CoolFace
Apppublic

kumar6591/data-quality-env

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
sql_brain.cpython-311.pyc13 linesDownload Raw Back to __pycache__
12�#�i��	���ddlmZddlmZed���Gd�d����Zeddd	��ed3dd��ed
dd��eddd��eddd��gZeddd	��eddd��eddd��eddd��edd d!��gZed"d#d$��ed%d&d'��ed(d)d*��ed+d,d-��gZd6d4�Zd5S)7�)�annotations)�	dataclassT)�frozenc�.�eZdZUded<ded<ded<dS)�SQLProbe�str�name�purpose�sql_templateN)�__name__�4__module__�__qualname__�__annotations__���:/Users/hemanthkunta/meta/data-quality-env/env/sql_brain.pyrrs0�������
�I�I�I��L�L�L������rr�sample_rowszQuick table sanity samplezSELECT * FROM {table} LIMIT 5�5null_emailzCount null emailszPSELECT SUM(CASE WHEN email IS NULL THEN 1 ELSE 0 END) AS null_email FROM {table}�null_customer_idzCount null customer IDsz\SELECT SUM(CASE WHEN customer_id IS NULL THEN 1 ELSE 0 END) AS null_customer_id FROM {table}�duplicate_rowsz"Estimate exact duplicate row countz�SELECT COALESCE(SUM(c-1),0) AS duplicate_rows FROM (SELECT customer_id, email, name, signup_date, country, COUNT(*) AS c FROM {table} GROUP BY 1,2,3,4,5 HAVING COUNT(*) > 1) t�country_distzDistribution by countryzKSELECT country, COUNT(*) AS n FROM {table} GROUP BY country ORDER BY n DESC�negative_quantity_rowsz"Count negative quantity violationsz[SELECT SUM(CASE WHEN quantity < 0 THEN 1 ELSE 0 END) AS negative_quantity_rows FROM {table}�unparseable_amount_rowszCount unparseable amount valuesz�SELECT SUM(CASE WHEN try_cast(replace(amount, '$', '') AS DOUBLE) IS NULL THEN 1 ELSE 0 END) AS unparseable_amount_rows FROM {table}�amount_parse_previewzPreview parsed amountsz_SELECT amount, try_cast(replace(amount, '$', '') AS DOUBLE) AS amount_num FROM {table} LIMIT 20�status_distzDistribution by statuszISELECT status, COUNT(*) AS n FROM {table} GROUP BY status ORDER BY n DESC�6mean_shiftz%Compare baseline/current amount meansz�SELECT (SELECT AVG(amount) FROM transactions_baseline) AS baseline_mean, (SELECT AVG(amount) FROM transactions_current) AS current_mean�new_categoriesz0Find categories present only in current snapshotz�SELECT DISTINCT c.category FROM transactions_current c LEFT JOIN (SELECT DISTINCT category FROM transactions_baseline) b ON c.category=b.category WHERE b.category IS NULL ORDER BY c.category�new_user_row_pctz%Estimate referential drift on user_idziSELECT AVG(CASE WHEN user_id >= 1000 THEN 1.0 ELSE 0.0 END) AS new_user_row_pct FROM transactions_current�mean_by_categoryz+Amount mean by category in current snapshotzoSELECT category, AVG(amount) AS avg_amount FROM transactions_current GROUP BY category ORDER BY avg_amount DESC�task_id�int�7table_namer�return�	list[str]c���|dkr�fd�tD��S|dkr�fd�tD��S�fd�tD��S)N�c�F��g|]}|j�������S�)�table�r�format��.0�pr"s  �r�8<listcomp>z#probes_for_task.<locals>.<listcomp>M�,���N�N�N�A���%�%�J�%�7�7�N�N�Nr�c�F��g|]}|j�������Sr(r*r,s  �rr/z#probes_for_task.<locals>.<listcomp>Or0rc�F��g|]}|j�������Sr(r*r,s  �rr/z#probes_for_task.<locals>.<listcomp>Ps,���J�J�J��A�N�!�!�9�!�3�3�J�J�Jr)�TASK1_PROBES�TASK2_PROBES�TASK3_PROBES)r r"s `r�probes_for_taskr7Ksk����!�|�O�N�N�N�N��N�N�N�N��!�|�O�N�N�N�N��N�N�N�N�J�J�J�J�\�J�J�J�JrN)r r!r"rr#r$)	�10__future__r�dataclassesrrr4r5r6r7rrr�<module>r:s��"�"�"�"�"�"�!�!�!�!�!�!���$��������������
�H�]�7�9X�Y�Y��H�\�.�1C�D�D��H�
�!:�=[�\�\��H��,�	A���
�H�^�6�9F�G�G���
�H�]�7�9X�Y�Y��H� �,�e���11
�H�!�)�	O���12
�H�� �i���13
�H�]�4�7B�C�C�#��*
�H��/�	I���
�H��:�	P���
�H��/�	$���
�H��5�y���)��8K�K�K�K�K�Kr