danny0405 commented on a change in pull request #2615:
URL: https://github.com/apache/calcite/pull/2615#discussion_r757834749
##########
File path:
core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java
##########
@@ -121,8 +124,8 @@ public TypeCoercionImpl(RelDataTypeFactory typeFactory,
SqlValidator validator)
// Set operations are binary for now.
final SqlCall operand0 = ((SqlCall) query).operand(0);
final SqlCall operand1 = ((SqlCall) query).operand(1);
- final boolean coerced = rowTypeCoercion(scope, operand0, columnIndex,
targetType)
- && rowTypeCoercion(scope, operand1, columnIndex, targetType);
+ boolean coerced = rowTypeCoercion(scope, operand0, columnIndex,
targetType);
Review comment:
Yeah, you code is correct, we should not add any short-cut logic here.
##########
File path:
core/src/test/java/org/apache/calcite/test/TypeCoercionConverterTest.java
##########
@@ -133,4 +162,24 @@
private void checkPlanEquals(String sql) {
tester.assertConvertsTo(sql, "${plan}");
}
+
+ private void checkValidateSqlEquals(String sql) {
+ Objects.requireNonNull(sql, "sql");
+ final SqlNode sqlQuery;
+ try {
+ sqlQuery = tester.parseQuery(sql);
+ } catch (RuntimeException | Error e) {
+ throw e;
+ } catch (Exception e) {
+ throw TestUtil.rethrow(e);
+ }
+ final RelDataTypeFactory typeFactory =
tester.getValidator().getTypeFactory();
+ final Prepare.CatalogReader catalogReader =
+ tester.createCatalogReader(typeFactory);
+ final SqlValidator validator =
+ tester.createValidator(catalogReader, typeFactory);
+
+ final String actual = validator.validate(sqlQuery).toString();
Review comment:
Somehow we need some refactoring for this testing infrustructure, for
e.g, a `Sql` util, we can do that in another PR.
##########
File path: core/src/test/java/org/apache/calcite/test/TypeCoercionTest.java
##########
@@ -894,6 +894,13 @@ public MockCatalogReader init() {
t2.addColumn("t2_binary", binaryType);
t2.addColumn("t2_boolean", booleanType);
registerTable(t2);
+
+ final MockTable t3 =
+ MockTable.create(this, tSchema, "T3", false, 7.0, null);
+ t3.addColumn("t3_varchar20", varchar20Type);
+ t3.addColumn("t3_int", intType);
Review comment:
Yeah, i'm sliding to reuse the original tables.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]