Package org.apache.calcite.test
Class RelMetadataFixture
java.lang.Object
org.apache.calcite.test.RelMetadataFixture
Parameters for a Metadata test.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A configuration that describes how metadata should be configured. -
Field Summary
Modifier and TypeFieldDescriptionfinal boolean
static final RelMetadataFixture
Default fixture.final SqlTestFactory
final org.apache.calcite.test.RelSupplier
final UnaryOperator<RelNode>
final SqlTester
-
Method Summary
Modifier and TypeMethodDescriptionassertColumnOriginDouble
(String expectedTableName1, String expectedColumnName1, String expectedTableName2, String expectedColumnName2, boolean expectedDerived) Checks thatRelMetadataQuery.getColumnOrigins(RelNode, int)
for column 0 returns two origins.Checks thatRelMetadataQuery.getColumnOrigins(RelNode, int)
for column 0 returns no origins.assertColumnOriginSingle
(String expectedTableName, String expectedColumnName, boolean expectedDerived) Checks thatRelMetadataQuery.getColumnOrigins(RelNode, int)
for column 0 returns one origin.assertCpuCost
(org.hamcrest.Matcher<Double> matcher, String reason) Checks the CPU component ofRelNode.computeSelfCost(RelOptPlanner, RelMetadataQuery)
.assertPercentageOriginalRows
(org.hamcrest.Matcher<Double> matcher) assertRowsUnique
(boolean ignoreNulls, org.hamcrest.Matcher<Boolean> matcher, String reason) assertRowsUnique
(org.hamcrest.Matcher<Boolean> matcher, String reason) ChecksRelMetadataQuery.areRowsUnique(RelNode)
for all values ofignoreNulls
.assertThatAreColumnsUnique
(Function<RelNode, ImmutableBitSet> columnsFn, UnaryOperator<RelNode> relFn, org.hamcrest.Matcher<Boolean> matcher) ChecksRelMetadataQuery.areColumnsUnique(RelNode, ImmutableBitSet)
, deriving parameters via functions.assertThatAreColumnsUnique
(ImmutableBitSet columns, org.hamcrest.Matcher<Boolean> matcher) assertThatAreRowsUnique
(org.hamcrest.Matcher<Boolean> matcher) assertThatDistinctRowCount
(Function<RelNode, ImmutableBitSet> groupKeyFn, org.hamcrest.Matcher<Double> matcher) ChecksRelMetadataQuery.getDistinctRowCount(RelNode, ImmutableBitSet, RexNode)
with a null predicate, deriving the group key from theRelNode
.assertThatDistinctRowCount
(ImmutableBitSet groupKey, org.hamcrest.Matcher<Double> matcher) ChecksRelMetadataQuery.getDistinctRowCount(RelNode, ImmutableBitSet, RexNode)
with a null predicate.assertThatNodeTypeCount
(org.hamcrest.Matcher<Map<Class<? extends RelNode>, Integer>> matcher) Checks the number of each sub-class ofRelNode
, callingRelMetadataQuery.getNodeTypes(RelNode)
.assertThatNodeTypeCountIs
(Class<? extends RelNode> k0, Integer v0, Object... rest) Shorthand for a call toassertThatNodeTypeCount(Matcher)
with a constant map.assertThatRel
(org.hamcrest.Matcher<RelNode> matcher) assertThatRowCount
(org.hamcrest.Matcher<Number> rowCountMatcher, org.hamcrest.Matcher<Number> minRowCountMatcher, org.hamcrest.Matcher<Number> maxRowCountMatcher) assertThatSelectivity
(org.hamcrest.Matcher<Double> matcher) assertThatUniqueKeys
(org.hamcrest.Matcher<Iterable<ImmutableBitSet>> matcher) assertThatUniqueKeysAre
(ImmutableBitSet... expectedUniqueKeys) Checks result of getting unique keys for SQL.toRel()
withCatalogReaderFactory
(SqlTestFactory.CatalogReaderFactory catalogReaderFactory) withCluster
(UnaryOperator<RelOptCluster> factory) withFactory
(UnaryOperator<SqlTestFactory> transform) withMetadataConfig
(RelMetadataFixture.MetadataConfig metadataConfig) withRelFn
(Function<RelBuilder, RelNode> relFn) Creates a copy of this fixture that uses a given function to create aRelNode
.withRelTransform
(UnaryOperator<RelNode> relTransform) Creates a copy of this fixture that uses a given SQL query.withTester
(UnaryOperator<SqlTester> transform)
-
Field Details
-
DEFAULT
Default fixture.Use this, or call the
withXxx
methods to make one with the properties you need. Fixtures are immutable, so whatever your test does to this fixture, it won't break other tests. -
tester
-
factory
-
metadataConfig
-
relSupplier
public final org.apache.calcite.test.RelSupplier relSupplier -
convertAsCalc
public final boolean convertAsCalc -
relTransform
-
-
Method Details
-
withSql
Creates a copy of this fixture that uses a given SQL query. -
withRelFn
Creates a copy of this fixture that uses a given function to create aRelNode
. -
withFactory
-
withTester
-
withMetadataConfig
-
convertingProjectAsCalc
-
withCatalogReaderFactory
public RelMetadataFixture withCatalogReaderFactory(SqlTestFactory.CatalogReaderFactory catalogReaderFactory) -
withCluster
-
withRelTransform
-
toRel
-
assertCpuCost
Checks the CPU component ofRelNode.computeSelfCost(RelOptPlanner, RelMetadataQuery)
. -
assertRowsUnique
ChecksRelMetadataQuery.areRowsUnique(RelNode)
for all values ofignoreNulls
. -
assertRowsUnique
public RelMetadataFixture assertRowsUnique(boolean ignoreNulls, org.hamcrest.Matcher<Boolean> matcher, String reason) -
assertPercentageOriginalRows
-
assertColumnOriginIsEmpty
Checks thatRelMetadataQuery.getColumnOrigins(RelNode, int)
for column 0 returns no origins. -
assertColumnOriginSingle
public RelMetadataFixture assertColumnOriginSingle(String expectedTableName, String expectedColumnName, boolean expectedDerived) Checks thatRelMetadataQuery.getColumnOrigins(RelNode, int)
for column 0 returns one origin. -
assertColumnOriginDouble
public RelMetadataFixture assertColumnOriginDouble(String expectedTableName1, String expectedColumnName1, String expectedTableName2, String expectedColumnName2, boolean expectedDerived) Checks thatRelMetadataQuery.getColumnOrigins(RelNode, int)
for column 0 returns two origins. -
assertThatUniqueKeysAre
Checks result of getting unique keys for SQL. -
assertThatRowCount
public RelMetadataFixture assertThatRowCount(org.hamcrest.Matcher<Number> rowCountMatcher, org.hamcrest.Matcher<Number> minRowCountMatcher, org.hamcrest.Matcher<Number> maxRowCountMatcher) -
assertThatSelectivity
-
assertThatDistinctRowCount
public RelMetadataFixture assertThatDistinctRowCount(ImmutableBitSet groupKey, org.hamcrest.Matcher<Double> matcher) ChecksRelMetadataQuery.getDistinctRowCount(RelNode, ImmutableBitSet, RexNode)
with a null predicate. -
assertThatDistinctRowCount
public RelMetadataFixture assertThatDistinctRowCount(Function<RelNode, ImmutableBitSet> groupKeyFn, org.hamcrest.Matcher<Double> matcher) ChecksRelMetadataQuery.getDistinctRowCount(RelNode, ImmutableBitSet, RexNode)
with a null predicate, deriving the group key from theRelNode
. -
assertThatRel
-
assertThatNodeTypeCountIs
public RelMetadataFixture assertThatNodeTypeCountIs(Class<? extends RelNode> k0, Integer v0, Object... rest) Shorthand for a call toassertThatNodeTypeCount(Matcher)
with a constant map. -
assertThatNodeTypeCount
public RelMetadataFixture assertThatNodeTypeCount(org.hamcrest.Matcher<Map<Class<? extends RelNode>, Integer>> matcher) Checks the number of each sub-class ofRelNode
, callingRelMetadataQuery.getNodeTypes(RelNode)
. -
assertThatUniqueKeys
public RelMetadataFixture assertThatUniqueKeys(org.hamcrest.Matcher<Iterable<ImmutableBitSet>> matcher) -
assertThatAreColumnsUnique
public RelMetadataFixture assertThatAreColumnsUnique(ImmutableBitSet columns, org.hamcrest.Matcher<Boolean> matcher) -
assertThatAreColumnsUnique
public RelMetadataFixture assertThatAreColumnsUnique(Function<RelNode, ImmutableBitSet> columnsFn, UnaryOperator<RelNode> relFn, org.hamcrest.Matcher<Boolean> matcher) ChecksRelMetadataQuery.areColumnsUnique(RelNode, ImmutableBitSet)
, deriving parameters via functions. -
assertThatAreRowsUnique
-