Search in sources :

Example 1 with TableResolver

use of com.hazelcast.sql.impl.schema.TableResolver in project hazelcast by hazelcast.

the class ParserOperationsTest method createContext.

private static OptimizerContext createContext() {
    PartitionedMapTable partitionedMapTable = new PartitionedMapTable("public", "t", "t", Arrays.asList(field("a"), field("b")), new ConstantTableStatistics(100L), null, null, null, null, null, false);
    TableResolver resolver = TestTableResolver.create("public", partitionedMapTable);
    List<TableResolver> tableResolvers = Collections.singletonList(resolver);
    List<List<String>> searchPaths = QueryUtils.prepareSearchPaths(emptyList(), tableResolvers);
    return OptimizerContext.create(new SqlCatalog(tableResolvers), searchPaths, emptyList(), 1, name -> null);
}
Also used : SqlCatalog(com.hazelcast.sql.impl.schema.SqlCatalog) TableResolver(com.hazelcast.sql.impl.schema.TableResolver) TestTableResolver(com.hazelcast.jet.sql.impl.TestTableResolver) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ConstantTableStatistics(com.hazelcast.sql.impl.schema.ConstantTableStatistics)

Example 2 with TableResolver

use of com.hazelcast.sql.impl.schema.TableResolver in project hazelcast by hazelcast.

the class ParserNameResolutionTest method createContext.

private static OptimizerContext createContext() {
    PartitionedMapTable table1 = new PartitionedMapTable(SCHEMA_1, TABLE_1, TABLE_1, Arrays.asList(field(FIELD_1), field(FIELD_2)), new ConstantTableStatistics(100L), null, null, null, null, null, false);
    PartitionedMapTable table2 = new PartitionedMapTable(SCHEMA_2, TABLE_2, TABLE_2, Arrays.asList(field(FIELD_1), field(FIELD_2)), new ConstantTableStatistics(100L), null, null, null, null, null, false);
    TableResolver resolver1 = TestTableResolver.create(SCHEMA_1, table1);
    TableResolver resolver2 = TestTableResolver.create(SCHEMA_2, table2);
    List<TableResolver> tableResolvers = Arrays.asList(resolver1, resolver2);
    List<List<String>> searchPaths = QueryUtils.prepareSearchPaths(emptyList(), tableResolvers);
    return OptimizerContext.create(new SqlCatalog(tableResolvers), searchPaths, emptyList(), 1, name -> null);
}
Also used : SqlCatalog(com.hazelcast.sql.impl.schema.SqlCatalog) TableResolver(com.hazelcast.sql.impl.schema.TableResolver) TestTableResolver(com.hazelcast.jet.sql.impl.TestTableResolver) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) SqlNodeList(org.apache.calcite.sql.SqlNodeList) ConstantTableStatistics(com.hazelcast.sql.impl.schema.ConstantTableStatistics)

Example 3 with TableResolver

use of com.hazelcast.sql.impl.schema.TableResolver in project hazelcast by hazelcast.

the class QueryUtils method prepareSearchPaths.

public static List<List<String>> prepareSearchPaths(List<List<String>> currentSearchPaths, List<TableResolver> tableResolvers) {
    // Current search paths have the highest priority.
    List<List<String>> res = new ArrayList<>();
    if (currentSearchPaths != null) {
        res.addAll(currentSearchPaths);
    }
    // Then add paths from table resolvers.
    if (tableResolvers != null) {
        for (TableResolver tableResolver : tableResolvers) {
            res.addAll(tableResolver.getDefaultSearchPaths());
        }
    }
    // Add catalog scope.
    res.add(Collections.singletonList(QueryUtils.CATALOG));
    // Add top-level scope.
    res.add(Collections.emptyList());
    return res;
}
Also used : TableResolver(com.hazelcast.sql.impl.schema.TableResolver) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

TableResolver (com.hazelcast.sql.impl.schema.TableResolver)3 List (java.util.List)3 TestTableResolver (com.hazelcast.jet.sql.impl.TestTableResolver)2 ConstantTableStatistics (com.hazelcast.sql.impl.schema.ConstantTableStatistics)2 SqlCatalog (com.hazelcast.sql.impl.schema.SqlCatalog)2 PartitionedMapTable (com.hazelcast.sql.impl.schema.map.PartitionedMapTable)2 Collections.emptyList (java.util.Collections.emptyList)2 ArrayList (java.util.ArrayList)1 SqlNodeList (org.apache.calcite.sql.SqlNodeList)1