-
Notifications
You must be signed in to change notification settings - Fork 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
Add builders for table function arguments #12350
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,71 @@ public boolean isPassThroughColumns() | |
return passThroughColumns; | ||
} | ||
|
||
public static Builder builder() | ||
{ | ||
return new Builder(); | ||
} | ||
|
||
public static final class Builder | ||
{ | ||
private Optional<QualifiedName> name; | ||
private RowType rowType; | ||
private List<String> partitionBy = List.of(); | ||
private List<SortItem> orderBy = List.of(); | ||
private boolean rowSemantics; | ||
private boolean pruneWhenEmpty; | ||
private boolean passThroughColumns; | ||
|
||
private Builder() {} | ||
|
||
public Builder name(Optional<QualifiedName> name) | ||
{ | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public Builder rowType(RowType rowType) | ||
{ | ||
this.rowType = rowType; | ||
return this; | ||
} | ||
|
||
public Builder partitionBy(List<String> partitionBy) | ||
losipiuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
this.partitionBy = partitionBy; | ||
return this; | ||
} | ||
|
||
public Builder orderBy(List<SortItem> orderBy) | ||
{ | ||
this.orderBy = orderBy; | ||
return this; | ||
} | ||
|
||
public Builder rowSemantics(boolean rowSemantics) | ||
{ | ||
this.rowSemantics = rowSemantics; | ||
return this; | ||
} | ||
|
||
public Builder pruneWhenEmpty(boolean pruneWhenEmpty) | ||
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. Generally I prefer boolean methods to have a good default and then a no-arg method to change tha behavior, so I would make this:
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. It was the initial approach. I changed it according to #12350 (comment) |
||
{ | ||
this.pruneWhenEmpty = pruneWhenEmpty; | ||
return this; | ||
} | ||
|
||
public Builder passThroughColumns(boolean passThroughColumns) | ||
{ | ||
this.passThroughColumns = passThroughColumns; | ||
return this; | ||
} | ||
|
||
public TableArgument build() | ||
{ | ||
return new TableArgument(name, rowType, partitionBy, orderBy, rowSemantics, pruneWhenEmpty, passThroughColumns); | ||
} | ||
} | ||
|
||
public static class QualifiedName | ||
{ | ||
private final String catalogName; | ||
|
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.
That looks like a typed value. I wouldn't foresee additional parameters here, and so the builder looks like an overkill
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.
Not really. At some point, we will allow arbitrary expressions as scalar arguments.