public Schema create( SchemaPlus parentSchema, String name, Map<String, Object> operand) { SchemaPlus schema = parentSchema.add(name, JdbcSchema.create(parentSchema, name + "$source", operand)); return new CloneSchema(schema); } }
@Deprecated // to be removed before 2.0 public static <T> Table createCloneTable(final JavaTypeFactory typeFactory, final RelProtoDataType protoRowType, final List<ColumnMetaData.Rep> repList, final Enumerable<T> source) { return createCloneTable(typeFactory, protoRowType, ImmutableList.of(), repList, source); }
public Schema create( SchemaPlus parentSchema, String name, Map<String, Object> operand) { SchemaPlus schema = parentSchema.add(name, JdbcSchema.create(parentSchema, name + "$source", operand)); return new CloneSchema(schema); } }
@Deprecated // to be removed before 2.0 public static <T> Table createCloneTable(final JavaTypeFactory typeFactory, final RelProtoDataType protoRowType, final List<ColumnMetaData.Rep> repList, final Enumerable<T> source) { return createCloneTable(typeFactory, protoRowType, ImmutableList.of(), repList, source); }
@Test public void testCloneSchema() throws ClassNotFoundException, SQLException { final Connection connection = CalciteAssert.that(CalciteAssert.Config.JDBC_FOODMART).connect(); final CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class); final SchemaPlus rootSchema = calciteConnection.getRootSchema(); final SchemaPlus foodmart = rootSchema.getSubSchema("foodmart"); rootSchema.add("foodmart2", new CloneSchema(foodmart)); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery( "select count(*) from \"foodmart2\".\"time_by_day\""); assertTrue(resultSet.next()); assertEquals(730, resultSet.getInt(1)); resultSet.close(); connection.close(); }
@Override protected Map<String, Table> getTableMap() { final Map<String, Table> map = new LinkedHashMap<>(); for (String name : sourceSchema.getTableNames()) { final Table table = sourceSchema.getTable(name); if (table instanceof QueryableTable) { final QueryableTable sourceTable = (QueryableTable) table; map.put(name, createCloneTable(MATERIALIZATION_CONNECTION, sourceTable, name)); } } return map; }
@Test public void testCloneSchema() throws ClassNotFoundException, SQLException { final Connection connection = CalciteAssert.that(CalciteAssert.Config.JDBC_FOODMART).connect(); final CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class); final SchemaPlus rootSchema = calciteConnection.getRootSchema(); final SchemaPlus foodmart = rootSchema.getSubSchema("foodmart"); rootSchema.add("foodmart2", new CloneSchema(foodmart)); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery( "select count(*) from \"foodmart2\".\"time_by_day\""); assertTrue(resultSet.next()); assertEquals(730, resultSet.getInt(1)); resultSet.close(); connection.close(); }
@Override protected Map<String, Table> getTableMap() { final Map<String, Table> map = new LinkedHashMap<>(); for (String name : sourceSchema.getTableNames()) { final Table table = sourceSchema.getTable(name); if (table instanceof QueryableTable) { final QueryableTable sourceTable = (QueryableTable) table; map.put(name, createCloneTable(MATERIALIZATION_CONNECTION, sourceTable, name)); } } return map; }
case SCOTT: jdbcScott = addSchemaIfNotExists(rootSchema, SchemaSpec.JDBC_SCOTT); return rootSchema.add(schema.schemaName, new CloneSchema(jdbcScott)); case CLONE_FOODMART: foodmart = addSchemaIfNotExists(rootSchema, SchemaSpec.JDBC_FOODMART); return rootSchema.add("foodmart2", new CloneSchema(foodmart)); case GEO: ModelHandler.addFunctions(rootSchema, null, ImmutableList.of(),
private Table createCloneTable(QueryProvider queryProvider, QueryableTable sourceTable, String name) { final Queryable<Object> queryable = sourceTable.asQueryable(queryProvider, sourceSchema, name); final JavaTypeFactory typeFactory = ((CalciteConnection) queryProvider).getTypeFactory(); return createCloneTable(typeFactory, Schemas.proto(sourceTable), ImmutableList.of(), null, queryable); }
case SCOTT: jdbcScott = addSchemaIfNotExists(rootSchema, SchemaSpec.JDBC_SCOTT); return rootSchema.add(schema.schemaName, new CloneSchema(jdbcScott)); case CLONE_FOODMART: foodmart = addSchemaIfNotExists(rootSchema, SchemaSpec.JDBC_FOODMART); return rootSchema.add("foodmart2", new CloneSchema(foodmart)); case GEO: ModelHandler.addFunctions(rootSchema, null, ImmutableList.of(),
private Table createCloneTable(QueryProvider queryProvider, QueryableTable sourceTable, String name) { final Queryable<Object> queryable = sourceTable.asQueryable(queryProvider, sourceSchema, name); final JavaTypeFactory typeFactory = ((CalciteConnection) queryProvider).getTypeFactory(); return createCloneTable(typeFactory, Schemas.proto(sourceTable), ImmutableList.of(), null, queryable); }
final CalcitePrepare.CalciteSignature<Object> calciteSignature = Schemas.prepare(connection, schema, viewSchemaPath, viewSql, map); return CloneSchema.createCloneTable(connection.getTypeFactory(), RelDataTypeImpl.proto(calciteSignature.rowType), calciteSignature.getCollationList(),
final CalcitePrepare.CalciteSignature<Object> calciteSignature = Schemas.prepare(connection, schema, viewSchemaPath, viewSql, map); return CloneSchema.createCloneTable(connection.getTypeFactory(), RelDataTypeImpl.proto(calciteSignature.rowType), calciteSignature.getCollationList(),