You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "xuzifu666 (via GitHub)" <gi...@apache.org> on 2025/04/03 10:17:53 UTC
[PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
xuzifu666 opened a new pull request, #4287:
URL: https://github.com/apache/calcite/pull/4287
As description in JIRA: https://issues.apache.org/jira/browse/CALCITE-6937
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2029623474
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
I don't understand what you are proposing
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2028018121
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
@mihaibudiu Thanks for the reminder, I had test about it and currently it not support convert in nested type(such as array), as follow:
**select cast(array[1.0, 2.1, 3.3] as real array) —> SELECT CAST(ARRAY (1.0, 2.1, 3.3) AS REAL ARRAY)**
but this pr is just handle with unnested type, I would plan to file a new issue and PR to resolve for nested type support, WDYT?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2029240661
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
is it difficult to fix this properly for all cases?
essentially every time you need to unparse REAL you write FLOAT
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2028252433
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
OK, how about change title to "Hive/Phoenix Dialect should not cast to REAL type", if OK I would change to it @mihaibudiu
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2031791504
##########
core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java:
##########
@@ -40,4 +47,19 @@ public PhoenixSqlDialect(Context context) {
@Override public boolean supportsCharSet() {
return false;
}
+
+ @Override public @Nullable SqlNode getCastSpec(RelDataType type) {
+ switch (type.getSqlTypeName()) {
+ case REAL:
+ return new SqlDataTypeSpec(
+ new SqlAlienSystemTypeNameSpec(
+ "FLOAT",
+ type.getSqlTypeName(),
+ SqlParserPos.ZERO),
+ SqlParserPos.ZERO);
+ default:
+ break;
+ }
+ return super.getCastSpec(type);
Review Comment:
Can't you handle arrays, multisets, and maps here?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2029570036
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
yes,but currently all dialect systems like this,such as clickhouse dialect could just support cast to unnested type,IMO archive unnested type first also is necessary,wdyt?@mihaibudiu
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2785600890
> It is necessary to confirm whether the issue lies in the verification apache hive version I used.
Yes, in Hive and Phoenix syntax are not support cast nested type such as map/array cast currently, maybe in this pr we just only consider unnested type cast? if OK, I would change to the earliest version, WDYT @NobiGo
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2027973525
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
Does this work if the type appears in another context which is not a simple cast?
For example, a `CAST(x as REAL ARRAY)`?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2028018121
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
@mihaibudiu Thanks for the reminder, I had test about it and currently it not support convert in nested type(such as array),as follow:
**select cast(array[1.0, 2.1, 3.3] as real array) —> SELECT CAST(ARRAY (1.0, 2.1, 3.3) AS REAL ARRAY)**
but not only Hive other system dialects also not support nested type now, I would plan to file a new issue and PR to resolve for nested type support in furture. This pr is just handle with unnested type, WDYT?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2029570036
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
yes,but currently all dialect systems like this,such as clickhouse dialect could just cast unnested type,IMO archive unnested type first also is necessary,wdyt?@mihaibudiu
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2788369523
> > > Throwing an exception for unsupported constructs is fine, but this may make some legal Calcite programs unable to generate code for Hive. But that should probably be a different issue: "Hive dialect does not support code generation for casts to nested data types"
> >
> >
> > OK, as discussion,I would changed it to throw an unsupported exception way, and would open a new jira “Hive dialect does not support code generation for casts to nested data types” to resolve in furture. cc @mihaibudiu @NobiGo
>
> I understand that the limitation in on the HiveQL side regarding casts to nested types, why do we need to open a Jira ticket in Calcite? If we are handling the case already with a clear exception, this seems enough on the Calcite side.
Yes,maybe we not need to to open a new jira. @asolimando
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2032515593
##########
core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java:
##########
@@ -40,4 +47,19 @@ public PhoenixSqlDialect(Context context) {
@Override public boolean supportsCharSet() {
return false;
}
+
+ @Override public @Nullable SqlNode getCastSpec(RelDataType type) {
+ switch (type.getSqlTypeName()) {
+ case REAL:
+ return new SqlDataTypeSpec(
+ new SqlAlienSystemTypeNameSpec(
+ "FLOAT",
+ type.getSqlTypeName(),
+ SqlParserPos.ZERO),
+ SqlParserPos.ZERO);
+ default:
+ break;
+ }
+ return super.getCastSpec(type);
Review Comment:
Had handled with array and map types in cast logic,because Hive/Phonenix had not type of multiset, PTAL @mihaibudiu
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2788078144
> Throwing an exception for unsupported constructs is fine, but this may make some legal Calcite programs unable to generate code for Hive. But that should probably be a different issue: "Hive dialect does not support code generation for casts to nested data types"
OK, as discussion,I would changed it to throw an unsupported exception way, and would open a new jira “Hive dialect does not support code generation for casts to nested data types” to resolve in furture. cc @mihaibudiu @NobiGo
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2028018121
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
@mihaibudiu Thanks for the reminder, I had test about it and currently it not support convert in nested type(such as array),as follow:
**select cast(array[1.0, 2.1, 3.3] as real array) —> SELECT CAST(ARRAY (1.0, 2.1, 3.3) AS REAL ARRAY)**
but not only Hive other systems dialect also not support nested type now, I would plan to file a new issue and PR to resolve for nested type support. This pr is just handle with unnested type, WDYT?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2026757763
##########
core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java:
##########
@@ -155,6 +155,13 @@ public HiveSqlDialect(Context context) {
@Override public @Nullable SqlNode getCastSpec(final RelDataType type) {
if (type instanceof BasicSqlType) {
switch (type.getSqlTypeName()) {
+ case REAL:
+ return new SqlDataTypeSpec(
+ new SqlAlienSystemTypeNameSpec(
+ "FLOAT",
Review Comment:
Please keep your coding style consistent with the others.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "asolimando (via GitHub)" <gi...@apache.org>.
asolimando commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2788364443
> > Throwing an exception for unsupported constructs is fine, but this may make some legal Calcite programs unable to generate code for Hive. But that should probably be a different issue: "Hive dialect does not support code generation for casts to nested data types"
>
> OK, as discussion,I would changed it to throw an unsupported exception way, and would open a new jira “Hive dialect does not support code generation for casts to nested data types” to resolve in furture. cc @mihaibudiu @NobiGo
I understand that the limitation in on the HiveQL side regarding casts to nested types, why do we need to open a Jira ticket in Calcite?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2034513039
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2514,9 +2514,8 @@ private SqlDialect nonOrdinalDialect() {
*/
@Test void testCastArrayCharset() {
final String query = "select cast(array['a', 'b', 'c'] as varchar array)";
- final String expected = "SELECT CAST(ARRAY ('a', 'b', 'c') AS VARCHAR ARRAY)";
Review Comment:
**This case also not support in HiveSQL, so change it.**
test result:
SELECT CAST(ARRAY ('a', 'b', 'c') AS VARCHAR ARRAY);
FAILED: ParseException line 1:45 mismatched input 'ARRAY' expecting ( near 'VARCHAR' in primitive type specification
MismatchedTokenException(35!=334)
at org.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(BaseRecognizer.java:617)
at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:115)
at org.apache.hadoop.hive.ql.parse.HiveParser.primitiveType(HiveParser.java:36225)
at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.castExpression(HiveParser_IdentifiersParser.java:3811)
at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.atomExpression(HiveParser_IdentifiersParser.java:6757)
at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceFieldExpression(HiveParser_IdentifiersParser.java:6962)
at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceUnaryPrefixExpression(HiveParser_IdentifiersParser.java:7298)
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2026885357
##########
core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java:
##########
@@ -155,6 +155,13 @@ public HiveSqlDialect(Context context) {
@Override public @Nullable SqlNode getCastSpec(final RelDataType type) {
if (type instanceof BasicSqlType) {
switch (type.getSqlTypeName()) {
+ case REAL:
+ return new SqlDataTypeSpec(
+ new SqlAlienSystemTypeNameSpec(
+ "FLOAT",
Review Comment:
Thanks,done @NobiGo
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2040586523
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2514,9 +2514,8 @@ private SqlDialect nonOrdinalDialect() {
*/
@Test void testCastArrayCharset() {
final String query = "select cast(array['a', 'b', 'c'] as varchar array)";
- final String expected = "SELECT CAST(ARRAY ('a', 'b', 'c') AS VARCHAR ARRAY)";
sql(query)
- .withHive().ok(expected);
+ .withHive().throws_("Hive dialect does not support cast to ARRAY");
Review Comment:
OK,had a test for postgresql and test it work well, thanks for your reply. @JiajunBernoulli
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2800248049
I think the commits can be squashed. If there are no further comments I plan to merge this.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #4287:
URL: https://github.com/apache/calcite/pull/4287
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2802371170
@NobiGo please let us know if you are happy with the changes
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2800514915
> I think the commits can be squashed. If there are no further comments I plan to merge this.
Thanks, had squashed commits. @mihaibudiu
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "JiajunBernoulli (via GitHub)" <gi...@apache.org>.
JiajunBernoulli commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2040582786
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2514,9 +2514,8 @@ private SqlDialect nonOrdinalDialect() {
*/
@Test void testCastArrayCharset() {
final String query = "select cast(array['a', 'b', 'c'] as varchar array)";
- final String expected = "SELECT CAST(ARRAY ('a', 'b', 'c') AS VARCHAR ARRAY)";
sql(query)
- .withHive().ok(expected);
+ .withHive().throws_("Hive dialect does not support cast to ARRAY");
Review Comment:
@mihaibudiu Yes, hive does not support it.
This is my mistake.
Postgre support it, can we add one line `withPostgresql()`?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2040586523
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2514,9 +2514,8 @@ private SqlDialect nonOrdinalDialect() {
*/
@Test void testCastArrayCharset() {
final String query = "select cast(array['a', 'b', 'c'] as varchar array)";
- final String expected = "SELECT CAST(ARRAY ('a', 'b', 'c') AS VARCHAR ARRAY)";
sql(query)
- .withHive().ok(expected);
+ .withHive().throws_("Hive dialect does not support cast to ARRAY");
Review Comment:
OK,had a test for postgresql and test it work well, thanks for your reply. @JiajunBernoulli
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2029631454
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
Emm,no other proposing currently,whether can do it like the pr firstly,it is difficult to cover all kind of cases such as array or other kind of complex type, it need to unparse all type with REAL,this pr resolve cast to real first,do you agree about it? thanks.@mihaibudiu
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2036401919
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9473,40 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealTypesCast() {
+ String query = "SELECT CAST(\"department_id\" AS float), "
+ + "CAST(\"department_id\" AS double), "
+ + "CAST(\"department_id\" AS real) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(\"department_id\" AS FLOAT), "
+ + "CAST(\"department_id\" AS DOUBLE), "
+ + "CAST(\"department_id\" AS FLOAT)\nFROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(`department_id` AS FLOAT), "
+ + "CAST(`department_id` AS DOUBLE), "
+ + "CAST(`department_id` AS FLOAT)\nFROM `foodmart`.`employee`";
+
+ sql(query)
+ .withPhoenix().ok(expectedPhoenix)
+ .withHive().ok(expectedHive);
+ }
+
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealArrayOrMapTypesCast() {
+ String query = "SELECT CAST(array[1,2,3] AS real array) FROM \"employee\"";
+ sql(query)
+ .withPhoenix().throws_("Phoenix dialect can not support cast to ARRAY")
Review Comment:
Thanks, done.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2028018121
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
@mihaibudiu Thanks for the reminder, I had test about it and currently it not support convert in nested type(such as array),as follow:
**select cast(array[1.0, 2.1, 3.3] as real array) —> SELECT CAST(ARRAY (1.0, 2.1, 3.3) AS REAL ARRAY)**
but this pr is just handle with unnested type, not only Hive other systems dialect also not support nested type now, I would plan to file a new issue and PR to resolve for nested type support, WDYT?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2785680635
If there is official statement to doesn't support these types, we can currently throw an exception and describe the situation clearly in Jira or Java doc.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2787149928
In particular, in Calcite there is no way to specify the type of an empty array/map except by using a CAST.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2032628837
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,55 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealTypesCast() {
+ String query = "SELECT CAST(\"department_id\" AS float), "
+ + "CAST(\"department_id\" AS double), "
+ + "CAST(\"department_id\" AS real) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(\"department_id\" AS FLOAT), "
+ + "CAST(\"department_id\" AS DOUBLE), "
+ + "CAST(\"department_id\" AS FLOAT)\nFROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(`department_id` AS FLOAT), "
+ + "CAST(`department_id` AS DOUBLE), "
+ + "CAST(`department_id` AS FLOAT)\nFROM `foodmart`.`employee`";
+
+ sql(query)
+ .withPhoenix().ok(expectedPhoenix)
+ .withHive().ok(expectedHive);
+ }
+
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealArrayTypesCast() {
+ String query = "SELECT CAST(array[1,2,3] AS real array) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(ARRAY[1, 2, 3] AS FLOAT ARRAY)\n"
+ + "FROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(ARRAY (1, 2, 3) AS FLOAT ARRAY)\n"
Review Comment:
`[40000] [42000]: Error while compiling statement: FAILED: ParseException line 1:37 extraneous input 'ARRAY' expecting ) near '<EOF>'`
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,55 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealTypesCast() {
+ String query = "SELECT CAST(\"department_id\" AS float), "
+ + "CAST(\"department_id\" AS double), "
+ + "CAST(\"department_id\" AS real) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(\"department_id\" AS FLOAT), "
+ + "CAST(\"department_id\" AS DOUBLE), "
+ + "CAST(\"department_id\" AS FLOAT)\nFROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(`department_id` AS FLOAT), "
+ + "CAST(`department_id` AS DOUBLE), "
+ + "CAST(`department_id` AS FLOAT)\nFROM `foodmart`.`employee`";
+
+ sql(query)
+ .withPhoenix().ok(expectedPhoenix)
+ .withHive().ok(expectedHive);
+ }
+
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealArrayTypesCast() {
+ String query = "SELECT CAST(array[1,2,3] AS real array) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(ARRAY[1, 2, 3] AS FLOAT ARRAY)\n"
+ + "FROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(ARRAY (1, 2, 3) AS FLOAT ARRAY)\n"
+ + "FROM `foodmart`.`employee`";
+
+ sql(query)
+ .withPhoenix().ok(expectedPhoenix)
+ .withHive().ok(expectedHive);
+ }
+
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealMapTypesCast() {
+ String query = "SELECT CAST(MAP[1.0,2.0,3.0,4.0] AS MAP<FLOAT, REAL>) FROM \"employee\"";
+ String expectedHive = "SELECT CAST(MAP (1.0, 2.0, 3.0, 4.0) AS MAP< FLOAT, FLOAT >)\n"
Review Comment:
This SQL throws an exception in Hive.
`SQL ERROR [40000] [42000]: Error while compiling statement: FAILED: ParseException line 1:40 cannot recognize input near 'MAP' '(' 'FLOAT' in primitive type specification`
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "JiajunBernoulli (via GitHub)" <gi...@apache.org>.
JiajunBernoulli commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2798531239
> Let's wait a bit to see what @JiajunBernoulli says about the incorrect test.
Sorry for the late reply due to busy workdays.
Thank you for letting me discover the mistake!
We can fix it.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2028245516
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
Then your issue title is not good. You are not treating occurrences of the REAL type, you are treating only occurrences of the casts to REAL.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2036402406
##########
core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java:
##########
@@ -171,6 +177,18 @@ public HiveSqlDialect(Context context) {
break;
}
}
+
+ if (type instanceof AbstractSqlType) {
Review Comment:
Make sense, had added MULTISET case. PTAL @mihaibudiu
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2029570036
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
yes,but currently all dialect systems like this,such as clickhouse dialect could just support cast unnested type,IMO archive unnested type first also is necessary,wdyt?@mihaibudiu
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6937] Hive/Phoenix can not support REAL type [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2029631454
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,25 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6937">[CALCITE-6937]
+ * Hive/Phoenix can not support REAL type</a>. */
+ @Test void testRealTypesCast() {
Review Comment:
Emm,no other proposing currently,whether can do it like the pr firstly,it is diffcult to cover all kind of cases such as array or other kind of complex type,this pr resolve cast to real first,do you agree about it? thanks.@mihaibudiu
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2785804609
> If there is official statement to doesn't support these types, we can currently throw an exception and describe the situation clearly in Jira or Java doc.
@NobiGo I had asked some Hive experts about it and search in Hive and Phoenix doc, Hive/Phoenix may not support cast nested type, we can refer in doc:
Hive: https://hive.apache.org/docs/latest/122917025/
seems only support base type cast.
Phoenix: https://phoenix.apache.org/language/index.html
If OK, I would modify as your 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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2035811688
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9473,40 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealTypesCast() {
+ String query = "SELECT CAST(\"department_id\" AS float), "
+ + "CAST(\"department_id\" AS double), "
+ + "CAST(\"department_id\" AS real) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(\"department_id\" AS FLOAT), "
+ + "CAST(\"department_id\" AS DOUBLE), "
+ + "CAST(\"department_id\" AS FLOAT)\nFROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(`department_id` AS FLOAT), "
+ + "CAST(`department_id` AS DOUBLE), "
+ + "CAST(`department_id` AS FLOAT)\nFROM `foodmart`.`employee`";
+
+ sql(query)
+ .withPhoenix().ok(expectedPhoenix)
+ .withHive().ok(expectedHive);
+ }
+
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealArrayOrMapTypesCast() {
+ String query = "SELECT CAST(array[1,2,3] AS real array) FROM \"employee\"";
+ sql(query)
+ .withPhoenix().throws_("Phoenix dialect can not support cast to ARRAY")
Review Comment:
Can we change this message to say "does not" instead of "can not"?
##########
core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java:
##########
@@ -171,6 +177,18 @@ public HiveSqlDialect(Context context) {
break;
}
}
+
+ if (type instanceof AbstractSqlType) {
Review Comment:
what about MULTISET?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2787148263
Throwing an exception for unsupported constructs is fine, but this may make some legal Calcite programs unable to generate code for Hive. But that should probably be a different issue: "Hive dialect does not support code generation for casts to nested data types"
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2032858600
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,55 @@ private void checkLiteral2(String expression, String expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealTypesCast() {
+ String query = "SELECT CAST(\"department_id\" AS float), "
+ + "CAST(\"department_id\" AS double), "
+ + "CAST(\"department_id\" AS real) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(\"department_id\" AS FLOAT), "
+ + "CAST(\"department_id\" AS DOUBLE), "
+ + "CAST(\"department_id\" AS FLOAT)\nFROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(`department_id` AS FLOAT), "
+ + "CAST(`department_id` AS DOUBLE), "
+ + "CAST(`department_id` AS FLOAT)\nFROM `foodmart`.`employee`";
+
+ sql(query)
+ .withPhoenix().ok(expectedPhoenix)
+ .withHive().ok(expectedHive);
+ }
+
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealArrayTypesCast() {
+ String query = "SELECT CAST(array[1,2,3] AS real array) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(ARRAY[1, 2, 3] AS FLOAT ARRAY)\n"
+ + "FROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(ARRAY (1, 2, 3) AS FLOAT ARRAY)\n"
+ + "FROM `foodmart`.`employee`";
+
+ sql(query)
+ .withPhoenix().ok(expectedPhoenix)
+ .withHive().ok(expectedHive);
+ }
+
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealMapTypesCast() {
+ String query = "SELECT CAST(MAP[1.0,2.0,3.0,4.0] AS MAP<FLOAT, REAL>) FROM \"employee\"";
+ String expectedHive = "SELECT CAST(MAP (1.0, 2.0, 3.0, 4.0) AS MAP< FLOAT, FLOAT >)\n"
Review Comment:
This spark is ok, but hive and phoenix not support.
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2037799078
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2514,9 +2514,8 @@ private SqlDialect nonOrdinalDialect() {
*/
@Test void testCastArrayCharset() {
final String query = "select cast(array['a', 'b', 'c'] as varchar array)";
- final String expected = "SELECT CAST(ARRAY ('a', 'b', 'c') AS VARCHAR ARRAY)";
sql(query)
- .withHive().ok(expected);
+ .withHive().throws_("Hive dialect does not support cast to ARRAY");
Review Comment:
@JiajunBernoulli you wrote this test originally, is it indeed incorrect?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6940] Hive/Phoenix Dialect should not cast to REAL type directly [calcite]
Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #4287:
URL: https://github.com/apache/calcite/pull/4287#issuecomment-2798676841
> > Let's wait a bit to see what @JiajunBernoulli says about the incorrect test.
>
> Sorry for the late reply due to busy workdays.
>
> Thank you for letting me discover the mistake!
>
> We can fix it.
Had add a test for Postgresql and test it in postgresql system thanks for your reply~ @JiajunBernoulli
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org