@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 }; } }
private Set<String> getAuthorizedTableNamesFromSubSchema( final SchemaPlus subSchema, final AuthenticationResult authenticationResult ) { if (DruidSchema.NAME.equals(subSchema.getName())) { // The "druid" schema's tables represent Druid datasources which require authorization return ImmutableSet.copyOf( AuthorizationUtils.filterAuthorizedResources( authenticationResult, subSchema.getTableNames(), DRUID_TABLE_RA_GENERATOR, authorizerMapper ) ); } else { // for non "druid" schema, we don't filter anything return subSchema.getTableNames(); } }
private Set<String> getAuthorizedFunctionNamesFromSubSchema( final SchemaPlus subSchema, final AuthenticationResult authenticationResult ) { if (DruidSchema.NAME.equals(subSchema.getName())) { // The "druid" schema's functions represent views on Druid datasources, authorize them as if they were // datasources for now return ImmutableSet.copyOf( AuthorizationUtils.filterAuthorizedResources( authenticationResult, subSchema.getFunctionNames(), DRUID_TABLE_RA_GENERATOR, authorizerMapper ) ); } else { // for non "druid" schema, we don't filter anything return subSchema.getFunctionNames(); } } }
public String getDefaultSchema() throws SQLException { if (defaultSchema == null) { if (connection == null) { return rootSchemaPlus.getName(); } else { return connection.getSchema(); } } else { return defaultSchema; } }
@Override public Object[] apply(final String schemaName) { final SchemaPlus subSchema = rootSchema.getSubSchema(schemaName); return new Object[]{ EMPTY_CATALOG, // 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 }; } }
private SchemaPlus currentMutableSchema(String elementType) { final SchemaPlus schema = currentSchema(); if (!schema.isMutable()) { throw new RuntimeException("Cannot define " + elementType + "; parent schema '" + schema.getName() + "' is not mutable"); } return schema; }
/** Returns the path to get to a schema from its root. */ public static Path path(SchemaPlus schema) { List<Pair<String, Schema>> list = new ArrayList<>(); for (SchemaPlus s = schema; s != null; s = s.getParentSchema()) { list.add(Pair.of(s.getName(), s)); } return new PathImpl(ImmutableList.copyOf(Lists.reverse(list))); }
/** Returns the path to get to a schema from its root. */ public static Path path(SchemaPlus schema) { List<Pair<String, Schema>> list = new ArrayList<>(); for (SchemaPlus s = schema; s != null; s = s.getParentSchema()) { list.add(Pair.of(s.getName(), s)); } return new PathImpl(ImmutableList.copyOf(Lists.reverse(list))); }
private SchemaPlus currentMutableSchema(String elementType) { final SchemaPlus schema = currentSchema(); if (!schema.isMutable()) { throw new RuntimeException("Cannot define " + elementType + "; parent schema '" + schema.getName() + "' is not mutable"); } return schema; }
/** Returns the expression for a schema. */ public static Expression expression(SchemaPlus schema) { return schema.getExpression(schema.getParentSchema(), schema.getName()); }
/** Returns the expression for a schema. */ public static Expression expression(SchemaPlus schema) { return schema.getExpression(schema.getParentSchema(), schema.getName()); }
/** Utility method to get the schema path as list for given schema instance. */ public static List<String> getSchemaPathAsList(SchemaPlus schema) { if (isRootSchema(schema)) { return Collections.emptyList(); } List<String> path = Lists.newArrayListWithCapacity(5); while(schema != null) { final String name = schema.getName(); if (!Strings.isNullOrEmpty(name)) { path.add(schema.getName()); } schema = schema.getParentSchema(); } return Lists.reverse(path); }
private Set<String> getAuthorizedTableNamesFromSubSchema( final SchemaPlus subSchema, final AuthenticationResult authenticationResult ) { if (DruidSchema.NAME.equals(subSchema.getName())) { // The "druid" schema's tables represent Druid datasources which require authorization return ImmutableSet.copyOf( AuthorizationUtils.filterAuthorizedResources( authenticationResult, subSchema.getTableNames(), DRUID_TABLE_RA_GENERATOR, authorizerMapper ) ); } else { // for non "druid" schema, we don't filter anything return subSchema.getTableNames(); } }
private Set<String> getAuthorizedFunctionNamesFromSubSchema( final SchemaPlus subSchema, final AuthenticationResult authenticationResult ) { if (DruidSchema.NAME.equals(subSchema.getName())) { // The "druid" schema's functions represent views on Druid datasources, authorize them as if they were // datasources for now return ImmutableSet.copyOf( AuthorizationUtils.filterAuthorizedResources( authenticationResult, subSchema.getFunctionNames(), DRUID_TABLE_RA_GENERATOR, authorizerMapper ) ); } else { // for non "druid" schema, we don't filter anything return subSchema.getFunctionNames(); } } }
public void scanSchema(SchemaPlus root) { if (shouldVisitCatalog() && visitCatalog()) { scanSchema(root.getName(), root); } }
@Override public Expression getExpression(SchemaPlus schema, String tableName, Class clazz) { return Expressions.field( schema.unwrap(ReflectiveSchema.class).getTargetExpression( schema.getParentSchema(), schema.getName()), field); } }
@Override public Expression getExpression(SchemaPlus schema, String tableName, Class clazz) { return Expressions.field( schema.unwrap(ReflectiveSchema.class).getTargetExpression( schema.getParentSchema(), schema.getName()), field); } }
drillSchema = schema.unwrap(AbstractSchema.class); } catch (ClassCastException e) { throw new RuntimeException(String.format("Schema '%s' is not expected under root schema", schema.getName()));
drillSchema = schema.unwrap(org.apache.drill.exec.store.AbstractSchema.class); } catch (ClassCastException e) { throw new RuntimeException(String.format("Schema '%s' is not expected under root schema", schema.getName()));
@Override public RelRoot expandView(RelDataType rowType, String queryString, SchemaPlus rootSchema, List<String> schemaPath) { final DrillCalciteCatalogReader catalogReader = new DrillCalciteCatalogReader( rootSchema, parserConfig.caseSensitive(), schemaPath, typeFactory, drillConfig, session); SchemaPlus schema = rootSchema; for (String s : schemaPath) { SchemaPlus newSchema = schema.getSubSchema(s); if (newSchema == null) { throw UserException .validationError() .message( "Failure while attempting to expand view. Requested schema %s not available in schema %s.", s, schema.getName()) .addContext("View Context", Joiner.on(", ").join(schemaPath)) .addContext("View SQL", queryString) .build(logger); } schema = newSchema; } SqlConverter parser = new SqlConverter(SqlConverter.this, schema, rootSchema, catalogReader); return expandView(queryString, parser); }