Skip to content

Commit 0c7d4ac

Browse files
feat: add stagingquery quickstart for purchases (#375)
## Summary ## Checklist - [ ] Added Unit Tests - [ ] Covered by existing CI - [ ] Integration tested - [ ] Documentation update <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new query to retrieve purchase records with date range filtering. - Enhanced data retrieval by including additional contextual metadata for improved insights. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- av pr metadata This information is embedded by the av CLI when creating PRs to track the status of stacks when using Aviator. Please do not delete or edit this section of the PR. ``` {"parent":"main","parentHead":"","trunk":"main"} ``` --> --------- Co-authored-by: Thomas Chow <[email protected]>
1 parent 6ff8894 commit 0c7d4ac

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (C) 2023 The Chronon Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from ai.chronon.api.ttypes import StagingQuery, MetaData
16+
17+
18+
19+
query = """
20+
SELECT
21+
ts,
22+
ds,
23+
purchase_id,
24+
user_id,
25+
product_id,
26+
purchase_price
27+
FROM data.purchases
28+
WHERE ds BETWEEN '{{ start_date }}' AND '{{ end_date }}'
29+
"""
30+
31+
staging_query = StagingQuery(
32+
query=query,
33+
startPartition="2023-10-31",
34+
metaData=MetaData(
35+
name='purchases_staging_query',
36+
outputNamespace="data"
37+
)
38+
)

0 commit comments

Comments
 (0)