Skip to content

add VirtualColumns.findEquivalent and VirtualColumn.EquivalenceKey#17084

Merged
clintropolis merged 3 commits intoapache:masterfrom
clintropolis:virtual-column-equivalence
Sep 17, 2024
Merged

add VirtualColumns.findEquivalent and VirtualColumn.EquivalenceKey#17084
clintropolis merged 3 commits intoapache:masterfrom
clintropolis:virtual-column-equivalence

Conversation

@clintropolis
Copy link
Copy Markdown
Member

@clintropolis clintropolis commented Sep 17, 2024

Adds methods to make it easier to check for equivalent virtual columns in the 'native' engine layer, even in cases where output names differ. This method isn't really used yet, but has some use cases in follow-up PRs.

I have only implemented EquivalenceKey for ExpressionVirtualColumn and NestedFieldVirtualColumn so far, and really only needed it for ExpressionVirtualColumn. The default implementation just means a virtual column cannot participate in equivalence, since I noticed a handful of implementations (FallbackVirtualColumn, HashPartitionVirtualColumn, and SettableLongVirtualColumn) do not implement equals proper either. Given their use-cases, and the intended use-case of this method, I don't think it probably matters, though it should be easy enough to add them if we need it.

Comment on lines +191 to +192
for (VirtualColumn vc : virtualColumns) {
if (vc.isEquivalent(virtualColumn)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wouldn't this this for loop will cost O(n^2) if it gets run for all VC-s in the query;
I think another pro of making it an internal contract/detail could enable the use of a Set so that it doesn't involve much cost

Comment thread processing/src/main/java/org/apache/druid/segment/VirtualColumn.java Outdated
@clintropolis clintropolis changed the title add VirtualColumns.findEquivalent and VirtualColumn.isEquivalent add VirtualColumns.findEquivalent and VirtualColumn.EquivalenceKey Sep 17, 2024
Copy link
Copy Markdown
Member

@kgyrtkirk kgyrtkirk left a comment

Choose a reason for hiding this comment

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

+1 (pending tests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants