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

[Feature] Unnest supports multiple parameters of different types #12484

Merged
merged 4 commits into from
Nov 3, 2022

Conversation

HangyuanLiu
Copy link
Contributor

@HangyuanLiu HangyuanLiu commented Oct 25, 2022

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Which issues of this PR fixes :

Fixes #

Problem Summary(Required) :

The Unnest function supports multiple parameters, and the lengths of multiple arrays in unnest may not be equal. When there is an unequal situation, the columns expanded by the few arrays are supplemented with NULL values.

https://github.com/StarRocks/StarRocksTest/pull/1354

Checklist:

  • I have added test cases for my bug fix or my new feature
  • I have added user document for my new feature or new function

@wanpengfei-git
Copy link
Collaborator

starrocks_be_unittest succeeded.

@wanpengfei-git
Copy link
Collaborator

starrocks_be_unittest succeeded.

@wanpengfei-git
Copy link
Collaborator

starrocks_be_unittest succeeded.

@@ -49,8 +54,7 @@ public TableFunction(FunctionName fnName, List<String> defaultColumnNames, List<

public static void initBuiltins(FunctionSet functionSet) {
TableFunction unnestFunction = new TableFunction(new FunctionName("unnest"), Lists.newArrayList("unnest"),
Lists.newArrayList(Type.ANY_ARRAY), Lists.newArrayList(Type.ANY_ELEMENT));

Lists.newArrayList(Type.ANY_ARRAY), Lists.newArrayList(Type.ANY_ELEMENT), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

In line 91 of Function.java, there is a todo like TODO: we don't currently support varargs with no fixed types. i.e. fn(...). Can this todo be removed after this pr merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that comment is for scalar function, and scalar function does not currently support multi-type case.

@wanpengfei-git
Copy link
Collaborator

BE Build Success

kangkaisen
kangkaisen previously approved these changes Nov 1, 2022
@wanpengfei-git
Copy link
Collaborator

BE Build Success

be/src/exprs/table_function/multi_unnest.h Outdated Show resolved Hide resolved
be/src/exprs/table_function/multi_unnest.h Outdated Show resolved Hide resolved
be/src/exprs/table_function/multi_unnest.h Outdated Show resolved Hide resolved
be/src/exprs/table_function/multi_unnest.h Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Nov 2, 2022

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 2 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@kangkaisen kangkaisen enabled auto-merge (squash) November 2, 2022 11:56
@sonarcloud
Copy link

sonarcloud bot commented Nov 2, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

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
21.3% 21.3% Duplication

@HangyuanLiu
Copy link
Contributor Author

run starrocks_fe_unittest

@wanpengfei-git
Copy link
Collaborator

[FE PR Coverage Check]

😍 pass : 55 / 56 (98.21%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/optimizer/transformer/RelationTransformer.java 3 4 75.00% [667]
🔵 com/starrocks/sql/parser/AstBuilder.java 6 6 100.00% []
🔵 com/starrocks/catalog/FunctionSet.java 15 15 100.00% []
🔵 com/starrocks/sql/analyzer/QueryAnalyzer.java 19 19 100.00% []
🔵 com/starrocks/catalog/TableFunction.java 4 4 100.00% []
🔵 com/starrocks/sql/analyzer/AST2SQL.java 5 5 100.00% []
🔵 com/starrocks/sql/ast/TableFunctionRelation.java 3 3 100.00% []

@HangyuanLiu
Copy link
Contributor Author

run starrocks_admit_test

@kangkaisen kangkaisen merged commit 65303eb into StarRocks:main Nov 3, 2022
choury pushed a commit that referenced this pull request Jun 12, 2023
[Feature] Unnest supports multiple parameters of different types #12484
unnest支持多列展开
```
select * from tb1;
+------+-------------------+-------------------+
| id   | type1             | type2             |
+------+-------------------+-------------------+
| id1  | typeA;typeB;typeC | type1;type2;type3 |
+------+-------------------+-------------------+


select id, t1.v1, t1.v2 from tb1, unnest(split(type1, ";"), split(type2, ";")) as t1(v1, v2);
+------+-------+-------+
| id   | v1    | v2    |
+------+-------+-------+
| id1  | typeA | type1 |
| id1  | typeB | type2 |
| id1  | typeC | type3 |
+------+-------+-------+

```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants