-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-38225][SQL] Adjust input format
of function to_binary
#35533
Closed
+49
−28
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5c01f94
for wrong format input
xinrong-meng 2869cb1
test
xinrong-meng 98634d7
trigger test
xinrong-meng 8be5db9
rmv base2 format support
xinrong-meng 4b93726
fail when format is cast(null as int)
xinrong-meng 6d94e00
rmv unnecessary chk
xinrong-meng 75494c3
fix
xinrong-meng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-- Automatically generated by SQLQueryTestSuite | ||
-- Number of queries: 116 | ||
-- Number of queries: 117 | ||
|
||
|
||
-- !query | ||
|
@@ -850,14 +850,6 @@ struct<to_binary(abc, base64):binary> | |
i� | ||
|
||
|
||
-- !query | ||
select to_binary('abc', 'base2') | ||
-- !query schema | ||
struct<to_binary(abc, base2):binary> | ||
-- !query output | ||
abc | ||
|
||
|
||
-- !query | ||
select to_binary('abc', 'hex') | ||
-- !query schema | ||
|
@@ -930,10 +922,28 @@ struct<to_binary(NULL, CAST(NULL AS STRING)):binary> | |
NULL | ||
|
||
|
||
-- !query | ||
select to_binary(null, cast(null as int)) | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.spark.sql.AnalysisException | ||
cannot resolve 'to_binary(NULL, CAST(NULL AS INT))' due to data type mismatch: Unsupported encoding format: Some(ansi_cast(null as int)). The format has to be a case-insensitive string literal of 'hex', 'utf-8', or 'base64'; line 1 pos 7 | ||
|
||
|
||
-- !query | ||
select to_binary('abc', 'invalidFormat') | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.spark.sql.AnalysisException | ||
cannot resolve 'to_binary('abc', 'invalidFormat')' due to data type mismatch: Unsupported encoding format: Some(invalidFormat). The format has to be a case-insensitive string literal of 'hex', 'utf-8', 'base2', or 'base64'; line 1 pos 7 | ||
cannot resolve 'to_binary('abc', 'invalidFormat')' due to data type mismatch: Unsupported encoding format: Some(invalidFormat). The format has to be a case-insensitive string literal of 'hex', 'utf-8', or 'base64'; line 1 pos 7 | ||
|
||
|
||
-- !query | ||
select to_binary('abc', 1) | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.spark.sql.AnalysisException | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentionally failed query. |
||
cannot resolve 'to_binary('abc', 1)' due to data type mismatch: Unsupported encoding format: Some(1). The format has to be a case-insensitive string literal of 'hex', 'utf-8', or 'base64'; line 1 pos 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-- Automatically generated by SQLQueryTestSuite | ||
-- Number of queries: 116 | ||
-- Number of queries: 117 | ||
|
||
|
||
-- !query | ||
|
@@ -846,14 +846,6 @@ struct<to_binary(abc, base64):binary> | |
i� | ||
|
||
|
||
-- !query | ||
select to_binary('abc', 'base2') | ||
-- !query schema | ||
struct<to_binary(abc, base2):binary> | ||
-- !query output | ||
abc | ||
|
||
|
||
-- !query | ||
select to_binary('abc', 'hex') | ||
-- !query schema | ||
|
@@ -926,10 +918,28 @@ struct<to_binary(NULL, CAST(NULL AS STRING)):binary> | |
NULL | ||
|
||
|
||
-- !query | ||
select to_binary(null, cast(null as int)) | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.spark.sql.AnalysisException | ||
cannot resolve 'to_binary(NULL, CAST(NULL AS INT))' due to data type mismatch: Unsupported encoding format: Some(cast(null as int)). The format has to be a case-insensitive string literal of 'hex', 'utf-8', or 'base64'; line 1 pos 7 | ||
|
||
|
||
-- !query | ||
select to_binary('abc', 'invalidFormat') | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.spark.sql.AnalysisException | ||
cannot resolve 'to_binary('abc', 'invalidFormat')' due to data type mismatch: Unsupported encoding format: Some(invalidFormat). The format has to be a case-insensitive string literal of 'hex', 'utf-8', 'base2', or 'base64'; line 1 pos 7 | ||
cannot resolve 'to_binary('abc', 'invalidFormat')' due to data type mismatch: Unsupported encoding format: Some(invalidFormat). The format has to be a case-insensitive string literal of 'hex', 'utf-8', or 'base64'; line 1 pos 7 | ||
|
||
|
||
-- !query | ||
select to_binary('abc', 1) | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.spark.sql.AnalysisException | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentionally failed query. |
||
cannot resolve 'to_binary('abc', 1)' due to data type mismatch: Unsupported encoding format: Some(1). The format has to be a case-insensitive string literal of 'hex', 'utf-8', or 'base64'; line 1 pos 7 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, do other systems like snowflake support
to_binary('abc', null)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snowflake doesn't specify that in their document, but BigQuery and Teradata support
to_binary('abc', null)
:Expressions, functions, and operators | BigQuery | Google Cloud "If an operand is NULL, the result is NULL, with the exception of the IS operator."
Teradata Online Documentation | Quick access to technical manuals "If either instring or in_encoding is NULL, the result is NULL."