public static SchemaPlus createRootSchema( final DruidSchema druidSchema, final SystemSchema systemSchema, final AuthorizerMapper authorizerMapper ) { final SchemaPlus rootSchema = CalciteSchema.createRootSchema(false, false).plus(); rootSchema.add(DruidSchema.NAME, druidSchema); rootSchema.add(InformationSchema.NAME, new InformationSchema(rootSchema, authorizerMapper)); rootSchema.add(SystemSchema.NAME, systemSchema); return rootSchema; }
/** Creates a root schema. * * <p>When <code>addMetadataSchema</code> argument is true adds a "metadata" * schema containing definitions of tables, columns etc. to root schema. * By default, creates a {@link CachingCalciteSchema}. */ public static CalciteSchema createRootSchema(boolean addMetadataSchema) { return createRootSchema(addMetadataSchema, true); }
/** Creates a root schema. * * <p>When <code>addMetadataSchema</code> argument is true adds a "metadata" * schema containing definitions of tables, columns etc. to root schema. * By default, creates a {@link CachingCalciteSchema}. */ public static CalciteSchema createRootSchema(boolean addMetadataSchema) { return createRootSchema(addMetadataSchema, true); }
/** Creates a root schema. * * @param addMetadataSchema Whether to add a "metadata" schema containing * definitions of tables, columns etc. * @param cache If true create {@link CachingCalciteSchema}; * if false create {@link SimpleCalciteSchema} */ public static CalciteSchema createRootSchema(boolean addMetadataSchema, boolean cache) { return createRootSchema(addMetadataSchema, cache, ""); }
/** Creates a root schema. * * @param addMetadataSchema Whether to add a "metadata" schema containing * definitions of tables, columns etc. * @param cache If true create {@link CachingCalciteSchema}; * if false create {@link SimpleCalciteSchema} */ public static CalciteSchema createRootSchema(boolean addMetadataSchema, boolean cache) { return createRootSchema(addMetadataSchema, cache, ""); }
/** * Creates a root schema. * * @param addMetadataSchema Whether to add "metadata" schema containing * definitions of tables, columns etc. */ public static SchemaPlus createRootSchema(boolean addMetadataSchema) { return CalciteSchema.createRootSchema(addMetadataSchema).plus(); }
/** * Creates a root schema. * * @param addMetadataSchema Whether to add "metadata" schema containing * definitions of tables, columns etc. */ public static SchemaPlus createRootSchema(boolean addMetadataSchema) { return CalciteSchema.createRootSchema(addMetadataSchema).plus(); }
/** * Creates a MockCatalogReader. * <p> * <p>Caller must then call {@link #init} to populate with data.</p> * * @param typeFactory Type factory */ public MockCatalogReader(RelDataTypeFactory typeFactory, boolean caseSensitive) { super(CalciteSchema.createRootSchema(false, false, DEFAULT_CATALOG), SqlNameMatchers.withCaseSensitive(caseSensitive), ImmutableList.of(PREFIX, ImmutableList.of()), typeFactory, null); }
/** * Creates a MockCatalogReader. * * <p>Caller must then call {@link #init} to populate with data.</p> * * @param typeFactory Type factory */ public MockCatalogReader(RelDataTypeFactory typeFactory, boolean caseSensitive) { super(CalciteSchema.createRootSchema(false, false, DEFAULT_CATALOG), SqlNameMatchers.withCaseSensitive(caseSensitive), ImmutableList.of(PREFIX, ImmutableList.of()), typeFactory, null); }
public static SchemaPlus createRootSchema( final DruidSchema druidSchema, final SystemSchema systemSchema, final AuthorizerMapper authorizerMapper ) { final SchemaPlus rootSchema = CalciteSchema.createRootSchema(false, false).plus(); rootSchema.add(DruidSchema.NAME, druidSchema); rootSchema.add(InformationSchema.NAME, new InformationSchema(rootSchema, authorizerMapper)); rootSchema.add(SystemSchema.NAME, systemSchema); return rootSchema; }
Objects.requireNonNull(rootSchema != null ? rootSchema : CalciteSchema.createRootSchema(true)); Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema"); this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
Objects.requireNonNull(rootSchema != null ? rootSchema : CalciteSchema.createRootSchema(true)); Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema"); this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
/** Creates an operator table that contains functions in the given class. * * @see ModelHandler#addFunctions */ public static SqlOperatorTable operatorTable(String className) { // Dummy schema to collect the functions final CalciteSchema schema = CalciteSchema.createRootSchema(false, false); ModelHandler.addFunctions(schema.plus(), null, ImmutableList.of(), className, "*", true); // The following is technical debt; see [CALCITE-2082] Remove // RelDataTypeFactory argument from SqlUserDefinedAggFunction constructor final SqlTypeFactoryImpl typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); final ListSqlOperatorTable table = new ListSqlOperatorTable(); for (String name : schema.getFunctionNames()) { for (Function function : schema.getFunctions(name, true)) { final SqlIdentifier id = new SqlIdentifier(name, SqlParserPos.ZERO); table.add( toOp(typeFactory, id, function)); } } return table; }
/** Creates an operator table that contains functions in the given class. * * @see ModelHandler#addFunctions */ public static SqlOperatorTable operatorTable(String className) { // Dummy schema to collect the functions final CalciteSchema schema = CalciteSchema.createRootSchema(false, false); ModelHandler.addFunctions(schema.plus(), null, ImmutableList.of(), className, "*", true); // The following is technical debt; see [CALCITE-2082] Remove // RelDataTypeFactory argument from SqlUserDefinedAggFunction constructor final SqlTypeFactoryImpl typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); final ListSqlOperatorTable table = new ListSqlOperatorTable(); for (String name : schema.getFunctionNames()) { for (Function function : schema.getFunctions(name, true)) { final SqlIdentifier id = new SqlIdentifier(name, SqlParserPos.ZERO); table.add( toOp(typeFactory, id, function)); } } return table; }
@Test public void testExplicitImplicitSchemaSameName() throws Exception { final SchemaPlus rootSchema = CalciteSchema.createRootSchema(false).plus(); // create schema "/a" final Map<String, Schema> aSubSchemaMap = new HashMap<>(); final SchemaPlus aSchema = rootSchema.add("a", new AbstractSchema() { @Override protected Map<String, Schema> getSubSchemaMap() { return aSubSchemaMap; } }); // add explicit schema "/a/b". aSchema.add("b", new AbstractSchema()); // add implicit schema "/a/b" aSubSchemaMap.put("b", new AbstractSchema()); aSchema.setCacheEnabled(true); // explicit should win implicit. assertThat(aSchema.getSubSchemaNames().size(), is(1)); }
@Test public void testSimpleCalciteSchema() throws Exception { final SchemaPlus rootSchema = CalciteSchema.createRootSchema(false, false).plus(); // create schema "/a" final Map<String, Schema> aSubSchemaMap = new HashMap<>(); final SchemaPlus aSchema = rootSchema.add("a", new AbstractSchema() { @Override protected Map<String, Schema> getSubSchemaMap() { return aSubSchemaMap; } }); // add explicit schema "/a/b". aSchema.add("b", new AbstractSchema()); // add implicit schema "/a/c" aSubSchemaMap.put("c", new AbstractSchema()); assertThat(aSchema.getSubSchema("c"), notNullValue()); assertThat(aSchema.getSubSchema("b"), notNullValue()); // add implicit schema "/a/b" aSubSchemaMap.put("b", new AbstractSchema()); // explicit should win implicit. assertThat(aSchema.getSubSchemaNames().size(), is(2)); }
@Test public void testSimpleCalciteSchema() throws Exception { final SchemaPlus rootSchema = CalciteSchema.createRootSchema(false, false).plus(); // create schema "/a" final Map<String, Schema> aSubSchemaMap = new HashMap<>(); final SchemaPlus aSchema = rootSchema.add("a", new AbstractSchema() { @Override protected Map<String, Schema> getSubSchemaMap() { return aSubSchemaMap; } }); // add explicit schema "/a/b". aSchema.add("b", new AbstractSchema()); // add implicit schema "/a/c" aSubSchemaMap.put("c", new AbstractSchema()); assertThat(aSchema.getSubSchema("c"), notNullValue()); assertThat(aSchema.getSubSchema("b"), notNullValue()); // add implicit schema "/a/b" aSubSchemaMap.put("b", new AbstractSchema()); // explicit should win implicit. assertThat(aSchema.getSubSchemaNames().size(), is(2)); }
@Test public void testExplicitImplicitSchemaSameName() throws Exception { final SchemaPlus rootSchema = CalciteSchema.createRootSchema(false).plus(); // create schema "/a" final Map<String, Schema> aSubSchemaMap = new HashMap<>(); final SchemaPlus aSchema = rootSchema.add("a", new AbstractSchema() { @Override protected Map<String, Schema> getSubSchemaMap() { return aSubSchemaMap; } }); // add explicit schema "/a/b". aSchema.add("b", new AbstractSchema()); // add implicit schema "/a/b" aSubSchemaMap.put("b", new AbstractSchema()); aSchema.setCacheEnabled(true); // explicit should win implicit. assertThat(aSchema.getSubSchemaNames().size(), is(1)); }
@Test public void testSimpleCalciteSchemaWithView() throws Exception { final SchemaPlus rootSchema = CalciteSchema.createRootSchema(false, false).plus();
@Test public void testSimpleCalciteSchemaWithView() throws Exception { final SchemaPlus rootSchema = CalciteSchema.createRootSchema(false, false).plus();