Skip to content

Commit 29d86b5

Browse files
authored
Add warning message for unique count and histogram (#1013)
* add warning for unique count and histogram * lint * lint * use logger Signed-off-by: Pengyu Hou <[email protected]> * fix * lint * fix flake8 --------- Signed-off-by: Pengyu Hou <[email protected]>
1 parent 5da9c32 commit 29d86b5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

api/py/ai/chronon/group_by.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ def Aggregation(
155155
arg_map = {}
156156
if isinstance(operation, tuple):
157157
operation, arg_map = operation[0], operation[1]
158+
159+
if operation == ttypes.Operation.UNIQUE_COUNT:
160+
LOGGER.warning("When using UNIQUE_COUNT operation, please consider using "
161+
"BOUNDED_UNIQUE_COUNT_K or APPROX_UNIQUE_COUNT "
162+
"for better performance and scalability.")
163+
elif operation == ttypes.Operation.HISTOGRAM:
164+
LOGGER.warning("When using HISTOGRAM operation, please consider using "
165+
"APPROX_HISTOGRAM_K for better performance and "
166+
"bounded memory usage.")
167+
158168
agg = ttypes.Aggregation(input_column, operation, arg_map, windows, buckets)
159169
agg.tags = tags
160170
return agg
@@ -516,7 +526,7 @@ def _normalize_source(source):
516526
elif isinstance(source, ttypes.Source):
517527
return source
518528
else:
519-
print("unrecognized " + str(source))
529+
LOGGER.warning("unrecognized " + str(source))
520530

521531
if not isinstance(sources, list):
522532
sources = [sources]

0 commit comments

Comments
 (0)