-
Notifications
You must be signed in to change notification settings - Fork 117
Tsaucer/prepare tpch examples for ci #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
timsaucer
wants to merge
49
commits into
apache:main
from
timsaucer:tsaucer/prepare_tpch_examples_for_ci
Closed
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
483dd01
Mostly small updates to tpc-h examples to make their results consiste…
timsaucer cacefab
Adding result validation step to q1 of tpc-h examples
timsaucer 722014d
Revert "Adding result validation step to q1 of tpc-h examples"
timsaucer 323c81e
Adding small reference data set so users can run examples without doc…
timsaucer bef28ce
Initial commit of pytest for running tpc-h examples as part of CI
timsaucer 7b66cea
Parameterize the tpch testing
timsaucer b19beca
Updates to ensure all tpc-h queries match answer file
timsaucer 01b9573
Remove dataset
timsaucer 5d3789d
Update functions to get path to answer files or data files
timsaucer e2f5c50
Cast binary to float before converting to python value
timsaucer 53c3de1
Updating from substr to substring and exposing substring call in python
timsaucer 1dc3f02
Testing workflow setup
timsaucer 1d468cd
Attempting to set workspace directory for CI step
timsaucer f4ce5d0
Add required license text
timsaucer cc9dc89
Testing workflow
timsaucer 7162d2c
Workflow testing for dbgen
timsaucer a2080e3
Workflow testing
timsaucer 20da160
Needed to add abs path
timsaucer 0b57c02
Do not produce verbose output on CI
timsaucer ff5f6cc
Add a couple debug statements to CI
timsaucer c89f0f2
Set copy path
timsaucer 5d50512
Add step to run tests on TPC-H examples
timsaucer 19301c1
Remove unused import
timsaucer 9e7da3f
Missing colon in yaml file
timsaucer 3826cd4
Yaml format error
timsaucer 66cbf94
Add dependency between CI jobs
timsaucer 549c8a3
Set CI jobs to copy artifact from one stage to another.
timsaucer 9ea3351
Now that we have the dependency on the artifact, we should allow the …
timsaucer 7866f58
Set full path for upload artifacts and set retention policy to 1 day
timsaucer acbefda
Checking to see if upload artifacts needs to be in the container's mount
timsaucer 5dc7e18
Path for building tpch data and path for using differ because of the …
timsaucer d51158b
Set relative path for artifact download
timsaucer 12438a1
Switching from artifacts to cache
timsaucer cfef43c
Docker container for data generation doesn't have the same paths, but…
timsaucer 3ddf0e5
Temporarily move cache command up to fail earlier
timsaucer d4c249a
Using restore instead of cache to pull data
timsaucer e36fb68
Setting path to see if that resolves not finding dataset
timsaucer 0d424e7
Re-add dependency
timsaucer 8180b26
Move dependancy up one level
timsaucer 39e6951
Add restore key, which shouldn't be necessary
timsaucer 6ee5061
Add debug statement to review cache keys
timsaucer 3f7339c
Attempting to pull cache object by setting to search across os
timsaucer 338a1d2
Checking path on restore isn't causing failure
timsaucer bcb9d6c
Remove debug statement, check path
timsaucer 39b8024
Debug statements
timsaucer 3cb4d7c
Testing run the docker gen script in test container instead of separa…
timsaucer cbb485b
Docker container does not need to be interactive terminal
timsaucer 2d65ed9
Just use the same script to generate the db as is in the repo
timsaucer e7a9b43
Python3.7 pyarrow does not convert decimal128 to float
timsaucer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import pytest | ||
from importlib import import_module | ||
import pyarrow as pa | ||
from datafusion import col, lit, functions as F | ||
from util import get_answer_file | ||
|
||
def df_selection(col_name, col_type): | ||
if col_type == pa.float64() or isinstance(col_type, pa.Decimal128Type): | ||
return F.round(col(col_name), lit(2)).alias(col_name) | ||
elif col_type == pa.string(): | ||
return F.trim(col(col_name)).alias(col_name) | ||
else: | ||
return col(col_name) | ||
|
||
def load_schema(col_name, col_type): | ||
if col_type == pa.int64() or col_type == pa.int32(): | ||
return col_name, pa.string() | ||
elif isinstance(col_type, pa.Decimal128Type): | ||
return col_name, pa.float64() | ||
else: | ||
return col_name, col_type | ||
|
||
def expected_selection(col_name, col_type): | ||
if col_type == pa.int64() or col_type == pa.int32(): | ||
return F.trim(col(col_name)).cast(col_type).alias(col_name) | ||
elif col_type == pa.string(): | ||
return F.trim(col(col_name)).alias(col_name) | ||
else: | ||
return col(col_name) | ||
|
||
def selections_and_schema(original_schema): | ||
columns = [ (c, original_schema.field(c).type) for c in original_schema.names ] | ||
|
||
df_selections = [ df_selection(c, t) for (c, t) in columns] | ||
expected_schema = [ load_schema(c, t) for (c, t) in columns] | ||
expected_selections = [ expected_selection(c, t) for (c, t) in columns] | ||
|
||
return (df_selections, expected_schema, expected_selections) | ||
|
||
def check_q17(df): | ||
raw_value = float(df.collect()[0]["avg_yearly"][0].as_py()) | ||
value = round(raw_value, 2) | ||
assert abs(value - 348406.05) < 0.001 | ||
|
||
@pytest.mark.parametrize( | ||
("query_code", "answer_file"), | ||
[ | ||
("q01_pricing_summary_report", "q1"), | ||
("q02_minimum_cost_supplier", "q2"), | ||
("q03_shipping_priority", "q3"), | ||
("q04_order_priority_checking", "q4"), | ||
("q05_local_supplier_volume", "q5"), | ||
("q06_forecasting_revenue_change", "q6"), | ||
("q07_volume_shipping", "q7"), | ||
("q08_market_share", "q8"), | ||
("q09_product_type_profit_measure", "q9"), | ||
("q10_returned_item_reporting", "q10"), | ||
("q11_important_stock_identification", "q11"), | ||
("q12_ship_mode_order_priority", "q12"), | ||
("q13_customer_distribution", "q13"), | ||
("q14_promotion_effect", "q14"), | ||
("q15_top_supplier", "q15"), | ||
("q16_part_supplier_relationship", "q16"), | ||
("q17_small_quantity_order", "q17"), | ||
("q18_large_volume_customer", "q18"), | ||
("q19_discounted_revenue", "q19"), | ||
("q20_potential_part_promotion", "q20"), | ||
("q21_suppliers_kept_orders_waiting", "q21"), | ||
("q22_global_sales_opportunity", "q22"), | ||
], | ||
) | ||
def test_tpch_query_vs_answer_file(query_code: str, answer_file: str): | ||
module = import_module(query_code) | ||
df = module.df | ||
|
||
# Treat q17 as a special case. The answer file does not match the spec. Running at | ||
# scale factor 1, we have manually verified this result does match the expected value. | ||
if answer_file == "q17": | ||
return check_q17(df) | ||
|
||
(df_selections, expected_schema, expected_selections) = selections_and_schema(df.schema()) | ||
|
||
df = df.select(*df_selections) | ||
|
||
read_schema = pa.schema(expected_schema) | ||
|
||
df_expected = module.ctx.read_csv(get_answer_file(answer_file), schema=read_schema, delimiter="|", file_extension=".out") | ||
|
||
df_expected = df_expected.select(*expected_selections) | ||
|
||
cols = list(read_schema.names) | ||
|
||
assert df.join(df_expected, (cols, cols), "anti").count() == 0 | ||
assert df.count() == df_expected.count() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first line here should activate the venv
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I hadn't looked at how far it got before I had to step away for the day. I know I also need to add in the upload and download artifacts between stages.