Skip to content

Commit 06bf7fd

Browse files
add sg
Co-authored-by: Thomas Chow <[email protected]>
1 parent 97d9870 commit 06bf7fd

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

api/py/test/sample/group_bys/quickstart/purchases.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from ai.chronon.api.ttypes import Source, EventSource
1616
from ai.chronon.query import Query, select
1717
from ai.chronon.group_by import GroupBy, Aggregation, Operation
18-
from ai.chronon.api.ttypes import StagingQuery, MetaData
1918

2019
"""
2120
This GroupBy aggregates metrics about a user's previous purchases in various windows.
@@ -68,25 +67,3 @@
6867
),
6968
],
7069
)
71-
72-
73-
query = """
74-
SELECT
75-
ts,
76-
ds,
77-
purchase_id,
78-
user_id,
79-
product_id,
80-
purchase_price
81-
FROM data.purchases
82-
WHERE ds BETWEEN '{{ start_date }}' AND '{{ end_date }}'
83-
"""
84-
85-
staging_query = StagingQuery(
86-
query=query,
87-
startPartition="2023-10-31",
88-
metaData=MetaData(
89-
name='purchases_staging_query',
90-
outputNamespace="data"
91-
)
92-
)
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)