okumin commented on PR #5312: URL: https://github.com/apache/hive/pull/5312#issuecomment-2241629279
I think @zabetak 's proposal is further better, and the last revision follows it. I tested some cases by hand and verified the approach would likely work in all known cases. I didn't add them to `qtest` because it sounds overkilling to test all the cases. ``` 0: jdbc:hive2://hive-hiveserver2:10000/defaul> select cast(0 as bigint) = '1' except select cast(1 as bigint) = '1'; Error: Error while compiling statement: FAILED: SemanticException Line 0:-1 Wrong arguments ''1'': Unsafe compares between different types are disabled for safety reasons. If you know what you are doing, please set hive.strict.checks.type.safety to false and make sure that hive.mapred.mode is not set to 'strict' to proceed. Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features. (state=42000,code=40000) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> select count(*) from (select cast(0 as bigint) = '1' except select cast(1 as bigint) = '1') x; Error: Error while compiling statement: FAILED: SemanticException Line 0:-1 Wrong arguments ''1'': Unsafe compares between different types are disabled for safety reasons. If you know what you are doing, please set hive.strict.checks.type.safety to false and make sure that hive.mapred.mode is not set to 'strict' to proceed. Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features. (state=42000,code=40000) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> with x as (select cast(0 as bigint) = '1' except select cast(1 as bigint) = '1') select count(*) from x; Error: Error while compiling statement: FAILED: SemanticException Line 0:-1 Wrong arguments ''1'': Unsafe compares between different types are disabled for safety reasons. If you know what you are doing, please set hive.strict.checks.type.safety to false and make sure that hive.mapred.mode is not set to 'strict' to proceed. Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features. (state=42000,code=40000) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> set hive.optimize.cte.materialize.threshold=1; No rows affected (0.005 seconds) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> set hive.optimize.cte.materialize.full.aggregate.only=false; No rows affected (0.006 seconds) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> with x as (select cast(0 as bigint) = '1' except select cast(1 as bigint) = '1') select count(*) from x; Error: Error while compiling statement: FAILED: SemanticException Line 0:-1 Wrong arguments ''1'': Unsafe compares between different types are disabled for safety reasons. If you know what you are doing, please set hive.strict.checks.type.safety to false and make sure that hive.mapred.mode is not set to 'strict' to proceed. Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features. (state=42000,code=40000) ``` ``` 0: jdbc:hive2://hive-hiveserver2:10000/defaul> select cast(key as bigint) = '1' from src qualify row_number() over (partition by key order by value) = 1; Error: Error while compiling statement: FAILED: SemanticException Line 0:-1 Wrong arguments ''1'': Unsafe compares between different types are disabled for safety reasons. If you know what you are doing, please set hive.strict.checks.type.safety to false and make sure that hive.mapred.mode is not set to 'strict' to proceed. Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features. (state=42000,code=40000) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> select count(*) from (select cast(key as bigint) = '1' from src qualify row_number() over (partition by key order by value) = 1) x; Error: Error while compiling statement: FAILED: SemanticException Line 0:-1 Wrong arguments ''1'': Unsafe compares between different types are disabled for safety reasons. If you know what you are doing, please set hive.strict.checks.type.safety to false and make sure that hive.mapred.mode is not set to 'strict' to proceed. Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features. (state=42000,code=40000) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> with x as (select cast(key as bigint) = '1' from src qualify row_number() over (partition by key order by value) = 1) select count(*) from x; Error: Error while compiling statement: FAILED: SemanticException Line 0:-1 Wrong arguments ''1'': Unsafe compares between different types are disabled for safety reasons. If you know what you are doing, please set hive.strict.checks.type.safety to false and make sure that hive.mapred.mode is not set to 'strict' to proceed. Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features. (state=42000,code=40000) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> set hive.optimize.cte.materialize.threshold=1; No rows affected (0.006 seconds) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> set hive.optimize.cte.materialize.full.aggregate.only=false; No rows affected (0.006 seconds) 0: jdbc:hive2://hive-hiveserver2:10000/defaul> with x as (select cast(key as bigint) = '1' from src qualify row_number() over (partition by key order by value) = 1) select count(*) from x; Error: Error while compiling statement: FAILED: SemanticException Line 0:-1 Wrong arguments ''1'': Unsafe compares between different types are disabled for safety reasons. If you know what you are doing, please set hive.strict.checks.type.safety to false and make sure that hive.mapred.mode is not set to 'strict' to proceed. Note that you may get errors or incorrect results if you make a mistake while using some of the unsafe features. (state=42000,code=40000) ``` -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org