Skip to content
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

[MINOR] Add example for MAP type in reference docs #3444

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

chucheng92
Copy link
Member

@chucheng92 chucheng92 commented Sep 27, 2023

The background is that I was going to implement Spark's MAP function, and found that the MAP constructor embedded in calcite had no examples in docs. So try to add it here.

Background and context can be found at: https://issues.apache.org/jira/browse/CALCITE-5918

@chucheng92 chucheng92 changed the title [MINOR] Add example for map type in reference docs [MINOR] Add example for MAP type in reference docs Sep 27, 2023
@chucheng92 chucheng92 force-pushed the map_example branch 2 times, most recently from 11d2d6f to 06061d1 Compare September 27, 2023 16:38
Copy link
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test which confirms this syntax?

@chucheng92
Copy link
Member Author

chucheng92 commented Sep 27, 2023

Is there a test which confirms this syntax?

thanks for reviewing. Yes, we have.

@Test void testMapValueConstructor() {

The background is that I was going to implement Spark's MAP function, and found that the MAP constructor embedded in calcite had no examples in docs. So try to add it here.

@LakeShen
Copy link
Contributor

LGTM

@@ -1200,7 +1200,7 @@ Note:
| ANY | The union of all types |
| UNKNOWN | A value of an unknown type; used as a placeholder |
| ROW | Row with 1 or more columns | Example: Row(f0 int null, f1 varchar)
| MAP | Collection of keys mapped to values |
| MAP | Collection of keys mapped to values | Example: MAP\['washington', 1, 'obama', 44\]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is different from other examples.

I think the example should be map(varchar, int).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. I have updated to map[varchar, int] instead of map(varchar, int), because the previous one is calcite standard form, the later one is Spark map form. We haven't implemented this yet. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chucheng92 Do you know generateTypeString? Please take a look at them.

  • ArraySqlType#generateTypeString
  • MapSqlType#generateTypeString
  • MultisetSqlType#generateTypeString

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JiajunBernoulli thanks. Jiajun, I get your point. I actually wanted to add an example of map function at the beginning, here is actually map type.

I have updated the PR. thanks for reminding me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chucheng92
In fact, we have many map constructor examples.

from (select map['a', false, 'b', true] from (values (2))) as t(mycol);

map[multiset['A'], map[1,2], multiset['B'], map[3, 4]] as z

@sonarcloud
Copy link

sonarcloud bot commented Oct 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@chucheng92
Copy link
Member Author

hi,@JiajunBernoulli I have squashed the commit, If u have time, could you help to merge this?

@JiajunBernoulli JiajunBernoulli added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Oct 2, 2023
@JiajunBernoulli JiajunBernoulli merged commit e8b6480 into apache:main Oct 24, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LGTM-will-merge-soon Overall PR looks OK. Only minor things left.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants