diff --git a/core/src/main/java/org/polypheny/db/algebra/SingleAlg.java b/core/src/main/java/org/polypheny/db/algebra/SingleAlg.java index 1b5f615222..2be776f4c6 100644 --- a/core/src/main/java/org/polypheny/db/algebra/SingleAlg.java +++ b/core/src/main/java/org/polypheny/db/algebra/SingleAlg.java @@ -36,6 +36,7 @@ import com.google.common.collect.ImmutableList; import java.util.List; +import lombok.Getter; import lombok.experimental.SuperBuilder; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.type.AlgDataType; @@ -49,6 +50,7 @@ * It is not required that single-input relational expressions use this class as a base class. However, default * implementations of methods make life easier. */ +@Getter @SuperBuilder(toBuilder = true) public abstract class SingleAlg extends AbstractAlgNode { @@ -67,11 +69,6 @@ protected SingleAlg( AlgOptCluster cluster, AlgTraitSet traits, AlgNode input ) } - public AlgNode getInput() { - return input; - } - - @Override public List getInputs() { return ImmutableList.of( input ); diff --git a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableJoin.java b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableJoin.java index 3addb6d71f..5b3c4a7148 100644 --- a/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableJoin.java +++ b/core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableJoin.java @@ -112,7 +112,7 @@ public AlgOptCost computeSelfCost( AlgOptPlanner planner, AlgMetadataQuery mq ) } else { rowCount += rightRowCount; } - return planner.getCostFactory().makeCost( rowCount, 0, 0 ); + return planner.getCostFactory().makeCost( rowCount, 0, 0 ).multiplyBy( 100 ); // de-courage usage of enumerable } diff --git a/core/src/main/java/org/polypheny/db/algebra/rules/ScanRule.java b/core/src/main/java/org/polypheny/db/algebra/rules/ScanRule.java index 5f84f4bd63..4dd0c794a1 100644 --- a/core/src/main/java/org/polypheny/db/algebra/rules/ScanRule.java +++ b/core/src/main/java/org/polypheny/db/algebra/rules/ScanRule.java @@ -41,7 +41,7 @@ public class ScanRule extends AlgOptRule { * @param algBuilderFactory Builder for relational expressions */ public ScanRule( AlgBuilderFactory algBuilderFactory ) { - super( operand( LogicalRelScan.class, any() ), algBuilderFactory, null ); + super( operand( LogicalRelScan.class, any() ), algBuilderFactory, ScanRule.class.getSimpleName() ); } @@ -55,4 +55,5 @@ public void onMatch( AlgOptRuleCall call ) { call.transformTo( newAlg ); } + } diff --git a/core/src/main/java/org/polypheny/db/plan/AlgOptPlanner.java b/core/src/main/java/org/polypheny/db/plan/AlgOptPlanner.java index 1caba99395..95922165ab 100644 --- a/core/src/main/java/org/polypheny/db/plan/AlgOptPlanner.java +++ b/core/src/main/java/org/polypheny/db/plan/AlgOptPlanner.java @@ -41,6 +41,7 @@ import org.polypheny.db.algebra.metadata.AlgMetadataProvider; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.algebra.metadata.CachingAlgMetadataProvider; +import org.polypheny.db.plan.volcano.VolcanoPlannerPhase; import org.polypheny.db.rex.RexExecutor; import org.polypheny.db.util.trace.PolyphenyDbTrace; import org.slf4j.Logger; @@ -106,6 +107,8 @@ public interface AlgOptPlanner { */ boolean addRule( AlgOptRule rule ); + boolean addRule( AlgOptRule operand, VolcanoPlannerPhase phase ); + /** * Removes a rule. * @@ -171,8 +174,8 @@ public interface AlgOptPlanner { * * The expression must not already have been registered. If you are not sure whether it has been registered, call {@link #ensureRegistered(AlgNode, AlgNode)}. * - * @param alg Relational expression to register (must not already be registered) - * @param equivAlg Relational expression it is equivalent to (may be null) + * @param alg Algebraic expression to register (must not already be registered) + * @param equivAlg Algebraic expression it is equivalent to (may be null) * @return the same expression, or an equivalent existing expression */ AlgNode register( AlgNode alg, AlgNode equivAlg ); @@ -180,13 +183,13 @@ public interface AlgOptPlanner { /** * Registers an algebra expression if it is not already registered. * - * If {@code equivRel} is specified, {@code rel} is placed in the same equivalence set. It is OK if {@code equivRel} has different traits; - * {@code rel} will end up in a different subset of the same set. + * If {@code equivAlg} is specified, {@code alg} is placed in the same equivalence set. It is OK if {@code equivAlg} has different traits; + * {@code alg} will end up in a different subset of the same set. * * It is OK if {@code alg} is a subset. * - * @param alg Relational expression to register - * @param equivAlg Relational expression it is equivalent to (may be null) + * @param alg Algebraic expression to register + * @param equivAlg Algebraic expression it is equivalent to (may be null) * @return Registered relational expression */ AlgNode ensureRegistered( AlgNode alg, AlgNode equivAlg ); diff --git a/core/src/main/java/org/polypheny/db/plan/AlgOptRule.java b/core/src/main/java/org/polypheny/db/plan/AlgOptRule.java index c885592bc9..06e090874f 100644 --- a/core/src/main/java/org/polypheny/db/plan/AlgOptRule.java +++ b/core/src/main/java/org/polypheny/db/plan/AlgOptRule.java @@ -41,6 +41,7 @@ import java.util.Objects; import java.util.function.Predicate; import java.util.stream.Collectors; +import lombok.Getter; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.convert.Converter; import org.polypheny.db.algebra.convert.ConverterRule; @@ -64,7 +65,13 @@ public abstract class AlgOptRule { /** * Root of operand tree. + * -- GETTER -- + * Returns the root operand of this rule + * + * @return the root operand of this rule + */ + @Getter private final AlgOptRuleOperand operand; /** @@ -356,16 +363,6 @@ private void assignSolveOrder() { } - /** - * Returns the root operand of this rule - * - * @return the root operand of this rule - */ - public AlgOptRuleOperand getOperand() { - return operand; - } - - /** * Returns a flattened list of operands of this rule. * diff --git a/core/src/main/java/org/polypheny/db/plan/AlgOptRuleCall.java b/core/src/main/java/org/polypheny/db/plan/AlgOptRuleCall.java index 257bc0e9fa..bf8352d1d0 100644 --- a/core/src/main/java/org/polypheny/db/plan/AlgOptRuleCall.java +++ b/core/src/main/java/org/polypheny/db/plan/AlgOptRuleCall.java @@ -39,6 +39,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import lombok.Getter; import org.polypheny.db.algebra.AlgNode; import org.polypheny.db.algebra.core.Filter; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; @@ -60,11 +61,19 @@ public abstract class AlgOptRuleCall { private static int nextId = 0; public final int id; + + @Getter protected final AlgOptRuleOperand operand0; protected Map> nodeInputs; + + @Getter public final AlgOptRule rule; public final AlgNode[] algs; + + @Getter private final AlgOptPlanner planner; + + @Getter private final List parents; @@ -94,26 +103,6 @@ protected AlgOptRuleCall( AlgOptPlanner planner, AlgOptRuleOperand operand, AlgN } - /** - * Returns the root operand matched by this rule. - * - * @return root operand - */ - public AlgOptRuleOperand getOperand0() { - return operand0; - } - - - /** - * Returns the invoked planner rule. - * - * @return planner rule - */ - public AlgOptRule getRule() { - return rule; - } - - /** * Returns a list of matched relational expressions. * @@ -166,16 +155,6 @@ protected void setChildAlgs( AlgNode alg, List inputs ) { } - /** - * Returns the planner. - * - * @return planner - */ - public AlgOptPlanner getPlanner() { - return planner; - } - - /** * Returns the current RelMetadataQuery, to be used for instance by {@link AlgOptRule#onMatch(AlgOptRuleCall)}. */ @@ -184,14 +163,6 @@ public AlgMetadataQuery getMetadataQuery() { } - /** - * @return list of parents of the first relational expression - */ - public List getParents() { - return parents; - } - - /** * Registers that a rule has produced an equivalent algebraic expression. * diff --git a/core/src/main/java/org/polypheny/db/plan/hep/HepPlanner.java b/core/src/main/java/org/polypheny/db/plan/hep/HepPlanner.java index 8128681701..8d5f65dd7c 100644 --- a/core/src/main/java/org/polypheny/db/plan/hep/HepPlanner.java +++ b/core/src/main/java/org/polypheny/db/plan/hep/HepPlanner.java @@ -65,6 +65,7 @@ import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.plan.CommonRelSubExprRule; import org.polypheny.db.plan.Context; +import org.polypheny.db.plan.volcano.VolcanoPlannerPhase; import org.polypheny.db.util.Pair; import org.polypheny.db.util.Util; import org.polypheny.db.util.graph.BreadthFirstIterator; @@ -179,6 +180,12 @@ public boolean addRule( AlgOptRule rule ) { } + @Override + public boolean addRule( AlgOptRule rule, VolcanoPlannerPhase phase ) { + return addRule( rule ); + } + + @Override public void clear() { super.clear(); diff --git a/core/src/main/java/org/polypheny/db/plan/volcano/RuleQueue.java b/core/src/main/java/org/polypheny/db/plan/volcano/RuleQueue.java index 019fa829a2..590b95d6da 100644 --- a/core/src/main/java/org/polypheny/db/plan/volcano/RuleQueue.java +++ b/core/src/main/java/org/polypheny/db/plan/volcano/RuleQueue.java @@ -57,6 +57,7 @@ import org.polypheny.db.algebra.AlgNodes; import org.polypheny.db.algebra.metadata.AlgMetadataQuery; import org.polypheny.db.plan.AlgOptCost; +import org.polypheny.db.plan.AlgOptRule; import org.polypheny.db.plan.AlgOptRuleOperand; import org.polypheny.db.util.Util; import org.polypheny.db.util.trace.PolyphenyDbTrace; @@ -139,6 +140,13 @@ class RuleQueue { } + public boolean addPhaseRuleMapping( VolcanoPlannerPhase phase, AlgOptRule rule ) { + phaseRuleMapping.get( phase ).add( rule.getClass().getSimpleName() ); + return true; + + } + + /** * Clear internal data structure for this rule queue. */ @@ -616,7 +624,7 @@ public int compare( VolcanoRuleMatch match1, VolcanoRuleMatch match2 ) { /** * PhaseMatchList represents a set of {@link VolcanoRuleMatch rule-matches} for a particular {@link VolcanoPlannerPhase phase of the planner's execution}. */ - private static class PhaseMatchList { + static class PhaseMatchList { /** * The VolcanoPlannerPhase that this PhaseMatchList is used in. diff --git a/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoPlanner.java b/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoPlanner.java index 4d3656ab8b..a80ea95a6c 100644 --- a/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoPlanner.java +++ b/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoPlanner.java @@ -378,6 +378,16 @@ public List getRules() { } + @Override + public boolean addRule( AlgOptRule rule, VolcanoPlannerPhase phase ) { + if ( ruleSet.contains( rule ) ) { + // Rule already exists. + return false; + } + ruleQueue.addPhaseRuleMapping( phase, rule ); + return addRule( rule ); + } + @Override public boolean addRule( AlgOptRule rule ) { if ( locked ) { diff --git a/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoRuleCall.java b/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoRuleCall.java index c06e4b3cf5..dce72f93ff 100644 --- a/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoRuleCall.java +++ b/core/src/main/java/org/polypheny/db/plan/volcano/VolcanoRuleCall.java @@ -129,7 +129,7 @@ public void transformTo( AlgNode alg, Map equiv ) { volcanoPlanner.listener.ruleProductionSucceeded( event ); } } catch ( Exception e ) { - throw new RuntimeException( "Error occurred while applying rule " + getRule(), e ); + throw new GenericRuntimeException( "Error occurred while applying rule " + getRule(), e ); } } diff --git a/core/src/main/java/org/polypheny/db/prepare/PolyphenyDbPrepareImpl.java b/core/src/main/java/org/polypheny/db/prepare/PolyphenyDbPrepareImpl.java index cf7192ba27..5a69be964b 100644 --- a/core/src/main/java/org/polypheny/db/prepare/PolyphenyDbPrepareImpl.java +++ b/core/src/main/java/org/polypheny/db/prepare/PolyphenyDbPrepareImpl.java @@ -132,6 +132,7 @@ import org.polypheny.db.plan.Convention; import org.polypheny.db.plan.ConventionTraitDef; import org.polypheny.db.plan.volcano.VolcanoPlanner; +import org.polypheny.db.plan.volcano.VolcanoPlannerPhase; import org.polypheny.db.prepare.Prepare.PreparedExplain; import org.polypheny.db.rex.RexBuilder; import org.polypheny.db.rex.RexNode; @@ -226,15 +227,19 @@ public class PolyphenyDbPrepareImpl implements PolyphenyDbPrepare { DocumentSortToSortRule.INSTANCE ); - public static final List DEFAULT_RULES = + public static final List PRE_PROCESS_RULES = ImmutableList.of( - ScanRule.INSTANCE, AllocationToPhysicalScanRule.REL_INSTANCE, AllocationToPhysicalScanRule.DOC_INSTANCE, AllocationToPhysicalScanRule.GRAPH_INSTANCE, AllocationToPhysicalModifyRule.REL_INSTANCE, AllocationToPhysicalModifyRule.DOC_INSTANCE, - AllocationToPhysicalModifyRule.GRAPH_INSTANCE, + AllocationToPhysicalModifyRule.GRAPH_INSTANCE + ); + + public static final List DEFAULT_RULES = + ImmutableList.of( + ScanRule.INSTANCE, RuntimeConfig.JOIN_COMMUTE.getBoolean() ? JoinAssociateRule.INSTANCE : ProjectMergeRule.INSTANCE, @@ -311,6 +316,12 @@ protected AlgOptPlanner createPlanner( final Context prepareContext, org.polyphe } AlgOptUtil.registerAbstractAlgs( planner ); + + for ( AlgOptRule preProcessRule : PRE_PROCESS_RULES ) { + planner.addRule( preProcessRule, VolcanoPlannerPhase.PRE_PROCESS ); + } + + for ( AlgOptRule rule : DEFAULT_RULES ) { planner.addRule( rule ); } diff --git a/core/src/test/java/org/polypheny/db/test/MockRelOptPlanner.java b/core/src/test/java/org/polypheny/db/test/MockRelOptPlanner.java index 68cff0e9f5..6dd8c706dd 100644 --- a/core/src/test/java/org/polypheny/db/test/MockRelOptPlanner.java +++ b/core/src/test/java/org/polypheny/db/test/MockRelOptPlanner.java @@ -31,6 +31,7 @@ import org.polypheny.db.plan.AlgOptRuleOperand; import org.polypheny.db.plan.AlgTraitSet; import org.polypheny.db.plan.Context; +import org.polypheny.db.plan.volcano.VolcanoPlannerPhase; import org.polypheny.db.rex.RexExecutorImpl; import org.polypheny.db.schema.Schemas; import org.polypheny.db.util.Pair; @@ -96,6 +97,12 @@ public boolean addRule( AlgOptRule rule ) { } + @Override + public boolean addRule( AlgOptRule operand, VolcanoPlannerPhase phase ) { + return addRule( rule ); + } + + @Override public boolean removeRule( AlgOptRule rule ) { return false; diff --git a/dbms/src/main/java/org/polypheny/db/processing/VolcanoQueryProcessor.java b/dbms/src/main/java/org/polypheny/db/processing/VolcanoQueryProcessor.java index fc2aadc0ed..d60e998c74 100644 --- a/dbms/src/main/java/org/polypheny/db/processing/VolcanoQueryProcessor.java +++ b/dbms/src/main/java/org/polypheny/db/processing/VolcanoQueryProcessor.java @@ -63,14 +63,15 @@ import org.polypheny.db.plan.ConventionTraitDef; import org.polypheny.db.plan.volcano.VolcanoCost; import org.polypheny.db.plan.volcano.VolcanoPlanner; +import org.polypheny.db.plan.volcano.VolcanoPlannerPhase; import org.polypheny.db.rex.RexExecutorImpl; import org.polypheny.db.schema.trait.ModelTraitDef; import org.polypheny.db.transaction.Statement; +@Getter public class VolcanoQueryProcessor extends AbstractQueryProcessor { - @Getter private final VolcanoPlanner planner; @@ -118,15 +119,20 @@ public class VolcanoQueryProcessor extends AbstractQueryProcessor { EnumerableRules.ENUMERABLE_DOCUMENT_UNWIND_RULE, EnumerableRules.ENUMERABLE_GRAPH_TRANSFORMER_RULE ); - public static final List DEFAULT_RULES = + public static final List PRE_PROCESS_RULES = ImmutableList.of( - ScanRule.INSTANCE, AllocationToPhysicalScanRule.REL_INSTANCE, AllocationToPhysicalScanRule.DOC_INSTANCE, AllocationToPhysicalScanRule.GRAPH_INSTANCE, AllocationToPhysicalModifyRule.REL_INSTANCE, AllocationToPhysicalModifyRule.DOC_INSTANCE, AllocationToPhysicalModifyRule.GRAPH_INSTANCE, + ScanRule.INSTANCE + ); + + + public static final List DEFAULT_RULES = + ImmutableList.of( RuntimeConfig.JOIN_COMMUTE.getBoolean() ? JoinAssociateRule.INSTANCE : ProjectMergeRule.INSTANCE, @@ -170,11 +176,15 @@ public VolcanoQueryProcessor( Statement statement ) { planner.registerAbstractAlgebraRules(); } - AlgOptUtil.registerAbstractAlgs( planner ); + for ( AlgOptRule preProcessRule : PRE_PROCESS_RULES ) { + planner.addRule( preProcessRule, VolcanoPlannerPhase.PRE_PROCESS ); + } + for ( AlgOptRule rule : DEFAULT_RULES ) { planner.addRule( rule ); } + if ( ENABLE_BINDABLE ) { for ( AlgOptRule rule : Bindables.RULES ) { planner.addRule( rule ); diff --git a/plugins/hsqldb-adapter/src/main/java/org/polypheny/db/hsqldb/stores/HsqldbStore.java b/plugins/hsqldb-adapter/src/main/java/org/polypheny/db/hsqldb/stores/HsqldbStore.java index 3933b974b1..109cb0dc09 100644 --- a/plugins/hsqldb-adapter/src/main/java/org/polypheny/db/hsqldb/stores/HsqldbStore.java +++ b/plugins/hsqldb-adapter/src/main/java/org/polypheny/db/hsqldb/stores/HsqldbStore.java @@ -37,6 +37,7 @@ import org.polypheny.db.catalog.entity.logical.LogicalIndex; import org.polypheny.db.catalog.entity.logical.LogicalTable; import org.polypheny.db.catalog.entity.physical.PhysicalTable; +import org.polypheny.db.catalog.exceptions.GenericRuntimeException; import org.polypheny.db.config.RuntimeConfig; import org.polypheny.db.plugins.PolyPluginManager; import org.polypheny.db.prepare.Context; @@ -231,12 +232,12 @@ protected String getTypeString( PolyType type ) { case DOCUMENT: return "LONGVARCHAR"; } - throw new RuntimeException( "Unknown type: " + type.name() ); + throw new GenericRuntimeException( "Unknown type: " + type.name() ); } @Override - public String getDefaultPhysicalSchemaName() { + public String getDefaultPhysicalNamespaceName() { return "PUBLIC"; } diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcConvention.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcConvention.java index ae7a6990b4..1c9c649716 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcConvention.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/JdbcConvention.java @@ -87,7 +87,7 @@ public static JdbcConvention of( SqlDialect dialect, Expression expression, Stri @Override public void register( AlgOptPlanner planner ) { for ( AlgOptRule rule : JdbcRules.rules( this ) ) { - planner.addRuleDuringRuntime( rule ); + planner.addRule( rule ); } planner.addRule( FilterSetOpTransposeRule.INSTANCE ); //planner.addRule( ProjectRemoveRule.INSTANCE ); diff --git a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/stores/AbstractJdbcStore.java b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/stores/AbstractJdbcStore.java index 032c10540b..1ff125f6dd 100644 --- a/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/stores/AbstractJdbcStore.java +++ b/plugins/jdbc-adapter-framework/src/main/java/org/polypheny/db/adapter/jdbc/stores/AbstractJdbcStore.java @@ -123,7 +123,10 @@ protected void registerJdbcInformation() { @Override public void updateNamespace( String name, long id ) { - currentJdbcSchema = JdbcSchema.create( id, storeCatalog, name, connectionFactory, dialect, this ); + if ( storeCatalog.getNamespace( id ) == null ) { + currentJdbcSchema = JdbcSchema.create( id, storeCatalog, getDefaultPhysicalNamespaceName(), connectionFactory, dialect, this ); + storeCatalog.addNamespace( id, currentJdbcSchema ); + } putNamespace( currentJdbcSchema ); } @@ -145,13 +148,10 @@ public Namespace getCurrentNamespace() { @Override public List createTable( Context context, LogicalTableWrapper logical, AllocationTableWrapper allocationWrapper ) { AllocationTable allocation = allocationWrapper.table; - String namespaceName = getDefaultPhysicalSchemaName(); + String namespaceName = getDefaultPhysicalNamespaceName(); String tableName = getPhysicalTableName( allocation.id, 0 ); - if ( storeCatalog.getNamespace( allocation.namespaceId ) == null ) { - updateNamespace( namespaceName, allocation.namespaceId ); - storeCatalog.addNamespace( allocation.namespaceId, currentJdbcSchema ); - } + updateNamespace( logical.table.getNamespaceName(), logical.table.namespaceId ); PhysicalTable table = storeCatalog.createTable( namespaceName, @@ -484,7 +484,7 @@ public void restoreTable( AllocationTable alloc, List entities ) } - public abstract String getDefaultPhysicalSchemaName(); + public abstract String getDefaultPhysicalNamespaceName(); @SuppressWarnings("unused") diff --git a/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/stores/MonetdbStore.java b/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/stores/MonetdbStore.java index 89904fd485..387d0049a1 100644 --- a/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/stores/MonetdbStore.java +++ b/plugins/monetdb-adapter/src/main/java/org/polypheny/db/adapter/monetdb/stores/MonetdbStore.java @@ -340,8 +340,8 @@ protected String getTypeString( PolyType type ) { @Override - public String getDefaultPhysicalSchemaName() { - return "public"; + public String getDefaultPhysicalNamespaceName() { + return "public" + getAdapterId(); } diff --git a/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java b/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java index 130ebdeae2..8e95fbb1a4 100644 --- a/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java +++ b/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java @@ -398,7 +398,7 @@ public boolean doesTypeUseLength( PolyType type ) { @Override - public String getDefaultPhysicalSchemaName() { + public String getDefaultPhysicalNamespaceName() { return "public"; } diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/RexProgramTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/RexProgramTest.java index 8488f019a1..688c4322e4 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/RexProgramTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/RexProgramTest.java @@ -332,7 +332,7 @@ private RexProgramBuilder createProg( int variant ) { typeFactory.createPolyType( PolyType.INTEGER ), typeFactory.createPolyType( PolyType.INTEGER ) ); List names = Arrays.asList( "x", "y" ); - AlgDataType inputRowType = typeFactory.createStructType( , types, names ); + AlgDataType inputRowType = typeFactory.createStructType( null, types, names ); final RexProgramBuilder builder = new RexProgramBuilder( inputRowType, rexBuilder ); // $t0 = x // $t1 = y diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/FunctionsTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/FunctionsTest.java index 6cc1bd83e1..07453fb3aa 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/FunctionsTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/FunctionsTest.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.polypheny.db.functions.Functions.charLength; +import static org.polypheny.db.functions.Functions.concat; import static org.polypheny.db.functions.Functions.greater; import static org.polypheny.db.functions.Functions.initcap; import static org.polypheny.db.functions.Functions.lesser; @@ -73,29 +74,29 @@ public void before() { @Test public void testCharLength() { - assertEquals( 3, charLength( "xyz" ) ); + assertEquals( 3, charLength( PolyString.of( "xyz" ) ) ); } @Test public void testConcat() { - assertEquals( "a bcd", concat( "a b", "cd" ) ); + assertEquals( PolyString.of( "a bcd" ), concat( PolyString.of( "a b" ), PolyString.of( "cd" ) ) ); // The code generator will ensure that nulls are never passed in. If we pass in null, it is treated like the string "null", as the following tests show. Not the desired behavior for SQL. - assertEquals( "anull", concat( "a", null ) ); - assertEquals( "nullnull", concat( (String) null, null ) ); - assertEquals( "nullb", concat( null, "b" ) ); + // assertEquals( "anull", concat( PolyString.of( "a" ), null ) ); why should we test something we don't want to occur + // assertEquals( "nullnull", concat( (PolyString) null, null ) ); + // assertEquals( "nullb", concat( null, PolyString.of( "b" ) ) ); } @Test public void testLower() { - assertEquals( "a bcd iijk", lower( "A bCd Iijk" ) ); + assertEquals( PolyString.of( "a bcd iijk" ), lower( PolyString.of( "A bCd Iijk" ) ) ); } @Test public void testUpper() { - assertEquals( "A BCD IIJK", upper( "A bCd iIjk" ) ); + assertEquals( PolyString.of( "A BCD IIJK" ), upper( PolyString.of( "A bCd iIjk" ) ) ); } @@ -350,112 +351,113 @@ public void testSTruncateDouble() { @Test public void testSTruncateLong() { - assertEquals( 12000d, Functions.struncate( 12345L, -3 ), 0.001 ); - assertEquals( 12000d, Functions.struncate( 12000L, -3 ), 0.001 ); - assertEquals( 12000d, Functions.struncate( 12001L, -3 ), 0.001 ); - assertEquals( 10000d, Functions.struncate( 12000L, -4 ), 0.001 ); - assertEquals( 0d, Functions.struncate( 12000L, -5 ), 0.001 ); - assertEquals( 11000d, Functions.struncate( 11999L, -3 ), 0.001 ); + assertEquals( 12000d, Functions.struncate( PolyLong.of( 12345L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.struncate( PolyLong.of( 12000L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.struncate( PolyLong.of( 12001L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 10000d, Functions.struncate( PolyLong.of( 12000L ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.struncate( PolyLong.of( 12000L ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); + assertEquals( 11000d, Functions.struncate( PolyLong.of( 11999L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); - assertEquals( -12000d, Functions.struncate( -12345L, -3 ), 0.001 ); - assertEquals( -12000d, Functions.struncate( -12000L, -3 ), 0.001 ); - assertEquals( -11000d, Functions.struncate( -11999L, -3 ), 0.001 ); - assertEquals( -10000d, Functions.struncate( -12000L, -4 ), 0.001 ); - assertEquals( 0d, Functions.struncate( -12000L, -5 ), 0.001 ); + assertEquals( -12000d, Functions.struncate( PolyLong.of( -12345L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.struncate( PolyLong.of( -12000L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -11000d, Functions.struncate( PolyLong.of( -11999L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -10000d, Functions.struncate( PolyLong.of( -12000L ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.struncate( PolyLong.of( -12000L ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); } @Test public void testSTruncateInt() { - assertEquals( 12000d, Functions.struncate( 12345, -3 ), 0.001 ); - assertEquals( 12000d, Functions.struncate( 12000, -3 ), 0.001 ); - assertEquals( 12000d, Functions.struncate( 12001, -3 ), 0.001 ); - assertEquals( 10000d, Functions.struncate( 12000, -4 ), 0.001 ); - assertEquals( 0d, Functions.struncate( 12000, -5 ), 0.001 ); - assertEquals( 11000d, Functions.struncate( 11999, -3 ), 0.001 ); + assertEquals( 12000d, Functions.struncate( PolyInteger.of( 12345 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.struncate( PolyInteger.of( 12000 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.struncate( PolyInteger.of( 12001 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 10000d, Functions.struncate( PolyInteger.of( 12000 ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.struncate( PolyInteger.of( 12000 ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); + assertEquals( 11000d, Functions.struncate( PolyInteger.of( 11999 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); - assertEquals( -12000d, Functions.struncate( -12345, -3 ), 0.001 ); - assertEquals( -12000d, Functions.struncate( -12000, -3 ), 0.001 ); - assertEquals( -11000d, Functions.struncate( -11999, -3 ), 0.001 ); - assertEquals( -10000d, Functions.struncate( -12000, -4 ), 0.001 ); - assertEquals( 0d, Functions.struncate( -12000, -5 ), 0.001 ); + assertEquals( -12000d, Functions.struncate( PolyInteger.of( -12345 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.struncate( PolyInteger.of( -12000 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -11000d, Functions.struncate( PolyInteger.of( -11999 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -10000d, Functions.struncate( PolyInteger.of( -12000 ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( -10000d, Functions.struncate( PolyInteger.of( -12000 ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.struncate( PolyInteger.of( -12000 ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); } @Test public void testSRoundDouble() { - assertEquals( 12.345d, Functions.sround( 12.345d, 3 ), 0.001 ); - assertEquals( 12.350d, Functions.sround( 12.345d, 2 ), 0.001 ); - assertEquals( 12.300d, Functions.sround( 12.345d, 1 ), 0.001 ); - assertEquals( 13.000d, Functions.sround( 12.999d, 2 ), 0.001 ); - assertEquals( 13.000d, Functions.sround( 12.999d, 1 ), 0.001 ); - assertEquals( 13.000d, Functions.sround( 12.999d, 0 ), 0.001 ); - - assertEquals( -12.345d, Functions.sround( -12.345d, 3 ), 0.001 ); - assertEquals( -12.350d, Functions.sround( -12.345d, 2 ), 0.001 ); - assertEquals( -12.300d, Functions.sround( -12.345d, 1 ), 0.001 ); - assertEquals( -13.000d, Functions.sround( -12.999d, 2 ), 0.001 ); - assertEquals( -13.000d, Functions.sround( -12.999d, 1 ), 0.001 ); - assertEquals( -13.000d, Functions.sround( -12.999d, 0 ), 0.001 ); - - assertEquals( 12350d, Functions.sround( 12345d, -1 ), 0.001 ); - assertEquals( 12300d, Functions.sround( 12345d, -2 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 12345d, -3 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 12000d, -3 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 12001d, -3 ), 0.001 ); - assertEquals( 10000d, Functions.sround( 12000d, -4 ), 0.001 ); - assertEquals( 0d, Functions.sround( 12000d, -5 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 11999d, -3 ), 0.001 ); - - assertEquals( -12350d, Functions.sround( -12345d, -1 ), 0.001 ); - assertEquals( -12300d, Functions.sround( -12345d, -2 ), 0.001 ); - assertEquals( -12000d, Functions.sround( -12345d, -3 ), 0.001 ); - assertEquals( -12000d, Functions.sround( -12000d, -3 ), 0.001 ); - assertEquals( -12000d, Functions.sround( -11999d, -3 ), 0.001 ); - assertEquals( -10000d, Functions.sround( -12000d, -4 ), 0.001 ); - assertEquals( 0d, Functions.sround( -12000d, -5 ), 0.001 ); + assertEquals( 12.345d, Functions.sround( PolyDouble.of( 12.345d ), PolyInteger.of( 3 ) ).doubleValue(), 0.001 ); + assertEquals( 12.350d, Functions.sround( PolyDouble.of( 12.345d ), PolyInteger.of( 2 ) ).doubleValue(), 0.001 ); + assertEquals( 12.300d, Functions.sround( PolyDouble.of( 12.345d ), PolyInteger.of( 1 ) ).doubleValue(), 0.001 ); + assertEquals( 13.000d, Functions.sround( PolyDouble.of( 12.999d ), PolyInteger.of( 2 ) ).doubleValue(), 0.001 ); + assertEquals( 13.000d, Functions.sround( PolyDouble.of( 12.999d ), PolyInteger.of( 1 ) ).doubleValue(), 0.001 ); + assertEquals( 13.000d, Functions.sround( PolyDouble.of( 12.999d ), PolyInteger.of( 0 ) ).doubleValue(), 0.001 ); + + assertEquals( -12.345d, Functions.sround( PolyDouble.of( -12.345d ), PolyInteger.of( 3 ) ).doubleValue(), 0.001 ); + assertEquals( -12.350d, Functions.sround( PolyDouble.of( -12.345d ), PolyInteger.of( 2 ) ).doubleValue(), 0.001 ); + assertEquals( -12.300d, Functions.sround( PolyDouble.of( -12.345d ), PolyInteger.of( 1 ) ).doubleValue(), 0.001 ); + assertEquals( -13.000d, Functions.sround( PolyDouble.of( -12.999d ), PolyInteger.of( 2 ) ).doubleValue(), 0.001 ); + assertEquals( -13.000d, Functions.sround( PolyDouble.of( -12.999d ), PolyInteger.of( 1 ) ).doubleValue(), 0.001 ); + assertEquals( -13.000d, Functions.sround( PolyDouble.of( -12.999d ), PolyInteger.of( 0 ) ).doubleValue(), 0.001 ); + + assertEquals( 12350d, Functions.sround( PolyDouble.of( 12345d ), PolyInteger.of( -1 ) ).doubleValue(), 0.001 ); + assertEquals( 12300d, Functions.sround( PolyDouble.of( 12345d ), PolyInteger.of( -2 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyDouble.of( 12345d ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyDouble.of( 12000d ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyDouble.of( 12001d ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 10000d, Functions.sround( PolyDouble.of( 12000d ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.sround( PolyDouble.of( 12000d ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyDouble.of( 11999d ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + + assertEquals( -12350d, Functions.sround( PolyDouble.of( -12345d ), PolyInteger.of( -1 ) ).doubleValue(), 0.001 ); + assertEquals( -12300d, Functions.sround( PolyDouble.of( -12345d ), PolyInteger.of( -2 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.sround( PolyDouble.of( -12345d ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.sround( PolyDouble.of( -12000d ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.sround( PolyDouble.of( -11999d ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -10000d, Functions.sround( PolyDouble.of( -12000d ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.sround( PolyDouble.of( -12000d ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); } @Test public void testSRoundLong() { - assertEquals( 12350d, Functions.sround( 12345L, -1 ), 0.001 ); - assertEquals( 12300d, Functions.sround( 12345L, -2 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 12345L, -3 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 12000L, -3 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 12001L, -3 ), 0.001 ); - assertEquals( 10000d, Functions.sround( 12000L, -4 ), 0.001 ); - assertEquals( 0d, Functions.sround( 12000L, -5 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 11999L, -3 ), 0.001 ); + assertEquals( 12350d, Functions.sround( PolyLong.of( 12345L ), PolyInteger.of( -1 ) ).doubleValue(), 0.001 ); + assertEquals( 12300d, Functions.sround( PolyLong.of( 12345L ), PolyInteger.of( -2 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyLong.of( 12345L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyLong.of( 12000L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyLong.of( 12001L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 10000d, Functions.sround( PolyLong.of( 12000L ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.sround( PolyLong.of( 12000L ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyLong.of( 11999L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); - assertEquals( -12350d, Functions.sround( -12345L, -1 ), 0.001 ); - assertEquals( -12300d, Functions.sround( -12345L, -2 ), 0.001 ); - assertEquals( -12000d, Functions.sround( -12345L, -3 ), 0.001 ); - assertEquals( -12000d, Functions.sround( -12000L, -3 ), 0.001 ); - assertEquals( -12000d, Functions.sround( -11999L, -3 ), 0.001 ); - assertEquals( -10000d, Functions.sround( -12000L, -4 ), 0.001 ); - assertEquals( 0d, Functions.sround( -12000L, -5 ), 0.001 ); + assertEquals( -12350d, Functions.sround( PolyLong.of( -12345L ), PolyInteger.of( -1 ) ).doubleValue(), 0.001 ); + assertEquals( -12300d, Functions.sround( PolyLong.of( -12345L ), PolyInteger.of( -2 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.sround( PolyLong.of( -12345L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.sround( PolyLong.of( -12000L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.sround( PolyLong.of( -11999L ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -10000d, Functions.sround( PolyLong.of( -12000L ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.sround( PolyLong.of( -12000L ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); } @Test public void testSRoundInt() { - assertEquals( 12350d, Functions.sround( 12345, -1 ), 0.001 ); - assertEquals( 12300d, Functions.sround( 12345, -2 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 12345, -3 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 12000, -3 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 12001, -3 ), 0.001 ); - assertEquals( 10000d, Functions.sround( 12000, -4 ), 0.001 ); - assertEquals( 0d, Functions.sround( 12000, -5 ), 0.001 ); - assertEquals( 12000d, Functions.sround( 11999, -3 ), 0.001 ); - - assertEquals( -12350d, Functions.sround( -12345, -1 ), 0.001 ); - assertEquals( -12300d, Functions.sround( -12345, -2 ), 0.001 ); - assertEquals( -12000d, Functions.sround( -12345, -3 ), 0.001 ); - assertEquals( -12000d, Functions.sround( -12000, -3 ), 0.001 ); - assertEquals( -12000d, Functions.sround( -11999, -3 ), 0.001 ); - assertEquals( -10000d, Functions.sround( -12000, -4 ), 0.001 ); - assertEquals( 0d, Functions.sround( -12000, -5 ), 0.001 ); + assertEquals( 12350d, Functions.sround( PolyInteger.of( 12345 ), PolyInteger.of( -1 ) ).doubleValue(), 0.001 ); + assertEquals( 12300d, Functions.sround( PolyInteger.of( 12345 ), PolyInteger.of( -2 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyInteger.of( 12345 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyInteger.of( 12000 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyInteger.of( 12001 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( 10000d, Functions.sround( PolyInteger.of( 12000 ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.sround( PolyInteger.of( 12000 ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); + assertEquals( 12000d, Functions.sround( PolyInteger.of( 11999 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + + assertEquals( -12350d, Functions.sround( PolyInteger.of( -12345 ), PolyInteger.of( -1 ) ).doubleValue(), 0.001 ); + assertEquals( -12300d, Functions.sround( PolyInteger.of( -12345 ), PolyInteger.of( -2 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.sround( PolyInteger.of( -12345 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.sround( PolyInteger.of( -12000 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -12000d, Functions.sround( PolyInteger.of( -11999 ), PolyInteger.of( -3 ) ).doubleValue(), 0.001 ); + assertEquals( -10000d, Functions.sround( PolyInteger.of( -12000 ), PolyInteger.of( -4 ) ).doubleValue(), 0.001 ); + assertEquals( 0d, Functions.sround( PolyInteger.of( -12000 ), PolyInteger.of( -5 ) ).doubleValue(), 0.001 ); } diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/test/SqlOperatorBaseTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/test/SqlOperatorBaseTest.java index 05f388c58e..e9315d5c55 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/test/SqlOperatorBaseTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/language/test/SqlOperatorBaseTest.java @@ -80,6 +80,7 @@ import org.polypheny.db.type.OperandCountRange; import org.polypheny.db.type.PolyType; import org.polypheny.db.type.checker.PolyOperandTypeChecker; +import org.polypheny.db.type.entity.PolyTimeStamp; import org.polypheny.db.util.Bug; import org.polypheny.db.util.Holder; import org.polypheny.db.util.Pair; @@ -8023,7 +8024,7 @@ private SqlNode literal( AlgDataType type, Object value ) { return SqlLiteral.createCharString( value.toString(), ParserPos.ZERO ); case TIMESTAMP: TimestampString ts = TimestampString.fromMillisSinceEpoch( (Long) value ); - return SqlLiteral.createTimestamp( ts, type.getPrecision(), ParserPos.ZERO ); + return SqlLiteral.createTimestamp( PolyTimeStamp.of( ts.getMillisSinceEpoch() ), type.getPrecision(), ParserPos.ZERO ); default: throw new AssertionError( type ); } diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/TraitPropagationTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/TraitPropagationTest.java index f3bdf862dc..fbf47b0d06 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/TraitPropagationTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/TraitPropagationTest.java @@ -37,6 +37,7 @@ import static org.junit.Assert.assertEquals; import static org.polypheny.db.sql.volcano.TraitPropagationTest.PropAction.run; +import com.google.common.collect.ImmutableList; import java.sql.Connection; import java.sql.DriverManager; import java.util.List; @@ -385,12 +386,12 @@ public AlgOptCost computeSelfCost( AlgOptPlanner planner, AlgMetadataQuery mq ) private static class PhysSort extends Sort implements Phys { PhysSort( AlgOptCluster cluster, AlgTraitSet traits, AlgNode child, AlgCollation collation, RexNode offset, RexNode fetch ) { - super( cluster, traits, child, collation, offset, fetch ); + super( cluster, traits, child, collation, List.of(), offset, fetch ); } @Override - public PhysSort copy( AlgTraitSet traitSet, AlgNode newInput, AlgCollation newCollation, RexNode offset, RexNode fetch ) { + public Sort copy( AlgTraitSet traitSet, AlgNode newInput, AlgCollation newCollation, ImmutableList fieldExps, RexNode offset, RexNode fetch ) { return new PhysSort( getCluster(), traitSet, newInput, newCollation, offset, fetch ); } diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/VolcanoPlannerTraitTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/VolcanoPlannerTraitTest.java index 2a2dedd470..96141f2ee9 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/VolcanoPlannerTraitTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/volcano/VolcanoPlannerTraitTest.java @@ -279,14 +279,14 @@ public String toString() { /** * Definition of {@link AltTrait}. */ - private static class AltTraitDef extends AlgTraitDef { + private static class AltTraitDef extends AlgTraitDef> { - private Multimap> conversionMap = HashMultimap.create(); + private Multimap, Pair, ConverterRule>> conversionMap = HashMultimap.create(); @Override - public Class getTraitClass() { - return AltTrait.class; + public Class> getTraitClass() { + return (Class>) AltTrait.class; } @@ -297,19 +297,19 @@ public String getSimpleName() { @Override - public AltTrait getDefault() { + public AltTrait getDefault() { return ALT_TRAIT; } @Override public AlgNode convert( AlgOptPlanner planner, AlgNode alg, AltTrait toTrait, boolean allowInfiniteCostConverters ) { - AlgTrait fromTrait = alg.getTraitSet().getTrait( this ); + AlgTrait fromTrait = alg.getTraitSet().getTrait( this ); if ( conversionMap.containsKey( fromTrait ) ) { final AlgMetadataQuery mq = AlgMetadataQuery.instance(); - for ( Pair traitAndRule : conversionMap.get( fromTrait ) ) { - AlgTrait trait = traitAndRule.left; + for ( Pair, ConverterRule> traitAndRule : conversionMap.get( fromTrait ) ) { + AlgTrait trait = traitAndRule.left; ConverterRule rule = traitAndRule.right; if ( trait == toTrait ) {