Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static Function<Object, Object> compileCast(IgniteTypeFactory typeFactor
RexProgram program = programBuilder.getProgram();
BlockBuilder list = new BlockBuilder();
List<Expression> projects = RexToLixTranslator.translateProjects(program, typeFactory, SqlConformanceEnum.DEFAULT,
list, null, DataContext.ROOT, getter, null);
list, null, null, DataContext.ROOT, getter, null);
list.add(projects.get(0));

MethodDeclaration decl = Expressions.methodDecl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public RelOptTable getTableForMember(List<String> names) {
throw new SqlException(Common.INTERNAL_ERR, "Expected name of exactly two parts, but was " + names);
}

SchemaPlus schema = root.getSubSchema(names.get(0));
SchemaPlus schema = root.subSchemas().get(names.get(0));

if (schema == null) {
throw new SqlException(Common.INTERNAL_ERR, "Schema with name \"" + names.get(0) + "\" not found");
}

Table table = schema.getTable(names.get(1));
Table table = schema.tables().get(names.get(1));

if (table == null) {
throw new SqlException(Common.INTERNAL_ERR, "Table with name " + names + " not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import org.apache.calcite.plan.volcano.RelSubset;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.Aggregate;
import org.apache.calcite.rel.metadata.BuiltInMetadata;
import org.apache.calcite.rel.metadata.CyclicMetadataException;
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMdDistinctRowCount;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.NumberUtil;
import org.jetbrains.annotations.Nullable;
Expand All @@ -38,8 +38,7 @@
@SuppressWarnings("unused") // actually all methods are used by runtime generated classes
public class IgniteMdDistinctRowCount extends RelMdDistinctRowCount {
public static final RelMetadataProvider SOURCE =
ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.DISTINCT_ROW_COUNT.method, new IgniteMdDistinctRowCount());
ReflectiveRelMetadataProvider.reflectiveSource(new IgniteMdDistinctRowCount(), BuiltInMetadata.DistinctRowCount.Handler.class);

@Override
public Double getDistinctRowCount(Aggregate rel, RelMetadataQuery mq, ImmutableBitSet groupKey, @Nullable RexNode predicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.ignite.internal.sql.engine.rel.IgniteRel;
import org.apache.ignite.internal.sql.engine.schema.IgniteDataSource;
import org.apache.ignite.internal.sql.engine.trait.IgniteDistribution;
Expand All @@ -44,8 +43,7 @@ public class IgniteMdDistribution implements MetadataHandler<BuiltInMetadata.Dis
* Metadata provider, responsible for distribution type request. It uses this implementation class under the hood.
*/
public static final RelMetadataProvider SOURCE =
ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.DISTRIBUTION.method, new IgniteMdDistribution());
ReflectiveRelMetadataProvider.reflectiveSource(new IgniteMdDistribution(), BuiltInMetadata.Distribution.Handler.class);

/** {@inheritDoc} */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.util.BuiltInMethod;

/**
* IgniteMdNonCumulativeCost.
Expand All @@ -34,7 +33,7 @@
@SuppressWarnings("unused") // actually all methods are used by runtime generated classes
public class IgniteMdNonCumulativeCost implements MetadataHandler<BuiltInMetadata.NonCumulativeCost> {
public static final RelMetadataProvider SOURCE = ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.NON_CUMULATIVE_COST.method, new IgniteMdNonCumulativeCost());
new IgniteMdNonCumulativeCost(), BuiltInMetadata.NonCumulativeCost.Handler.class);

/**
* GetDef.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.ignite.internal.sql.engine.rel.ProjectableFilterableTableScan;

/**
Expand All @@ -36,7 +35,7 @@
@SuppressWarnings("unused") // actually all methods are used by runtime generated classes
public class IgniteMdPercentageOriginalRows implements MetadataHandler<BuiltInMetadata.PercentageOriginalRows> {
public static final RelMetadataProvider SOURCE = ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.PERCENTAGE_ORIGINAL_ROWS.method, new IgniteMdPercentageOriginalRows());
new IgniteMdPercentageOriginalRows(), BuiltInMetadata.PercentageOriginalRows.Handler.class);

/** {@inheritDoc} */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

import org.apache.calcite.plan.RelOptPredicateList;
import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.rel.metadata.BuiltInMetadata;
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMdPredicates;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.rex.RexUtil;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.ignite.internal.sql.engine.rel.ProjectableFilterableTableScan;
import org.apache.ignite.internal.sql.engine.util.RexUtils;

Expand All @@ -35,8 +35,8 @@
*/
@SuppressWarnings("unused") // actually all methods are used by runtime generated classes
public class IgniteMdPredicates extends RelMdPredicates {
public static final RelMetadataProvider SOURCE = ReflectiveRelMetadataProvider
.reflectiveSource(BuiltInMethod.PREDICATES.method, new IgniteMdPredicates());
public static final RelMetadataProvider SOURCE = ReflectiveRelMetadataProvider.reflectiveSource(
new IgniteMdPredicates(), BuiltInMetadata.Predicates.Handler.class);

/**
* See {@link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
import org.apache.calcite.rel.core.JoinRelType;
import org.apache.calcite.rel.core.Minus;
import org.apache.calcite.rel.core.Sort;
import org.apache.calcite.rel.metadata.BuiltInMetadata;
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelColumnOrigin;
import org.apache.calcite.rel.metadata.RelMdRowCount;
import org.apache.calcite.rel.metadata.RelMdUtil;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.calcite.util.ImmutableIntList;
import org.apache.calcite.util.mapping.IntPair;
import org.apache.ignite.internal.sql.engine.rel.IgniteAggregate;
Expand All @@ -56,8 +56,7 @@ public class IgniteMdRowCount extends RelMdRowCount {
public static final double NON_EQUI_COEFF = 0.7;

public static final RelMetadataProvider SOURCE =
ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.ROW_COUNT.method, new IgniteMdRowCount());
ReflectiveRelMetadataProvider.reflectiveSource(new IgniteMdRowCount(), BuiltInMetadata.RowCount.Handler.class);

/** {@inheritDoc} */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.rel.metadata.BuiltInMetadata;
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMdSelectivity;
import org.apache.calcite.rel.metadata.RelMdUtil;
Expand All @@ -36,7 +37,6 @@
import org.apache.calcite.rex.RexVisitor;
import org.apache.calcite.rex.RexVisitorImpl;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.calcite.util.ImmutableIntList;
import org.apache.calcite.util.Util;
import org.apache.calcite.util.mapping.Mapping;
Expand All @@ -58,8 +58,7 @@
*/
public class IgniteMdSelectivity extends RelMdSelectivity {
public static final RelMetadataProvider SOURCE =
ReflectiveRelMetadataProvider.reflectiveSource(
BuiltInMethod.SELECTIVITY.method, new IgniteMdSelectivity());
ReflectiveRelMetadataProvider.reflectiveSource(new IgniteMdSelectivity(), BuiltInMetadata.Selectivity.Handler.class);

public static final double EQ_SELECTIVITY = 0.333;
public static final double IS_NOT_NULL_SELECTIVITY = 0.9;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ private SqlNode rewriteTableToQuery(SqlNode from) {

SqlSelect expandedQry = new SqlSelect(SqlParserPos.ZERO, null,
SqlNodeList.of(SqlIdentifier.star(SqlParserPos.ZERO)), src, null, null, null,
null, null, null, null, null);
null, null, null, null, null, null);

return SqlValidatorUtil.addAlias(expandedQry, alias);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private SchemaPlus getDefaultSchema(int catalogVersion, String schemaName) {
assert rootSchema != null : "Root schema does not exist";

SchemaPlus schemaPlus = rootSchema.root();
SchemaPlus defaultSchema = schemaPlus.getSubSchema(schemaName);
SchemaPlus defaultSchema = schemaPlus.subSchemas().get(schemaName);
// If default schema does not exist or misconfigured, we should use the root schema as default one
// because there is no other schema for the validator to use.
if (defaultSchema == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import it.unimi.dsi.fastutil.ints.IntArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.apache.calcite.linq4j.Ord;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelOptCost;
Expand Down Expand Up @@ -74,7 +75,7 @@ public class IgniteProject extends Project implements TraitsAwareIgniteRel {
* @param rowType Output row type.
*/
public IgniteProject(RelOptCluster cluster, RelTraitSet traits, RelNode input, List<? extends RexNode> projects, RelDataType rowType) {
super(cluster, traits, List.of(), input, projects, rowType);
super(cluster, traits, List.of(), input, projects, rowType, Set.of());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,8 @@ private static MapReduceAgg createAvgAgg(
// PROJECT: reduce_sum/reduce_count

MakeReduceExpr reduceOutputExpr = (rexBuilder, input, args, typeFactory) -> {
RexNode numeratorRef = rexBuilder.makeInputRef(input, args.get(0));
RexInputRef denominatorRef = rexBuilder.makeInputRef(input, args.get(1));
RexNode numeratorRef = rexBuilder.makeInputRef(input, args.getInt(0));
RexInputRef denominatorRef = rexBuilder.makeInputRef(input, args.getInt(1));

numeratorRef = rexBuilder.ensureType(mapSum0.type, numeratorRef, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ private static PhysicalNode createAggregate(IgniteTableModify tableModify, RelOp
RelDataType rowCountType = modifiedRowsField.getType();
RelDataType sumType = IgniteTypeSystem.INSTANCE.deriveSumType(typeFactory, rowCountType);

AggregateCall sum = AggregateCall.create(SqlStdOperatorTable.SUM0, false, false,
false, ImmutableList.of(0), -1, null, RelCollations.EMPTY, 0, tableModify,
AggregateCall sum = AggregateCall.create(SqlStdOperatorTable.SUM0,
false, false, false,
ImmutableList.of(), ImmutableList.of(0), -1,
null, RelCollations.EMPTY,
sumType, null);

IgniteColocatedHashAggregate sumAgg = new IgniteColocatedHashAggregate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.calcite.rel.hint.RelHint;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.lookup.LikePattern;
import org.apache.calcite.tools.Frameworks;
import org.apache.calcite.util.ImmutableIntList;
import org.apache.ignite.internal.catalog.Catalog;
Expand Down Expand Up @@ -154,8 +155,8 @@ public IgniteTable table(int catalogVersion, int tableId) {
if (rootSchema != null) {
SchemaPlus schemaPlus = rootSchema.root();

for (String name : schemaPlus.getSubSchemaNames()) {
SchemaPlus subSchema = schemaPlus.getSubSchema(name);
for (String name : schemaPlus.subSchemas().getNames(LikePattern.any())) {
SchemaPlus subSchema = schemaPlus.subSchemas().get(name);

assert subSchema != null : name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public final class Commons {
.sqlValidatorConfig(SqlValidator.Config.DEFAULT
.withIdentifierExpansion(true)
.withDefaultNullCollation(NullCollation.HIGH)
.withSqlConformance(IgniteSqlConformance.INSTANCE)
.withConformance(IgniteSqlConformance.INSTANCE)
.withTypeCoercionRules(standardCompatibleCoercionRules())
.withTypeCoercionFactory(IgniteTypeCoercion::new))
// Dialects support.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private IgniteRel parseQuery(IgniteSchema schema, String sqlStmt) {
try {
PlanningContext ctx = PlanningContext.builder()
.frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
.defaultSchema(createRootSchema(List.of(schema)).getSubSchema(schema.getName()))
.defaultSchema(createRootSchema(List.of(schema)).subSchemas().get(schema.getName()))
.build())
.defaultSchemaName(schema.getName())
.query(sqlStmt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,11 @@ private static AggregateCall createAggregateCall(
List<Integer> args,
RelDataType resultType
) {
return AggregateCall.create(
func,
false,
false,
false,
args,
-1,
RelCollations.EMPTY,
resultType,
null
return AggregateCall.create(func,
false, false, false,
List.of(), args, -1,
null, RelCollations.EMPTY,
resultType, null
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.Table;
import org.apache.calcite.schema.lookup.LikePattern;
import org.apache.calcite.schema.lookup.Lookup;
import org.apache.calcite.tools.Frameworks;
import org.apache.ignite.internal.sql.engine.schema.IgniteSchema;
import org.apache.ignite.internal.sql.engine.schema.IgniteSchemas;
Expand Down Expand Up @@ -60,9 +63,10 @@ public PredefinedSchemaManager(Collection<IgniteSchema> schemas) {
for (IgniteSchema schema : schemas) {
schemaPlus.add(schema.getName(), schema);

Lookup<Table> tables = schema.tables();
tableById.putAll(
schema.getTableNames().stream()
.map(schema::getTable)
tables.getNames(LikePattern.any()).stream()
.map(tables::get)
.map(IgniteTable.class::cast)
.collect(toIntMapCollector(IgniteTable::id, identity()))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ protected PlanningContext plannerCtx(
}

SchemaPlus rootSchema = createRootSchema(schemas);
SchemaPlus defaultSchema = rootSchema.getSubSchema(DEFAULT_SCHEMA);
SchemaPlus defaultSchema = rootSchema.subSchemas().get(DEFAULT_SCHEMA);

if (defaultSchema == null && !schemas.isEmpty()) {
defaultSchema = rootSchema.getSubSchema(schemas.iterator().next().getName());
defaultSchema = rootSchema.subSchemas().get(schemas.iterator().next().getName());
}

assertNotNull(defaultSchema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,12 @@ private static class TestCase {
}

List<Integer> colocationKeys() {
IgniteTable table = (IgniteTable) schema.getTable("T");
IgniteTable table = (IgniteTable) schema.tables().get("T");
return table.distribution().getKeys();
}

List<String> columnNames() {
IgniteTable table = (IgniteTable) schema.getTable("T");
IgniteTable table = (IgniteTable) schema.tables().get("T");
List<String> names = new ArrayList<>();
TableDescriptor tableDescriptor = table.descriptor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testLongPlanningTimeout() {
PlanningContext ctx = PlanningContext.builder()
.plannerTimeout(plannerTimeout)
.frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
.defaultSchema(createRootSchema(List.of(schema)).getSubSchema(schema.getName()))
.defaultSchema(createRootSchema(List.of(schema)).subSchemas().get(schema.getName()))
.build())
.defaultSchemaName(schema.getName())
.query(sql)
Expand Down
Loading