@Override public RelDataType getRowType(RelDataTypeFactory relDataTypeFactory) { return tbl.getRowType(relDataTypeFactory); }
@Override public Object[] apply(final String schemaName) { final SchemaPlus subSchema = rootSchema.getSubSchema(schemaName); return new Object[]{ CATALOG_NAME, // CATALOG_NAME subSchema.getName(), // SCHEMA_NAME null, // SCHEMA_OWNER null, // DEFAULT_CHARACTER_SET_CATALOG null, // DEFAULT_CHARACTER_SET_SCHEMA null, // DEFAULT_CHARACTER_SET_NAME null // SQL_PATH }; } }
@Override public Statistic getStatistic() { return tbl.getStatistic(); }
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; }
@Override public Statistic getStatistic() { List<ImmutableBitSet> keys = new ArrayList<ImmutableBitSet>(); return Statistics.of(100, keys); }
@Override @SuppressWarnings("rawtypes") public Expression getExpression(final SchemaPlus schema, final String tableName, final Class clazz) { return Schemas.tableExpression(schema, getElementType(), tableName, clazz); }
/** * Return a view macro that may or may not be defined in a certain schema. If it's not defined, returns null. * * @param schemaPlus schema * @param functionName function name * * @return view, or null */ @Nullable private static TableMacro getView(final SchemaPlus schemaPlus, final String functionName) { // Look for a zero-arg function that is also a TableMacro. The returned value // is never null so we don't need to check for that. final Collection<org.apache.calcite.schema.Function> functions = schemaPlus.getFunctions(functionName); for (org.apache.calcite.schema.Function function : functions) { if (function.getParameters().isEmpty() && function instanceof TableMacro) { return (TableMacro) function; } } return null; }
@Override public Enumerable<Object[]> scan(final DataContext root) { final FluentIterable<Object[]> results = FluentIterable .from(rootSchema.getSubSchemaNames()) .transform( new Function<String, Object[]>() { @Override public Object[] apply(final String schemaName) { final SchemaPlus subSchema = rootSchema.getSubSchema(schemaName); return new Object[]{ CATALOG_NAME, // CATALOG_NAME subSchema.getName(), // SCHEMA_NAME null, // SCHEMA_OWNER null, // DEFAULT_CHARACTER_SET_CATALOG null, // DEFAULT_CHARACTER_SET_SCHEMA null, // DEFAULT_CHARACTER_SET_NAME null // SQL_PATH }; } } ); return Linq4j.asEnumerable(results); }
private boolean isRolledUpColumn(SqlIdentifier identifier, SqlValidatorScope scope) { Pair<String, String> pair = findTableColumnPair(identifier, scope); if (pair == null) { return false; } String tableAlias = pair.left; String columnName = pair.right; Table table = findTable(tableAlias); if (table != null) { return table.isRolledUp(columnName); } return false; }
private boolean isRolledUpColumnAllowedInAgg(SqlIdentifier identifier, SqlValidatorScope scope, SqlCall aggCall, SqlNode parent) { Pair<String, String> pair = findTableColumnPair(identifier, scope); if (pair == null) { return true; } String tableAlias = pair.left; String columnName = pair.right; Table table = findTable(tableAlias); if (table != null) { return table.rolledUpColumnValidInsideAgg(columnName, aggCall, parent, catalogReader.getConfig()); } return true; }
void setHolder(SchemaPlus plusOfThis) { for (String s : getSubSchemaNames()) { plusOfThis.add(s, getSubSchema(s)); } }
@Override public Statistic getStatistic() { return stat != null ? stat : Statistics.of(rows.size(), ImmutableList.<ImmutableBitSet>of()); }
void setHolder(SchemaPlus plusOfThis) { for (String s : getSubSchemaNames()) { plusOfThis.add(s, getSubSchemaKnownExists(s)); } }
void setHolder(SchemaPlus plusOfThis) { for (String s : getSubSchemaNames()) { CapitalizingJdbcSchema inner = getSubSchema(s); SchemaPlus holder = plusOfThis.add(s, inner); inner.setHolder(holder); } }
@Override public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) throws IOException { OpenTSDBSchema schema = new OpenTSDBSchema(getName()); parent.add(getName(), schema); }
void setHolder(SchemaPlus plusOfThis) { for (String s : getSubSchemaNames()) { CapitalizingJdbcSchema inner = getSubSchema(s); SchemaPlus holder = plusOfThis.add(s, inner); inner.setHolder(holder); } }
@Override public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) throws IOException { KafkaMessageSchema schema = new KafkaMessageSchema(plugin, getName()); SchemaPlus hPlus = parent.add(getName(), schema); schema.setHolder(hPlus); }
@Override public void registerSchemas(SchemaConfig config, SchemaPlus parent) { JdbcCatalogSchema schema = new JdbcCatalogSchema(getName()); SchemaPlus holder = parent.add(getName(), schema); schema.setHolder(holder); }
@Override public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) throws IOException { HBaseSchema schema = new HBaseSchema(getName()); SchemaPlus hPlus = parent.add(getName(), schema); schema.setHolder(hPlus); }
@Override public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) throws IOException { KuduTables schema = new KuduTables(getName()); SchemaPlus hPlus = parent.add(getName(), schema); schema.setHolder(hPlus); }