congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
ReflectiveSchema.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
net.hydromatic.optiq.impl.java.ReflectiveSchema
constructor

Best Java code snippets using net.hydromatic.optiq.impl.java.ReflectiveSchema.<init> (Showing top 16 results out of 315)

origin: org.apache.optiq/optiq-core

return new ReflectiveSchema(target);
origin: net.hydromatic/optiq

/**
 * Creates a ReflectiveSchema within another schema.
 *
 * @param parentSchema Parent schema
 * @param name Name of new schema
 * @param target Object whose fields become the tables of the schema
 * @return New ReflectiveSchema
 */
public static ReflectiveSchema create(
  MutableSchema parentSchema,
  String name,
  Object target) {
 ReflectiveSchema schema =
   new ReflectiveSchema(
     parentSchema,
     name,
     target,
     parentSchema.getSubSchemaExpression(
       name, ReflectiveSchema.class));
 parentSchema.addSchema(name, schema);
 return schema;
}
origin: org.apache.optiq/optiq-core

 public OptiqConnection createConnection() throws Exception {
  Class.forName("net.hydromatic.optiq.jdbc.Driver");
  Connection connection =
    DriverManager.getConnection("jdbc:optiq:");
  OptiqConnection optiqConnection =
    connection.unwrap(OptiqConnection.class);
  SchemaPlus rootSchema =
    optiqConnection.getRootSchema();
  rootSchema.add(name, new ReflectiveSchema(schema));
  optiqConnection.setSchema(name);
  return optiqConnection;
 }
});
origin: org.apache.optiq/optiq-core

  connection.unwrap(OptiqConnection.class);
SchemaPlus rootSchema = optiqConnection.getRootSchema();
rootSchema.add("hr", new ReflectiveSchema(new Hr()));
rootSchema.add("foodmart", new ReflectiveSchema(new Foodmart()));
Statement statement = connection.createStatement();
ResultSet resultSet =
origin: org.apache.optiq/optiq-core

/** Test case for bug where if two tables have different element classes
 * but those classes have identical fields, Optiq would generate code to use
 * the wrong element class; a {@link ClassCastException} would ensue. */
@Test public void testDifferentTypesSameFields() throws Exception {
 Class.forName("net.hydromatic.optiq.jdbc.Driver");
 Connection connection = DriverManager.getConnection("jdbc:optiq:");
 OptiqConnection optiqConnection =
   connection.unwrap(OptiqConnection.class);
 final SchemaPlus rootSchema = optiqConnection.getRootSchema();
 rootSchema.add("TEST", new ReflectiveSchema(new MySchema()));
 Statement statement = optiqConnection.createStatement();
 ResultSet resultSet =
   statement.executeQuery("SELECT \"myvalue\" from TEST.\"mytable2\"");
 assertEquals("myvalue=2\n", OptiqAssert.toString(resultSet));
 resultSet.close();
 statement.close();
 connection.close();
}
origin: org.apache.optiq/optiq-core

private Connection setup() throws SQLException {
 // Create a jdbc database & table
 final String db = TempDb.INSTANCE.getUrl();
 Connection c1 = DriverManager.getConnection(db, "", "");
 Statement stmt1 = c1.createStatement();
 // This is a table we can join with the emps from the hr schema
 stmt1.execute("create table table1(id integer not null primary key, "
     + "field1 varchar(10))");
 stmt1.execute("insert into table1 values(100, 'foo')");
 stmt1.execute("insert into table1 values(200, 'bar')");
 c1.close();
 // Make an optiq schema with both a jdbc schema and a non-jdbc schema
 Connection optiqConn = DriverManager.getConnection("jdbc:optiq:");
 OptiqConnection optiqConnection =
   optiqConn.unwrap(OptiqConnection.class);
 SchemaPlus rootSchema = optiqConnection.getRootSchema();
 rootSchema.add("DB",
   JdbcSchema.create(rootSchema, "DB",
     JdbcSchema.dataSource(db, "org.hsqldb.jdbcDriver", "", ""),
     null, null));
 rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema()));
 return optiqConn;
}
origin: org.apache.optiq/optiq-core

@Before
public void setUp() throws SQLException {
 Connection connection = DriverManager.getConnection("jdbc:optiq:");
 OptiqConnection optiqConnection = connection.unwrap(OptiqConnection.class);
 SchemaPlus rootSchema = optiqConnection.getRootSchema();
 rootSchema.add("test", new ReflectiveSchema(new TestSchema()));
 optiqConnection.setSchema("test");
 this.conn = optiqConnection;
}
origin: org.apache.optiq/optiq-core

/**
 * The example in the README.
 */
@Test public void testReadme() throws ClassNotFoundException, SQLException {
 Class.forName("net.hydromatic.optiq.jdbc.Driver");
 Connection connection = DriverManager.getConnection("jdbc:optiq:");
 OptiqConnection optiqConnection =
   connection.unwrap(OptiqConnection.class);
 final SchemaPlus rootSchema = optiqConnection.getRootSchema();
 rootSchema.add("hr", new ReflectiveSchema(new HrSchema()));
 Statement statement = optiqConnection.createStatement();
 ResultSet resultSet = statement.executeQuery(
   "select d.\"deptno\", min(e.\"empid\")\n"
     + "from \"hr\".\"emps\" as e\n"
     + "join \"hr\".\"depts\" as d\n"
     + "  on e.\"deptno\" = d.\"deptno\"\n"
     + "group by d.\"deptno\"\n"
     + "having count(*) > 1");
 final String s = OptiqAssert.toString(resultSet);
 assertThat(s, notNullValue());
 resultSet.close();
 statement.close();
 connection.close();
}
origin: org.apache.optiq/optiq-core

private String adviseSql(String sql) throws ClassNotFoundException,
  SQLException {
 Class.forName("net.hydromatic.optiq.jdbc.Driver");
 Properties info = new Properties();
 info.put("lex", "JAVA");
 info.put("quoting", "DOUBLE_QUOTE");
 Connection connection =
   DriverManager.getConnection("jdbc:optiq:", info);
 OptiqConnection optiqConnection =
   connection.unwrap(OptiqConnection.class);
 SchemaPlus rootSchema = optiqConnection.getRootSchema();
 rootSchema.add("hr", new ReflectiveSchema(new HrSchema()));
 SchemaPlus schema = rootSchema.add("s", new AbstractSchema());
 optiqConnection.setSchema("hr");
 final TableFunction table =
   new SqlAdvisorGetHintsFunction();
 schema.add("get_hints", table);
 PreparedStatement ps = connection.prepareStatement(
   "select *\n"
   + "from table(\"s\".\"get_hints\"(?, ?)) as t(id, names, type)");
 SqlParserUtil.StringAndPos sap = SqlParserUtil.findPos(sql);
 ps.setString(1, sap.sql);
 ps.setInt(2, sap.cursor);
 return OptiqAssert.toString(ps.executeQuery());
}
origin: org.apache.optiq/optiq-core

/**
 * Tests a view.
 */
@Test public void testView() throws SQLException, ClassNotFoundException {
 Class.forName("net.hydromatic.optiq.jdbc.Driver");
 Connection connection =
   DriverManager.getConnection("jdbc:optiq:");
 OptiqConnection optiqConnection =
   connection.unwrap(OptiqConnection.class);
 SchemaPlus rootSchema = optiqConnection.getRootSchema();
 SchemaPlus schema = rootSchema.add("s", new AbstractSchema());
 schema.add("emps_view",
   ViewTable.viewMacro(schema,
     "select * from \"hr\".\"emps\" where \"deptno\" = 10",
     null));
 rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema()));
 ResultSet resultSet = connection.createStatement().executeQuery(
   "select *\n"
   + "from \"s\".\"emps_view\"\n"
   + "where \"empid\" < 120");
 assertEquals(
   "empid=100; deptno=10; name=Bill; salary=10000.0; commission=1000\n"
   + "empid=110; deptno=10; name=Theodore; salary=11500.0; commission=250\n",
   OptiqAssert.toString(resultSet));
}
origin: org.apache.optiq/optiq-core

/**
 * Tests a relation that is accessed via method syntax.
 * The function returns a {@link net.hydromatic.linq4j.Queryable}.
 */
@Ignore
@Test public void testOperator() throws SQLException, ClassNotFoundException {
 Class.forName("net.hydromatic.optiq.jdbc.Driver");
 Connection connection =
   DriverManager.getConnection("jdbc:optiq:");
 OptiqConnection optiqConnection =
   connection.unwrap(OptiqConnection.class);
 SchemaPlus rootSchema = optiqConnection.getRootSchema();
 SchemaPlus schema = rootSchema.add("s", new AbstractSchema());
 schema.add("GenerateStrings",
   TableMacroImpl.create(JdbcTest.GENERATE_STRINGS_METHOD));
 schema.add("StringUnion",
   TableMacroImpl.create(JdbcTest.STRING_UNION_METHOD));
 rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema()));
 ResultSet resultSet = connection.createStatement().executeQuery(
   "select *\n"
   + "from table(s.StringUnion(\n"
   + "  GenerateStrings(5),\n"
   + "  cursor (select name from emps)))\n"
   + "where char_length(s) > 3");
 assertTrue(resultSet.next());
}
origin: org.apache.optiq/optiq-core

schema.add("null_emps",
  ViewTable.viewMacro(schema, "select * from \"emps\"", null));
rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema()));
final Statement statement = connection.createStatement();
ResultSet resultSet;
origin: org.apache.optiq/optiq-core

  driver.connect("jdbc:optiq:", new Properties());
SchemaPlus rootSchema = connection.getRootSchema();
rootSchema.add("hr", new ReflectiveSchema(new HrSchema()));
connection.setSchema("hr");
final Statement statement = connection.createStatement();
origin: org.apache.optiq/optiq-core

case REFLECTIVE_FOODMART:
 return rootSchema.add("foodmart",
   new ReflectiveSchema(new JdbcTest.FoodmartSchema()));
case JDBC_FOODMART:
 final DataSource dataSource =
case HR:
 return rootSchema.add("hr",
   new ReflectiveSchema(new JdbcTest.HrSchema()));
case LINGUAL:
 return rootSchema.add("SALES",
   new ReflectiveSchema(new JdbcTest.LingualSchema()));
case POST:
 final SchemaPlus post = rootSchema.add("POST", new AbstractSchema());
origin: org.apache.optiq/optiq-core

  driver.connect("jdbc:optiq:", new Properties());
SchemaPlus rootSchema = connection.getRootSchema();
rootSchema.add("hr", new ReflectiveSchema(new HrSchema()));
connection.setSchema("hr");
final Statement statement = connection.createStatement();
origin: org.apache.optiq/optiq-core

public String checkTpchQuery(String tpchTestQuery) throws Exception {
 final SchemaPlus schema =
   Frameworks.createRootSchema(true).add("tpch",
     new ReflectiveSchema(new TpchSchema()));
 final FrameworkConfig config = Frameworks.newConfigBuilder()
   .lex(Lex.MYSQL)
   .defaultSchema(schema)
   .programs(Programs.ofRules(Programs.RULE_SET))
   .build();
 Planner p = Frameworks.getPlanner(config);
 SqlNode n = p.parse(tpchTestQuery);
 n = p.validate(n);
 RelNode r = p.convert(n);
 String plan = RelOptUtil.toString(r);
 p.close();
 return plan;
}
net.hydromatic.optiq.impl.javaReflectiveSchema<init>

Javadoc

Creates a ReflectiveSchema.

Popular methods of ReflectiveSchema

  • create
    Creates a ReflectiveSchema within another schema.
  • fieldRelation
    Returns a table based on a particular field of this schema. If the field is not of the right type to
  • getElementType
    Deduces the element type of a collection; same logic as #toEnumerable
  • getExpression
  • getTargetExpression
    Returns an expression for the object wrapped by this schema (not the schema itself).
  • addTable
  • getQueryProvider
  • getTable
  • getTableMap
  • getTarget
    Returns the wrapped object. (May not appear to be used, but is used in generated code via BuiltinMet
  • methodMember
  • toEnumerable
  • methodMember,
  • toEnumerable

Popular in Java

  • Running tasks concurrently on multiple threads
  • setScale (BigDecimal)
  • getSharedPreferences (Context)
  • getResourceAsStream (ClassLoader)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now