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
[FLINK-31677][table] Add built-in MAP_ENTRIES function. #22312
Conversation
13959f8
to
227d13c
Compare
hi @snuyanzin do you have time to review it? |
227d13c
to
7884126
Compare
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.
LGTM
hi @dawidwys could you have a look this ,it is long time no one to review and merge? |
hi @snuyanzin do you have time to review it? |
docs/data/sql_functions.yml
Outdated
@@ -646,6 +646,9 @@ collection: | |||
- sql: MAP_VALUES(map) | |||
table: MAP.mapValues() | |||
description: Returns the values of the map as array. No order guaranteed. | |||
- sql: MAP_ENTRIES(map) | |||
table: MAP.mapEntries() | |||
description: Returns an unordered array of all entries in the given map. No order guaranteed. |
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.
what means unordered
here?
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.
keys are not sorted, i will remove it @snuyanzin
@@ -231,6 +231,7 @@ advanced type helper functions | |||
Expression.array_remove | |||
Expression.map_keys | |||
Expression.map_values | |||
Expression.map_entries |
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.
it's better to have abc order
@property | ||
def map_entries(self) -> 'Expression': | ||
""" | ||
Returns an unordered array of all entries in the given map. No order guaranteed. |
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.
same about unordered
@@ -1396,6 +1397,11 @@ public OutType mapValues() { | |||
return toApiSpecificExpression(unresolvedCall(MAP_VALUES, toExpr())); | |||
} | |||
|
|||
/** Returns an unordered array of all entries in the given map. */ |
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.
same about unordered
7884126
to
5934b4b
Compare
hi @snuyanzin rebase and fix your reviews and ci passed |
hi @snuyanzin do you have time look again? |
1 similar comment
hi @snuyanzin do you have time look again? |
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.
@liuyongvs Thanks for this PR. I left one comment.
callContext -> | ||
Optional.of( | ||
DataTypes.ARRAY( | ||
DataTypes.ROW( |
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.
Do we need to specify the name for each field of the Row
type? Btw, seems spark use
StructType(
StructField("key", childDataType.keyType, false) ::
StructField("value", childDataType.valueType, childDataType.valueContainsNull) ::
Nil)
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.
added @luoyuxia
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.
@liuyongvs Thanks for updating. LGTM. Could you please rebase master. When test pass, please ping me. I can help merge.
bfba384
to
9ea9ec4
Compare
9ea9ec4
to
d97ce47
Compare
What is the purpose of the change
This is an implementation of MAP_ENTRIES
Brief change log
MAP_ENTRIES for Table API and SQL
See also
presto https://prestodb.io/docs/current/functions/map.html
spark https://spark.apache.org/docs/latest/api/sql/index.html#map_entries
Verifying this change
This change added tests in MapFunctionITCase.
Does this pull request potentially affect one of the following parts:
Dependencies (does it add or upgrade a dependency): ( no)
The public API, i.e., is any changed class annotated with @public(Evolving): (yes )
The serializers: (no)
The runtime per-record code paths (performance sensitive): ( no)
Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: ( no)
The S3 file system connector: ( no)
Documentation
Does this pull request introduce a new feature? (yes)
If yes, how is the feature documented? (docs)