Skip to content

MSQ: Fix validation of time position in collations.#16961

Merged
gianm merged 2 commits intoapache:masterfrom
gianm:fix-time-position-validation
Aug 27, 2024
Merged

MSQ: Fix validation of time position in collations.#16961
gianm merged 2 commits intoapache:masterfrom
gianm:fix-time-position-validation

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Aug 26, 2024

It is possible for the collation to refer to a field that isn't mapped, such as when the DML includes "CLUSTERED BY some_function(some_field)". In this case, the collation refers to a projected column that is not part of the field mappings. Prior to this patch, that would lead to an out of bounds list access on fieldMappings.

This patch fixes the problem by identifying the position of __time in the fieldMappings first, rather than retrieving each collation field from fieldMappings.

Fixes a bug introduced in #16849.

Release note:

SQL based ingestion can only have __time column in the first position of the clustered by clause. If the __time column is at any other position, we throw a InvalidSqlInput exception.

It is possible for the collation to refer to a field that isn't mapped,
such as when the DML includes "CLUSTERED BY some_function(some_field)".
In this case, the collation refers to a projected column that is not
part of the field mappings. Prior to this patch, that would lead to an
out of bounds list access on fieldMappings.

This patch fixes the problem by identifying the position of __time in
the fieldMappings first, rather than retrieving each collation field
from fieldMappings.

Fixes a bug introduced in apache#16849.
@gianm gianm added Bug Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Aug 26, 2024
@gianm gianm added this to the 31.0.0 milestone Aug 26, 2024

@MethodSource("data")
@ParameterizedTest(name = "{index}:with context {0}")
public void testReplaceOnFooWithAllClusteredByExpression(String contextName, Map<String, Object> context)

Check notice

Code scanning / CodeQL

Useless parameter

The parameter 'contextName' is never used.
@gianm gianm merged commit ed3dbd6 into apache:master Aug 27, 2024
@gianm gianm deleted the fix-time-position-validation branch August 27, 2024 07:02
hevansDev pushed a commit to hevansDev/druid that referenced this pull request Aug 29, 2024
* MSQ: Fix validation of time position in collations.

It is possible for the collation to refer to a field that isn't mapped,
such as when the DML includes "CLUSTERED BY some_function(some_field)".
In this case, the collation refers to a projected column that is not
part of the field mappings. Prior to this patch, that would lead to an
out of bounds list access on fieldMappings.

This patch fixes the problem by identifying the position of __time in
the fieldMappings first, rather than retrieving each collation field
from fieldMappings.

Fixes a bug introduced in apache#16849.

* Fix test. Better warning message.
@cryptoe
Copy link
Copy Markdown
Contributor

cryptoe commented Sep 3, 2024

@gianm Just added a release note to the description. Please let me know if its okay.

edgar2020 pushed a commit to edgar2020/druid that referenced this pull request Sep 5, 2024
* MSQ: Fix validation of time position in collations.

It is possible for the collation to refer to a field that isn't mapped,
such as when the DML includes "CLUSTERED BY some_function(some_field)".
In this case, the collation refers to a projected column that is not
part of the field mappings. Prior to this patch, that would lead to an
out of bounds list access on fieldMappings.

This patch fixes the problem by identifying the position of __time in
the fieldMappings first, rather than retrieving each collation field
from fieldMappings.

Fixes a bug introduced in apache#16849.

* Fix test. Better warning message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Batch Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Querying Bug Release Notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants