Skip to content

Conversation

@xiedeyantu
Copy link
Member

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.

That was fast!

@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Dec 3, 2025
@mihaibudiu
Copy link
Contributor

Let's see if there are any other comments.

@mihaibudiu
Copy link
Contributor

Actually, the documentation needs to be updated: reference.md

@mihaibudiu
Copy link
Contributor

One more thing: can you add some tests with the syntax T.* EXCEPT(...)? Will this work in a join with both inputs?

@xiedeyantu
Copy link
Member Author

One more thing: can you add some tests with the syntax T.* EXCEPT(...)? Will this work in a join with both inputs?

This case is not supported yet. I will look into how we can add support for it.

@xiedeyantu
Copy link
Member Author

I think supporting T.* EXCLUDE(...) will require some additional work. We should probably remove the LGTM label for now, as I may need to do some refactoring.

@mihaibudiu mihaibudiu removed the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Dec 4, 2025
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.

Let's see if this can include the T.* syntax as well.

@xiedeyantu
Copy link
Member Author

Let's see if this can include the T.* syntax as well.

Maybe yes, I will check it.

@xiedeyantu xiedeyantu force-pushed the CALCITE-7310 branch 3 times, most recently from 63ea502 to 155496e Compare December 4, 2025 04:55
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.

Having the changes in a separate commit would have made this a bit easier to review

* A scalar value has length 1;
* The length of array or object is the number of elements is contains.

### Babel parser extensions
Copy link
Contributor

Choose a reason for hiding this comment

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

could you instead add the new rule to the grammar and make this a note after the grammar rule is described?

import static java.util.Objects.requireNonNull;

/**
* Represents {@code SELECT * EXCLUDE(...)} when parsed by the Babel parser.
Copy link
Contributor

Choose a reason for hiding this comment

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

The fact that the Babel parser (only) uses this class should probably not be part of the Javadoc of this class.

}

@Override public void validate(SqlValidator validator, SqlValidatorScope scope) {
// Babel already validates the exclude list
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems odd, what if someone wants to use this outside of Babel?

Copy link
Member Author

Choose a reason for hiding this comment

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

Deleted this empty override of the validate method.


private static boolean matchesExcludeNames(List<String> columnNames,
List<String> excludeNames, SqlNameMatcher nameMatcher) {
if (excludeNames.size() > columnNames.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this right even if there are duplicates?
or have duplicates been checked elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

The EXCLUDE list is compared item by item, and duplicates are also included. Additionally, there is a Boolean type for identification, so no extra consideration for duplicates is needed here.

Copy link
Contributor

Choose a reason for hiding this comment

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

here you are returning after comparing only lengths

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, this should be a comparison between column names and fully qualified names. For example, [deptno] (in excludeNames) and [emp.deptno] (in columnNames).

Copy link
Contributor

Choose a reason for hiding this comment

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

So each list is a qualified identifier?

Copy link
Member Author

@xiedeyantu xiedeyantu Dec 5, 2025

Choose a reason for hiding this comment

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

Yes, excludeNamescan be either [deptno] or [emp, deptno], while columnNameswould be [emp, deptno] or [emp, empno].

Copy link
Contributor

Choose a reason for hiding this comment

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

please make this clearer in the name of the arguments

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in cb1be43

return false;
}
for (SqlNode node : excludeList) {
if (!(node instanceof SqlIdentifier)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect this can never happen, so this can perhaps be an assertion?

@xiedeyantu
Copy link
Member Author

Having the changes in a separate commit would have made this a bit easier to review

Yes, because it was basically a major refactoring, I force-pushed it. Then do you think it's better to let the default parser have this capability without distinguishing Babel separately?

@mihaibudiu
Copy link
Contributor

No, I think it's fine to have it in Babel, but in general I don't think a class should list in JavaDoc the places where it's used unless the class is private. After all, you don't know what other code people will write in the future using this class.

@xiedeyantu
Copy link
Member Author

Some other comments have been addressed. If I missed anything, please let me know.

* Represents {@code SELECT * EXCLUDE(...)}.
*/
public class SqlStarExclude extends SqlCall {
public static final SqlSpecialOperator OPERATOR =
Copy link
Contributor

Choose a reason for hiding this comment

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

Change
public static final SqlSpecialOperator OPERATOR
to
public static final SqlOperator OPERATOR.

Also, implement the createCall method for the operator

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 for review, I have addressed this in 6f38e07

return ImmutableNullableList.of(starIdentifier, excludeList);
}

@Override public SqlNode clone(SqlParserPos pos) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to override clone if operator createCall is implemented correctly

Copy link
Contributor

@dssysolyatin dssysolyatin left a comment

Choose a reason for hiding this comment

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

Looks good. I added a few minor comments

}

@Override public List<SqlNode> getOperandList() {
return ImmutableNullableList.of(starIdentifier, excludeList);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why it is ImmutableNullableList and not just ImmutableList ? If I understand correctly both starIdentifier and excludeList are not nullable.

starIdentifier.unparse(writer, leftPrec, rightPrec);
writer.sep("EXCLUDE");
writer.print("(");
for (int i = 0; i < excludeList.size(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need your own unparse logic for SqlNodeList instead of using excludeList.unparse

final SqlWriter.Frame frame = writer.startList("(", ")");
excludeList.unparse(...)
writer.endList(frame)

@xiedeyantu
Copy link
Member Author

I've made some adjustments to SqlStarExclude based on your comments. Please review it again. Thank you @dssysolyatin .

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 6, 2025

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.

This looks great from my pov, if @dssysolyatin likes it we can merge it after squashing.

@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Dec 8, 2025
Copy link
Contributor

@dssysolyatin dssysolyatin left a comment

Choose a reason for hiding this comment

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

Looks good. Feel free to merge

@mihaibudiu
Copy link
Contributor

@xiedeyantu please squash the commits; feel free to merge if you want, otherwise I will do it

@xiedeyantu
Copy link
Member Author

Jenkins might have some issues. Should we wait for it?

@mihaibudiu
Copy link
Contributor

Nah, jenkins can run later too

@xiedeyantu xiedeyantu merged commit 935d676 into apache:main Dec 9, 2025
18 of 19 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.

3 participants