You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "jackylau (Jira)" <ji...@apache.org> on 2023/06/08 10:03:00 UTC
[jira] [Commented] (CALCITE-5772) Add MAP_CONCAT, MAP_FROM_ENTRIES for Spark dialect
[ https://issues.apache.org/jira/browse/CALCITE-5772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17730483#comment-17730483 ]
jackylau commented on CALCITE-5772:
-----------------------------------
[~jiajunbernoulli] [~julianhyde] [~tanclary]
comments:
because my other prs will conflict it, so i don't submit. so i add an summary:
the spark MAP_FROM_ENTRIES nullable have 2 case:
1) input is nullable
2) array, which contains null entry like this ,it will also return null
so we should take this into consideration, type and result, i will add comment in the pr when you review you will see
{code:java}
// code placeholder
spark-sql> select map_from_entries(array(struct(1, 'a'), null));
NULL {code}
{code:java}
case class MapFromEntries(child: Expression)
extends UnaryExpression
with NullIntolerant
with QueryErrorsBase {
@transient
private lazy val dataTypeDetails: Option[(MapType, Boolean, Boolean)] = child.dataType match {
case ArrayType(
StructType(Array(
StructField(_, keyType, keyNullable, _),
StructField(_, valueType, valueNullable, _))),
containsNull) => Some((MapType(keyType, valueType, valueNullable), keyNullable, containsNull))
case _ => None
}
@transient private lazy val nullEntries: Boolean = dataTypeDetails.get._3
override def nullable: Boolean = child.nullable || nullEntries
{code}
> Add MAP_CONCAT, MAP_FROM_ENTRIES for Spark dialect
> ---------------------------------------------------
>
> Key: CALCITE-5772
> URL: https://issues.apache.org/jira/browse/CALCITE-5772
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.35.0
> Reporter: jackylau
> Assignee: jackylau
> Priority: Major
> Fix For: 1.35.0
>
>
> h3. [map_concat|https://spark.apache.org/docs/latest/api/sql/index.html#map_concat]
> map_concat(map, ...) - Returns the union of all the given maps
> *Examples:*
> {{> SELECT map_concat(map(1, 'a', 2, 'b'), map(3, 'c'));
> {1:"a",2:"b",3:"c"}}}
> {{}}
> h3. [map_from_entries|https://spark.apache.org/docs/latest/api/sql/index.html#map_from_entries]
> map_from_entries(arrayOfEntries) - Returns a map created from the given array of entries.
> *Examples:*
>
> {{{}> SELECT map_from_entries(array(struct(1, 'a'), struct(2, 'b')));
> {1:"a",2:"b"}{}}}{{{}{}}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)