xuzifu666 commented on code in PR #4939:
URL: https://github.com/apache/calcite/pull/4939#discussion_r3245340198
##########
babel/src/test/java/org/apache/calcite/test/BabelTest.java:
##########
@@ -307,6 +306,36 @@ names, is(
"HIREDATE", "SAL", "COMM", "DEPTNO", "SLACKER")));
});
+ // REPLACE with a completely different type
+ fixture.withSql("select * replace('fixed' as empno) from emp")
+ .type(type -> {
+ final List<String> names = type.getFieldList().stream()
+ .map(RelDataTypeField::getName)
+ .collect(Collectors.toList());
+ assertThat(
+ names, is(
+ ImmutableList.of("EMPNO", "ENAME", "JOB", "MGR",
+ "HIREDATE", "SAL", "COMM", "DEPTNO", "SLACKER")));
+ // EMPNO was INTEGER, now replaced by a CHAR literal
+
assertThat(type.getFieldList().get(0).getType().getSqlTypeName().getName(),
+ is("CHAR"));
+ });
+
+ // Same column replaced twice: the last one wins
+ fixture.withSql("select * replace(empno + 1 as empno, 'fixed' as empno)
from emp")
Review Comment:
That makes sense! I agree with this point. My tests on relevant databases
(including ClickHouse
https://fiddle.clickhouse.com/1f06c0d0-9704-4611-bd03-e5c31cd4e4fe) show that
not support multiple `replace` statements. I've modified the output here to
show an error. Thanks for the suggestion.
--
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]