Skip to content

test(native): Add AbstractTestQueries to native tests#23671

Open
pramodsatya wants to merge 2 commits intomasterfrom
presto-native-tests
Open

test(native): Add AbstractTestQueries to native tests#23671
pramodsatya wants to merge 2 commits intomasterfrom
presto-native-tests

Conversation

@pramodsatya
Copy link
Contributor

@pramodsatya pramodsatya commented Sep 18, 2024

Description

Adds support to run testcases from AbstractTestQueries with the C++ worker in presto-native-tests. These testcases are run with Presto's iterative optimizer disabled in TestNonIterativeDistributedQueries and with the default native hive query runner in TestTpchDistributedQueries.

Motivation and Context

Improves Presto C++ e2e test coverage with sidecar by extending production tests from presto-tests module to use the native worker.

Release Notes

== RELEASE NOTES ==

General Changes
* Add testcases from `AbstractTestQueries` to `presto-native-tests`.

steveburnett
steveburnett previously approved these changes Sep 18, 2024
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

Reviewed README.md, no concerns. Thanks for the doc!

@pramodsatya pramodsatya force-pushed the presto-native-tests branch 2 times, most recently from acaa071 to 8ec8208 Compare September 19, 2024 04:56
@pramodsatya pramodsatya marked this pull request as ready for review September 19, 2024 04:57
mknegi
mknegi previously approved these changes Sep 19, 2024
@tdcmeehan
Copy link
Contributor

Are these tests being run as part of the CI?

@pramodsatya
Copy link
Contributor Author

They are not being run as part of CI currently, but we plan to setup a pipeline to run these tests on a regular cadence subsequently. Will also add a CI job to run these tests in a follow-up PR.

@pramodsatya pramodsatya force-pushed the presto-native-tests branch 2 times, most recently from 32b2ad6 to f614cb6 Compare October 7, 2024 21:16
@pramodsatya pramodsatya force-pushed the presto-native-tests branch 3 times, most recently from 11d653c to 47ecc65 Compare November 11, 2024 07:49
@tdcmeehan tdcmeehan self-assigned this Nov 11, 2024
@steveburnett
Copy link
Contributor

Just a suggestions for the release note: Consider using the description of the PR in the release note entry to help a release note reader understand what this module does.

== RELEASE NOTES ==
General Changes
* Add presto-native-tests module to run end-to-end tests with Presto native workers. :pr:`23671`

@pramodsatya
Copy link
Contributor Author

Just a suggestions for the release note: Consider using the description of the PR in the release note entry to help a release note reader understand what this module does.

== RELEASE NOTES ==
General Changes
* Add presto-native-tests module to run end-to-end tests with Presto native workers. :pr:`23671`

Thanks for the suggestion @steveburnett, updated accordingly.

pramodsatya added a commit that referenced this pull request Nov 4, 2025
## Description
Fixes expected `orderdate` length in `testShowColumns` for `DWRF` file
format.

## Motivation and Context
Required by tests to be added in #23671 .


```
== NO RELEASE NOTE ==
```
@pramodsatya
Copy link
Contributor Author

@aditi-pandit, could you please help review this PR? I addressed the previous review comments and opened issues for failures identified.

Copilot AI review requested due to automatic review settings December 4, 2025 01:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for running testcases from AbstractTestQueries with the C++ worker in presto-native-tests. This significantly improves Presto C++ end-to-end test coverage by extending production tests from the presto-tests module to use the native worker.

Key changes:

  • Added two new test classes (TestTpchDistributedQueries and TestNonIterativeDistributedQueries) that run tests with different optimizer configurations
  • Created AbstractTestQueriesNative as a base class that extends AbstractTestQueries with C++-specific test overrides and error handling
  • Updated table creation utilities to support TPC-H standard schema for better test compatibility

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
presto-native-tests/src/test/java/com/facebook/presto/nativetests/AbstractTestQueriesNative.java New abstract base class that extends AbstractTestQueries with C++-specific test overrides and error message patterns
presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestTpchDistributedQueries.java New test class running testcases with default native hive query runner using PARQUET storage format
presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestNonIterativeDistributedQueries.java New test class running testcases with iterative optimizer disabled using DWRF storage format
presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestQueries.java Modified queries to add ORDER BY clause and simplified regex patterns for better C++ compatibility
presto-native-tests/src/test/java/com/facebook/presto/nativetests/NativeTestsUtils.java Updated createTables calls to use new parameter for TPC-H standard schema
presto-native-tests/presto_cpp/tests/custom_functions/CustomFunctions.cpp Registered custom_add function for native testing
presto-native-execution/src/test/java/com/facebook/presto/nativeworker/NativeQueryRunnerUtils.java Added useTpchStandardSchema parameter to table creation methods for flexibility in test schema configuration
presto-native-execution/src/test/java/com/facebook/presto/nativeworker/AbstractTestNativeIcebergTpchQueries.java Updated to use new createLineitemStandard signature with castDateToVarchar parameter
presto-native-execution/src/test/java/com/facebook/presto/nativeworker/AbstractTestNativeHiveExternalTableTpchQueries.java Updated to use new createLineitemStandard signature with castDateToVarchar parameter
presto-native-execution/src/test/java/com/facebook/presto/nativeworker/AbstractTestNativeCteExecution.java Updated to use new createAllTables signature with useTpchStandardSchema parameter
presto-docs/src/main/sphinx/presto_cpp/limitations.rst Added documentation for approx_set function differences between Presto C++ and Presto Java

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Test
public void testAnalyzePropertiesSystemTable()
{
assertQuery("SELECT COUNT(*) FROM system.metadata.analyze_properties WHERE catalog_name = 'tpch'", "SELECT 0");
Copy link
Contributor

Choose a reason for hiding this comment

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

@pramodsatya : Why does this fail on native ?

Copy link
Contributor Author

@pramodsatya pramodsatya Dec 11, 2025

Choose a reason for hiding this comment

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

@aditi-pandit, this does not fail on native, it is added here to maintain consistency with the TestTpchDistributedQueries from presto-tests:

Ideally the tests here should be moved to a separate abstract class, I can take this up in a subsequent PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah... you can move the tests to a separate abstract class. Lets avoid rewriting the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried moving these tests out of TestTpchDistributedQueries and into an abstract class, but because we are overriding several tests from the base class AbstractTestQueries for native testing, this refactor does not help avoid rewriting the tests.
Could I add a TODO comment for this?

Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

@pramodsatya : Another high level comment: Whether we cast Date depends on the storage format as DWRF doesn't support DATE but Parquet does. Ideally we should use that to guide the casting and avoid the extra parameter as much as possible. Lets cleanup guided by that.

assertQuery(session, "select o.custkey, c.name from orders o join customer c on cast(o.custkey as varchar) = cast(c.custkey as varchar)");
assertQuery(session, "select o.orderkey, c.name from orders o join customer c on cast(o.custkey as varchar) = cast(c.custkey as varchar)");
assertQuery(session, "select *, cast(o.custkey as varchar), cast(c.custkey as varchar) from orders o join customer c on cast(o.custkey as varchar) = cast(c.custkey as varchar)");
assertQuery(session, "select c.name, cast(o.custkey as varchar), cast(c.custkey as varchar) from orders o join customer c on cast(o.custkey as varchar) = cast(c.custkey as varchar)");
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't follow why these columns are added. Why did * not work ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The market segment and comment columns in customer table are swapped when select * is used (this happens without the config being tested here as well).

@Test
public void testAnalyzePropertiesSystemTable()
{
assertQuery("SELECT COUNT(*) FROM system.metadata.analyze_properties WHERE catalog_name = 'tpch'", "SELECT 0");
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah... you can move the tests to a separate abstract class. Lets avoid rewriting the tests.

assertQueryFails("SELECT greatest(rgb(255, 0, 0))", errorMessage);
}

/// The output JSON formatted string is different in Presto C++.
Copy link
Contributor

Choose a reason for hiding this comment

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

@amitkdutta : Can you review these tests for json_format usage ?

@pramodsatya pramodsatya force-pushed the presto-native-tests branch 2 times, most recently from a949c4a to 8ab36e6 Compare January 13, 2026 17:05
Copy link
Contributor Author

@pramodsatya pramodsatya left a comment

Choose a reason for hiding this comment

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

Thanks @aditi-pandit, I have reverted the castDateToVarchar parameter to use storageFormat instead, and separated this change to #26955.

Could you please take another look?

@Test
public void testAnalyzePropertiesSystemTable()
{
assertQuery("SELECT COUNT(*) FROM system.metadata.analyze_properties WHERE catalog_name = 'tpch'", "SELECT 0");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried moving these tests out of TestTpchDistributedQueries and into an abstract class, but because we are overriding several tests from the base class AbstractTestQueries for native testing, this refactor does not help avoid rewriting the tests.
Could I add a TODO comment for this?

assertQuery(session, "select o.custkey, c.name from orders o join customer c on cast(o.custkey as varchar) = cast(c.custkey as varchar)");
assertQuery(session, "select o.orderkey, c.name from orders o join customer c on cast(o.custkey as varchar) = cast(c.custkey as varchar)");
assertQuery(session, "select *, cast(o.custkey as varchar), cast(c.custkey as varchar) from orders o join customer c on cast(o.custkey as varchar) = cast(c.custkey as varchar)");
assertQuery(session, "select c.name, cast(o.custkey as varchar), cast(c.custkey as varchar) from orders o join customer c on cast(o.custkey as varchar) = cast(c.custkey as varchar)");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The market segment and comment columns in customer table are swapped when select * is used (this happens without the config being tested here as well).

pramodsatya added a commit that referenced this pull request Jan 13, 2026
…on storageFormat (#26955)

## Description
Reverts parameter `castDateToVarchar` in helper methods used to create
Tpch tables for testing. Passes in the `storageFormat` instead, and
modifies the `createTable` methods to use the storage format to decide
if `Date` columns should be cast to `Varchar`.

## Motivation and Context
Cleanup test utility methods for `presto-native-tests`:
#23671.

## Impact
NA.

## Test Plan
Verified with existing native e2e tests.


```
== NO RELEASE NOTE ==
```
@steveburnett
Copy link
Contributor

Consider rebasing the PR to rerun the tests.

@pramodsatya
Copy link
Contributor Author

@aditi-pandit, @czentgr, could you please help review these tests?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants