-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Return scalar result when all inputs are constants in map
and make_map
#11461
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a584b9e
return scalar result when all inputs are constants.
Rachelint b2ba98e
support convert map array to scalar.
Rachelint ae1f0f2
disable the const evaluate for Map type before impl its hash calculat…
Rachelint 0956bcd
add tests in map.slt.
Rachelint 48314ae
improve error return.
Rachelint 1217e96
fix error.
Rachelint 46e57ea
fix remove unused import.
Rachelint 6c8c699
remove duplicated testcase.
Rachelint 3a6d37a
remove inline.
Rachelint 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
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 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -212,3 +212,95 @@ SELECT map(column5, column6) FROM t; | |||||||||||||||
# {k1:1, k2:2} | ||||||||||||||||
# {k3: 3} | ||||||||||||||||
# {k5: 5} | ||||||||||||||||
|
||||||||||||||||
query error | ||||||||||||||||
SELECT map(column5, column6) FROM t; | ||||||||||||||||
# TODO: support array value | ||||||||||||||||
# ---- | ||||||||||||||||
# {k1:1, k2:2} | ||||||||||||||||
# {k3: 3} | ||||||||||||||||
# {k5: 5} | ||||||||||||||||
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.
Suggested change
I think this test is the same as the above one. We can remove it. 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. fixed |
||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAKE_MAP('POST', 41, 'HEAD', 33, 'PATCH', 30, 'OPTION', 29, 'GET', 27, 'PUT', 25, 'DELETE', 24) AS method_count from t; | ||||||||||||||||
---- | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30, OPTION: 29, GET: 27, PUT: 25, DELETE: 24} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30, OPTION: 29, GET: 27, PUT: 25, DELETE: 24} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30, OPTION: 29, GET: 27, PUT: 25, DELETE: 24} | ||||||||||||||||
|
||||||||||||||||
query I | ||||||||||||||||
SELECT MAKE_MAP('POST', 41, 'HEAD', 33)['POST'] from t; | ||||||||||||||||
---- | ||||||||||||||||
41 | ||||||||||||||||
41 | ||||||||||||||||
41 | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAKE_MAP('POST', 41, 'HEAD', 33, 'PATCH', null) from t; | ||||||||||||||||
---- | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: } | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: } | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: } | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAKE_MAP('POST', null, 'HEAD', 33, 'PATCH', null) from t; | ||||||||||||||||
---- | ||||||||||||||||
{POST: , HEAD: 33, PATCH: } | ||||||||||||||||
{POST: , HEAD: 33, PATCH: } | ||||||||||||||||
{POST: , HEAD: 33, PATCH: } | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAKE_MAP(1, null, 2, 33, 3, null) from t; | ||||||||||||||||
---- | ||||||||||||||||
{1: , 2: 33, 3: } | ||||||||||||||||
{1: , 2: 33, 3: } | ||||||||||||||||
{1: , 2: 33, 3: } | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAKE_MAP([1,2], ['a', 'b'], [3,4], ['b']) from t; | ||||||||||||||||
---- | ||||||||||||||||
{[1, 2]: [a, b], [3, 4]: [b]} | ||||||||||||||||
{[1, 2]: [a, b], [3, 4]: [b]} | ||||||||||||||||
{[1, 2]: [a, b], [3, 4]: [b]} | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAP(['POST', 'HEAD', 'PATCH'], [41, 33, 30]) from t; | ||||||||||||||||
---- | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAP(['POST', 'HEAD', 'PATCH'], [41, 33, null]) from t; | ||||||||||||||||
---- | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: } | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: } | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: } | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAP([[1,2], [3,4]], ['a', 'b']) from t; | ||||||||||||||||
---- | ||||||||||||||||
{[1, 2]: a, [3, 4]: b} | ||||||||||||||||
{[1, 2]: a, [3, 4]: b} | ||||||||||||||||
{[1, 2]: a, [3, 4]: b} | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAP(make_array('POST', 'HEAD', 'PATCH'), make_array(41, 33, 30)) from t; | ||||||||||||||||
---- | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAP(arrow_cast(make_array('POST', 'HEAD', 'PATCH'), 'FixedSizeList(3, Utf8)'), arrow_cast(make_array(41, 33, 30), 'FixedSizeList(3, Int64)')) from t; | ||||||||||||||||
---- | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
|
||||||||||||||||
query ? | ||||||||||||||||
SELECT MAP(arrow_cast(make_array('POST', 'HEAD', 'PATCH'), 'LargeList(Utf8)'), arrow_cast(make_array(41, 33, 30), 'LargeList(Int64)')) from t; | ||||||||||||||||
---- | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} | ||||||||||||||||
{POST: 41, HEAD: 33, PATCH: 30} |
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.
Any specific reason for using inline over 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.
Just a personal habit to mark the very short function, and try to reduce the function call cost(it will be really inlined or not... determinded by the compiler).
Will it cause some problems that I haven't noticed before?
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.
Since it more of a suggestion to complier, i dont think this should cause problems. TIL: Inlining small functions can provide small speed wins.
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.
I think there is rare case for
inline
. I perfer not to inline unless the benmark shows that compiler fail to do the good job for ushttps://matklad.github.io/2021/07/09/inline-in-rust.html
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.
Seem inline here is actually unnecessary according to the article mentioned by @jayzhan211 , removed.