Skip to content

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jul 31, 2025

Which issue does this PR close?

Rationale for this change

We had customers relying on the old syntax, and there appears to be no reason (or tests) that the old syntax is barred

What changes are included in this PR?

Remove the error that prevents runnings queries like this

> SELECT approx_percentile_cont_with_weight(c1, c2, 0.95) FROM test;
+-------------------------------------------------------------------+
| approx_percentile_cont_with_weight(test.c1,test.c2,Float64(0.95)) |
+-------------------------------------------------------------------+
| 5.0                                                               |
+-------------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.001 seconds.

Are these changes tested?

Yes, new sqllogictests are added

Are there any user-facing changes?

Yes, new (well, old) syntax is supported as well

@alamb alamb changed the title Alamb/old approx distinct syntax (Re)Support old syntax for approx_percentile_cont and approx_percentile_cont_with_weight Jul 31, 2025
} else {
// User defined aggregate functions (UDAF) have precedence in case it has the same name as a scalar built-in function
if let Some(fm) = self.context_provider.get_aggregate_meta(&name) {
if fm.is_ordered_set_aggregate() && within_group.is_empty() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there appears to be no tests for this error nor any reason I can see for not allowing it


# csv_query_approx_percentile_cont (c2, alternate syntax, should be the same as above)
query B
SELECT (ABS(1 - CAST(approx_percentile_cont(c2, 0.1) AS DOUBLE) / 1.0) < 0.05) AS q FROM aggregate_test_100
Copy link
Contributor Author

Choose a reason for hiding this comment

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

now both the new and old queries work

Copy link
Contributor

@crepererum crepererum left a comment

Choose a reason for hiding this comment

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

The docs need to be updated too.

@github-actions github-actions bot added documentation Improvements or additions to documentation sql SQL Planner sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Aug 8, 2025
@alamb
Copy link
Contributor Author

alamb commented Aug 8, 2025

The docs need to be updated too.

In 6c283df

@alamb alamb requested a review from crepererum August 8, 2025 18:59
@alamb alamb merged commit eaf614d into apache:main Aug 13, 2025
28 checks passed
@alamb
Copy link
Contributor Author

alamb commented Aug 13, 2025

Thanks again @crepererum

@alamb alamb deleted the alamb/old_approx_distinct_syntax branch August 13, 2025 12:44
crepererum pushed a commit to influxdata/arrow-datafusion that referenced this pull request Aug 25, 2025
…ntile_cont_with_weight` (apache#16999)

* Add sqllogictests

* Allow both new and old sytanx for approx_percentile_cont and approx_percentile_cont_with_weight

* Update docs

* Add documentation and more tests
crepererum pushed a commit to influxdata/arrow-datafusion that referenced this pull request Sep 5, 2025
…ntile_cont_with_weight` (apache#16999)

* Add sqllogictests

* Allow both new and old sytanx for approx_percentile_cont and approx_percentile_cont_with_weight

* Update docs

* Add documentation and more tests
crepererum pushed a commit to influxdata/arrow-datafusion that referenced this pull request Sep 5, 2025
…ntile_cont_with_weight` (apache#16999)

* Add sqllogictests

* Allow both new and old sytanx for approx_percentile_cont and approx_percentile_cont_with_weight

* Update docs

* Add documentation and more tests
erratic-pattern pushed a commit to influxdata/arrow-datafusion that referenced this pull request Oct 6, 2025
…ntile_cont_with_weight` (apache#16999)

* Add sqllogictests

* Allow both new and old sytanx for approx_percentile_cont and approx_percentile_cont_with_weight

* Update docs

* Add documentation and more tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation functions Changes to functions implementation sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support old syntax for approx_percentile_cont and approx_percentile_cont_with_weight

2 participants