Empty string is converted to null
See original GitHub issuespark-redshift (v3.0.0-preview1) will convert an empty string ''
into a null
value when reading data from redshift:
spark.read
.format("com.databricks.spark.redshift")
.option("url", url)
.option("aws_iam_role", iamRole)
.option("tempdir", tmpDir)
.option("query", "select '' as foo, null as bar")
.load()
.show()
[info] +----+----+
[info] | foo| bar|
[info] +----+----+
[info] |null|null|
[info] +----+----+
In redshift, there is a distinction between null
and ''
:
redshift-user=> select foo is null as foonull, bar is null as barnull from (select '' as foo, null as bar);
foonull | barnull
---------+---------
f | t
(1 row)
spark-sql also supports this distinction:
spark.sql("select '' as foo, null as bar").show()
[info] +---+----+
[info] |foo| bar|
[info] +---+----+
[info] | |null|
[info] +---+----+
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Converting empty string into null - mysql - Stack Overflow
I have a form that POST value keeps coming as "" empty string into a unique SQL field. It has to be unique...
Read more >Empty strings ("") converted to 'null' depending on database
When using the Oracle database platforms, empty strings are converted to 'null' values by the database.
Read more >FAQ: Is there any property to convert an empty string to NULL ...
No, there is no custom property that converts empty strings to NULL values in the source in PowerCenter. However, some functions could be...
Read more >21.2 Validating Null and Empty Strings
An empty string is represented as "" . It is a character sequence of zero characters. A null string is represented by null...
Read more >Java Utililty Methods Null Value Convert - Java2s.com
Method ; String, convertNullToBlank(String s) convert Null To Blank return null == s ? "" : s; ; String, convertNullToEmptyStr(String inObj) convert Null...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Databricks has decided to close source new work on this project, so I don’t expect any update or any PR accepted here. Maybe a community fork will get going, I’m disappointed and will avoid Databricks open source projects going forward.
I was wondering if you had an issue with Redshift that returns NULL in one database and on the same dataset but in different database it returns empty string. The data is the same on both of the databases?