Created
October 13, 2023 15:40
-
-
Save trungv0/e9780cf82613393c9641719dda3527d4 to your computer and use it in GitHub Desktop.
frosty friday w066
This file contains 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
# https://frostyfriday.org/blog/2023/10/06/week-66-intermediate/ | |
import snowflake.snowpark as snowpark | |
from snowflake.snowpark import functions as F | |
def main(session: snowpark.Session): | |
tableName = 'snowflake.account_usage.tables' | |
dataframe = ( | |
session.table(tableName) | |
.filter( | |
(F.col('row_count') > 0) | |
& (~F.col('is_transient')) | |
& F.col('deleted').is_null() | |
) | |
.select(F.col('table_catalog').as_('database')) | |
.group_by(F.col('database')) | |
.agg(F.count('*').as_('tables')) | |
) | |
return dataframe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment