This is an automated email from the ASF dual-hosted git repository. jhyde pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/calcite.git
commit 68eacfc57da7492377797e39ee3e2778be1b1aa4 Author: Julian Hyde <jh...@apache.org> AuthorDate: Tue Nov 12 10:50:51 2019 -0800 Javadoc warning Also cosmetic changes --- .../java/org/apache/calcite/runtime/Resources.java | 4 +- .../calcite/sql/test/SqlOperatorBaseTest.java | 9 ++- .../org/apache/calcite/test/RexProgramTest.java | 11 ++- .../apache/calcite/test/SqlToRelConverterTest.java | 26 +++---- .../test/enumerable/EnumerableCalcTest.java | 3 +- .../calcite/test/fuzzer/RexProgramFuzzyTest.java | 11 ++- .../adapter/elasticsearch/PredicateAnalyzer.java | 1 + .../calcite/adapter/elasticsearch/MatchTest.java | 80 ++++++++++++---------- .../org/apache/calcite/adapter/tpch/TpchTest.java | 5 +- 9 files changed, 73 insertions(+), 77 deletions(-) diff --git a/core/src/main/java/org/apache/calcite/runtime/Resources.java b/core/src/main/java/org/apache/calcite/runtime/Resources.java index 8ec97ee..371b65e 100644 --- a/core/src/main/java/org/apache/calcite/runtime/Resources.java +++ b/core/src/main/java/org/apache/calcite/runtime/Resources.java @@ -99,7 +99,7 @@ public class Resources { * ExInst<IllegalArgumentException> illegalBinaryString(String a0); * </blockquote> * - * will look up a resource "IllegalBinaryString" from the resource file + * <p>will look up a resource "IllegalBinaryString" from the resource file * "com/example/MyResource_en_US.properties", and substitute in the parameter * value {@code a0}. * @@ -859,7 +859,7 @@ public class Resources { * * </blockquote> * - * Then when you call + * <p>Then when you call * {@link ResourceBundle#getBundle ResourceBundle.getBundle("foo.MyResource")}, * it will find the class before the properties file, but still automatically * load the properties file based upon the name of the class. diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java index edb5f3e..6559238 100644 --- a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java +++ b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java @@ -8928,14 +8928,13 @@ public abstract class SqlOperatorBaseTest { /** Test that calls all operators with all possible argument types, and for * each type, with a set of tricky values. * - * This is not really a unit test since there are no assertions; + * <p>This is not really a unit test since there are no assertions; * it either succeeds or fails in the preparation of the operator case * and not when actually testing (validating/executing) the call. * - * Nevertheless the log messages conceal many problems which potentially need - * to be fixed especially cases where the query passes from the validation stage - * and fails at runtime. - * */ + * <p>Nevertheless the log messages conceal many problems which potentially + * need to be fixed especially cases where the query passes from the + * validation stage and fails at runtime. */ @Disabled("Too slow and not really a unit test") @Tag("slow") @Test public void testArgumentBounds() { diff --git a/core/src/test/java/org/apache/calcite/test/RexProgramTest.java b/core/src/test/java/org/apache/calcite/test/RexProgramTest.java index 403067d..816cab6 100644 --- a/core/src/test/java/org/apache/calcite/test/RexProgramTest.java +++ b/core/src/test/java/org/apache/calcite/test/RexProgramTest.java @@ -763,16 +763,13 @@ public class RexProgramTest extends RexProgramBuilderBase { checkSimplifyUnchanged(cast(cast(vVarchar(), tInt()), tVarchar())); } - @Disabled("CALCITE-3457: AssertionError in RexSimplify.validateStrongPolicy:843") + @Disabled("CALCITE-3457: AssertionError in RexSimplify.validateStrongPolicy") @Test public void reproducerFor3457() { // Identified with RexProgramFuzzyTest#testFuzzy, seed=4887662474363391810L checkSimplify( - eq( - unaryMinus(abstractCast(literal(1), tInt(true))), - unaryMinus(abstractCast(literal(1), tInt(true))) - ), - "I've no idea what I'm doing 🐕" - ); + eq(unaryMinus(abstractCast(literal(1), tInt(true))), + unaryMinus(abstractCast(literal(1), tInt(true)))), + "true"); } @Test public void testNoCommonReturnTypeFails() { diff --git a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java index dcb80e9..c328085 100644 --- a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java +++ b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java @@ -133,9 +133,9 @@ public class SqlToRelConverterTest extends SqlToRelTestBase { sql(sql).ok(); } - /** Test case for: + /** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-2468">[CALCITE-2468] - * struct type alias should not cause IOOBE.</a>. + * struct type alias should not cause IndexOutOfBoundsException</a>. */ @Test public void testStructTypeAlias() { final String sql = "select t.r AS myRow\n" @@ -167,11 +167,9 @@ public class SqlToRelConverterTest extends SqlToRelTestBase { sql(sql).ok(); } - /** - * Test case for + /** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-245">[CALCITE-245] - * Off-by-one translation of ON clause of JOIN</a>. - */ + * Off-by-one translation of ON clause of JOIN</a>. */ @Test public void testConditionOffByOne() { // Bug causes the plan to contain // LogicalJoin(condition=[=($9, $9)], joinType=[inner]) @@ -237,8 +235,7 @@ public class SqlToRelConverterTest extends SqlToRelTestBase { /** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-801">[CALCITE-801] - * NullPointerException using USING on table alias with column - * aliases</a>. */ + * NullPointerException using USING on table alias with column aliases</a>. */ @Test public void testValuesUsing() { final String sql = "select d.deptno, min(e.empid) as empid\n" + "from (values (100, 'Bill', 1)) as e(empid, name, deptno)\n" @@ -847,8 +844,7 @@ public class SqlToRelConverterTest extends SqlToRelTestBase { /** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-439">[CALCITE-439] - * SqlValidatorUtil.uniquify() may not terminate under some - * conditions</a>. */ + * SqlValidatorUtil.uniquify() may not terminate under some conditions</a>. */ @Test public void testGroupAlias() { final String sql = "select \"$f2\", max(x), max(x + 1)\n" + "from (values (1, 2)) as t(\"$f2\", x)\n" @@ -1992,7 +1988,7 @@ public class SqlToRelConverterTest extends SqlToRelTestBase { /** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-3183">[CALCITE-3183] - * Trimming method for Filter rel uses wrong traitSet </a> */ + * Trimming method for Filter rel uses wrong traitSet</a>. */ @Test public void testFilterAndSortWithTrim() { // Create a customized test with RelCollation trait in the test cluster. Tester tester = new TesterImpl(getDiffRepos(), @@ -2103,8 +2099,7 @@ public class SqlToRelConverterTest extends SqlToRelTestBase { * * <p>Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-551">[CALCITE-551] - * Sub-query inside aggregate function</a>. - */ + * Sub-query inside aggregate function</a>. */ @Test public void testAggCaseInSubQuery() { final String sql = "SELECT SUM(\n" + " CASE WHEN deptno IN (SELECT deptno FROM dept) THEN 1 ELSE 0 END)\n" @@ -3625,9 +3620,10 @@ public class SqlToRelConverterTest extends SqlToRelTestBase { sql(sql).ok(); } - /** Test case for: + /** Test case for * <a href="https://issues.apache.org/jira/browse/CALCITE-3456">[CALCITE-3456] - * AssertionError throws when aggregation same digest in subquery in same scope</a>. + * AssertionError throws when aggregation same digest in sub-query in same + * scope</a>. */ @Test public void testAggregateWithSameDigestInSubQueries() { final String sql = "select\n" diff --git a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCalcTest.java b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCalcTest.java index 1cf0cf5..631d352 100644 --- a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCalcTest.java +++ b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCalcTest.java @@ -46,8 +46,7 @@ public class EnumerableCalcTest { SqlStdOperatorTable.COALESCE, builder.field("commission"), builder.literal(0))) - .build() - ) + .build()) .planContains("inp4_ != null ? inp4_.intValue() : 0;") .returnsUnordered( "$f0=0", diff --git a/core/src/test/java/org/apache/calcite/test/fuzzer/RexProgramFuzzyTest.java b/core/src/test/java/org/apache/calcite/test/fuzzer/RexProgramFuzzyTest.java index afacada..2b56704 100644 --- a/core/src/test/java/org/apache/calcite/test/fuzzer/RexProgramFuzzyTest.java +++ b/core/src/test/java/org/apache/calcite/test/fuzzer/RexProgramFuzzyTest.java @@ -51,13 +51,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; /** - * Validates that {@link org.apache.calcite.rex.RexSimplify} is able to deal with - * randomized {@link RexNode}. - * Note: the default fuzzing time is 5 seconds to keep overall test duration reasonable. - * The test starts from a random point every time, so the longer it runs the more errors it detects. + * Validates that {@link org.apache.calcite.rex.RexSimplify} is able to deal + * with a randomized {@link RexNode}. * - * <p>Note: The test is not included to {@link org.apache.calcite.test.CalciteSuite} since it would - * fail every build (there are lots of issues with {@link org.apache.calcite.rex.RexSimplify}) + * <p>The default fuzzing time is 5 seconds to keep overall test duration + * reasonable. The test starts from a random point every time, so the longer it + * runs the more errors it detects. */ public class RexProgramFuzzyTest extends RexProgramBuilderBase { protected static final Logger LOGGER = diff --git a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/PredicateAnalyzer.java b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/PredicateAnalyzer.java index ade7b60..1679f03 100644 --- a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/PredicateAnalyzer.java +++ b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/PredicateAnalyzer.java @@ -52,6 +52,7 @@ import static org.apache.calcite.adapter.elasticsearch.QueryBuilders.regexpQuery import static org.apache.calcite.adapter.elasticsearch.QueryBuilders.termQuery; import static java.lang.String.format; + /** * Query predicate analyzer. Uses visitor pattern to traverse existing expression * and convert it to {@link QueryBuilder}. diff --git a/elasticsearch/src/test/java/org/apache/calcite/adapter/elasticsearch/MatchTest.java b/elasticsearch/src/test/java/org/apache/calcite/adapter/elasticsearch/MatchTest.java index 2e5efd3..ab3f0cb 100644 --- a/elasticsearch/src/test/java/org/apache/calcite/adapter/elasticsearch/MatchTest.java +++ b/elasticsearch/src/test/java/org/apache/calcite/adapter/elasticsearch/MatchTest.java @@ -16,7 +16,6 @@ */ package org.apache.calcite.adapter.elasticsearch; - import org.apache.calcite.jdbc.CalciteConnection; import org.apache.calcite.rel.RelNode; import org.apache.calcite.rel.type.RelDataType; @@ -40,6 +39,7 @@ import org.apache.calcite.tools.RelRunner; import org.apache.calcite.util.NlsString; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.io.LineProcessor; import com.google.common.io.Resources; @@ -139,63 +139,68 @@ public class MatchTest { }; } - /** - * Test the ElasticSearch match query. The match query is translated from CONTAINS query which - * is build using RelBuilder, RexBuilder because the normal sql query assumes CONTAINS query - * is for date/period range + /** + * Tests the ElasticSearch match query. The match query is translated from + * CONTAINS query which is build using RelBuilder, RexBuilder because the + * normal SQL query assumes CONTAINS query is for date/period range. * - * Equivalent SQL query: select * from zips where city contains 'waltham' + * <p>Equivalent SQL query: * - * ElasticSearch query for it: - * {"query":{"constant_score":{"filter":{"match":{"city":"waltham"}}}}} + * <blockquote> + * <code>select * from zips where city contains 'waltham'</code> + * </blockquote> * - * @throws Exception + * <p>ElasticSearch query for it: + * + * <blockquote><code> + * {"query":{"constant_score":{"filter":{"match":{"city":"waltham"}}}}} + * </code></blockquote> */ @Test public void testMatchQuery() throws Exception { CalciteConnection con = (CalciteConnection) newConnectionFactory() .createConnection(); - SchemaPlus postschema = con.getRootSchema().getSubSchema("elastic"); + SchemaPlus postSchema = con.getRootSchema().getSubSchema("elastic"); FrameworkConfig postConfig = Frameworks.newConfigBuilder() - .parserConfig(SqlParser.Config.DEFAULT) - .defaultSchema(postschema) - .build(); + .parserConfig(SqlParser.Config.DEFAULT) + .defaultSchema(postSchema) + .build(); final RelBuilder builder = RelBuilder.create(postConfig); builder.scan(ZIPS); - final RelDataTypeFactory relDataTypeFactory = new SqlTypeFactoryImpl( - RelDataTypeSystem.DEFAULT); - final RexBuilder rexbuilder = new RexBuilder(relDataTypeFactory); + final RelDataTypeFactory typeFactory = + new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT); + final RexBuilder rexBuilder = new RexBuilder(typeFactory); - RexNode nameRexNode = rexbuilder.makeCall(SqlStdOperatorTable.ITEM, - rexbuilder.makeInputRef(relDataTypeFactory.createSqlType(SqlTypeName.ANY), 0), - rexbuilder.makeCharLiteral( - new NlsString("city", rexbuilder.getTypeFactory().getDefaultCharset().name(), - SqlCollation.COERCIBLE))); + RexNode nameRexNode = rexBuilder.makeCall(SqlStdOperatorTable.ITEM, + rexBuilder.makeInputRef(typeFactory.createSqlType(SqlTypeName.ANY), 0), + rexBuilder.makeCharLiteral( + new NlsString("city", typeFactory.getDefaultCharset().name(), + SqlCollation.COERCIBLE))); - RelDataType mapType = relDataTypeFactory.createMapType( - relDataTypeFactory.createSqlType(SqlTypeName.VARCHAR), - relDataTypeFactory.createTypeWithNullability( - relDataTypeFactory.createSqlType(SqlTypeName.ANY), true)); + RelDataType mapType = typeFactory.createMapType( + typeFactory.createSqlType(SqlTypeName.VARCHAR), + typeFactory.createTypeWithNullability( + typeFactory.createSqlType(SqlTypeName.ANY), true)); - ArrayList<RexNode> namedList = new ArrayList<RexNode>(2); - namedList.add(rexbuilder.makeInputRef(mapType, 0)); - namedList.add(nameRexNode); + List<RexNode> namedList = + ImmutableList.of(rexBuilder.makeInputRef(mapType, 0), + nameRexNode); - //Add fields in builder stack so it is accessible while filter preparation + // Add fields in builder stack so it is accessible while filter preparation builder.projectNamed(namedList, Arrays.asList("_MAP", "city"), true); RexNode filterRexNode = builder - .call(SqlStdOperatorTable.CONTAINS, builder.field("city"), - builder.literal("waltham")); + .call(SqlStdOperatorTable.CONTAINS, builder.field("city"), + builder.literal("waltham")); builder.filter(filterRexNode); String builderExpected = "" - + "LogicalFilter(condition=[CONTAINS($1, 'waltham')])\n" - + " LogicalProject(_MAP=[$0], city=[ITEM($0, 'city')])\n" - + " LogicalTableScan(table=[[elastic, " + ZIPS + "]])\n"; + + "LogicalFilter(condition=[CONTAINS($1, 'waltham')])\n" + + " LogicalProject(_MAP=[$0], city=[ITEM($0, 'city')])\n" + + " LogicalTableScan(table=[[elastic, " + ZIPS + "]])\n"; RelNode root = builder.build(); @@ -204,12 +209,13 @@ public class MatchTest { String s = CalciteAssert.toString(preparedStatement.executeQuery()); final String result = "" - + "_MAP={id=02154, city=NORTH WALTHAM, loc=[-71.236497, 42.382492], pop=57871, state=MA}; city=NORTH WALTHAM\n"; + + "_MAP={id=02154, city=NORTH WALTHAM, loc=[-71.236497, 42.382492], " + + "pop=57871, state=MA}; city=NORTH WALTHAM\n"; - //Validate query prepared + // Validate query prepared assertThat(root, hasTree(builderExpected)); - //Validate result returned from ES + // Validate result returned from ES assertThat(s, is(result)); } } diff --git a/plus/src/test/java/org/apache/calcite/adapter/tpch/TpchTest.java b/plus/src/test/java/org/apache/calcite/adapter/tpch/TpchTest.java index 9a71d1f..933b764 100644 --- a/plus/src/test/java/org/apache/calcite/adapter/tpch/TpchTest.java +++ b/plus/src/test/java/org/apache/calcite/adapter/tpch/TpchTest.java @@ -929,11 +929,10 @@ public class TpchTest { } /** Runs with query #i. - * @param i Ordinal of query, per the benchmark, 1-based * - */ + * @param i Ordinal of query, per the benchmark, 1-based */ private CalciteAssert.AssertQuery query(int i) { return with() - .query(QUERIES.get(i - 1).replaceAll("tpch\\.", "tpch_01.")); + .query(QUERIES.get(i - 1).replaceAll("tpch\\.", "tpch_01.")); } }