You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "jingpan xiong (Jira)" <ji...@apache.org> on 2021/08/24 12:28:00 UTC

[jira] [Commented] (SPARK-35289) Make CatalogString contains nullable information

    [ https://issues.apache.org/jira/browse/SPARK-35289?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17403776#comment-17403776 ] 

jingpan xiong commented on SPARK-35289:
---------------------------------------

i had meet this issue in my project, and my error message is below 
!screenshot-1.png! 
And the data in the test is :
hesnx;qgdph;qydpt;26;rtaco;2:51.1
updle;tlpuu;agyue;10;mbdnn;3:22.2
sjjzs;tpnkb;pytdu;14;vfogo;4:70.3
ozacs;afcpc;zkfhz;14;nqpwa;5:94.4
uibxi;hbggo;zstuo;10;xiibw;6:05.5
bphga;xajrb;juwwh;18;lkndi;7:71.6
phswl;zivnz;ujsui;24;pyhhk;8:79.7

The command of the test is : 
spark-sql:
create table testtmp01 (
`date` string,
`user` string,
`name` string,
`age` string,
`str` string,
`extends_map` map<int,double>
) ROW FORMAT DELIMITED FIELDS TERMINATED BY ';' 
COLLECTION ITEMS TERMINATED BY '|' 
MAP KEYS TERMINATED BY ':' 
STORED AS TEXTFILE;

spark-shell:
case class DailySessionIdLabelInfo(extends_map: Map[Int, Double])
val dddd = sql("select extends_map from testtmp01 limit 10").as[DailySessionIdLabelInfo]

And can we add a full error log for this issue to let the user know the real issue for this problem?

> Make CatalogString contains nullable information
> ------------------------------------------------
>
>                 Key: SPARK-35289
>                 URL: https://issues.apache.org/jira/browse/SPARK-35289
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.1.1
>            Reporter: hezuojiao
>            Assignee: Apache Spark
>            Priority: Major
>         Attachments: screenshot-1.png
>
>
> When trying to cast ArrayType/MapType/StructType from containing NULL to not contain NULL, we will get a confusing failure message.
>  Here's a example:
> {code:java}
> // new UT in CastSuite
> test("array casting") {
>  val arrayContainsNull = Literal.create(Seq("contains", "null", null),
>  ArrayType(StringType, containsNull = true))
>  val ret = cast(arrayContainsNull, ArrayType(StringType, containsNull = false))
>  assert(ret.resolved === false)
>  // scalastyle:off println
>  println(ret.typeCheckFailureMessage)
>  // scalastyle:on println
> }
> {code}
> Failure massage:
> {code:java}
> cannot cast array<string> to array<string>{code}
> From the above error message, it is not clear why the error is reported, because the data type before and after is the same.
>  Therefore, I think we need to specify nullable info for ArrayType/MapType?/StructType in the Catalog String to identify the reason for Cast Failures.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org