Java Code Examples for org.apache.calcite.jdbc.CalciteSchema#getFunctionNames()
The following examples show how to use
org.apache.calcite.jdbc.CalciteSchema#getFunctionNames() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalciteCatalogReader.java From calcite with Apache License 2.0 | 6 votes |
/** 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; }
Example 2
Source File: CalciteCatalogReader.java From calcite with Apache License 2.0 | 5 votes |
public List<SqlMoniker> getAllSchemaObjectNames(List<String> names) { final CalciteSchema schema = SqlValidatorUtil.getSchema(rootSchema, names, nameMatcher); if (schema == null) { return ImmutableList.of(); } final List<SqlMoniker> result = new ArrayList<>(); // Add root schema if not anonymous if (!schema.name.equals("")) { result.add(moniker(schema, null, SqlMonikerType.SCHEMA)); } final Map<String, CalciteSchema> schemaMap = schema.getSubSchemaMap(); for (String subSchema : schemaMap.keySet()) { result.add(moniker(schema, subSchema, SqlMonikerType.SCHEMA)); } for (String table : schema.getTableNames()) { result.add(moniker(schema, table, SqlMonikerType.TABLE)); } final NavigableSet<String> functions = schema.getFunctionNames(); for (String function : functions) { // views are here as well result.add(moniker(schema, function, SqlMonikerType.FUNCTION)); } return result; }