snowflake-cloud-data-platform

Is there a way to know when a table was last accessed in snowflake

有些话、适合烂在心里 提交于 2020-04-16 05:50:36
问题 I am currently working on snowflake where I need to find when a table was last accessed in snowflake either by a query or manually. Can someone help me out here? Thank you 回答1: If you mean with a select, I don't think there's a way to do it by table, you'd have to monitor the last executed queries to find that information: https://docs.snowflake.net/manuals/sql-reference/functions/query_history.html Update-wise: SYSTEM$LAST_CHANGE_COMMIT_TIME should give you the info you need. 来源: https:/

Query to get list of all roles and their associated users in snowflake

好久不见. 提交于 2020-04-16 02:14:03
问题 I want to get list of all users along with the roles that are assigned to those users in a single query in snowflake. SHOW GRANTS TO ROLE1; --> This gives me list of all users assigned to ROLE1 BUT I Cannot do something like below - SHOW GRANTS TO ROLE1 UNION ALL SHOW GRANTS TO ROLE2 UNION ALL SHOW GRANTS TO ROLE3; Objective is to achieve something like above in a single query of snowflake. Regards, Yogesh 回答1: A number of queries in snowflake are not really queries, so you have to fetch the

Is it possible to generate dynamic sql to return rows with various columns in snowflake

烂漫一生 提交于 2020-04-14 06:17:07
问题 We store various data as value/pairs within a JSON column. The pair names are not the same for all rows and depend on some metadata. Is there a way I could write a SQL statement that retrieves some of these value pairs depending on some metadata? Something like a dynamically generated SELECT MyJson:FruitShape, MyJson:Fruitsize FROM MyTable WHERE ... I understand I can create and execute dynamic SQL within a stored procedure but this SQL is limited to returning a scalar vale... We need a

Snowflake - how do I retrieve the name of the currently executing procedure?

不问归期 提交于 2020-04-13 16:57:50
问题 I'd like to access the name of the currently executing procedure in Snowflake in the javascript procedure itself and store it in a variable. When I interrogate the "this" object, I can see the name in the Variant return, but in terms of JSON I believe it's the name not the value and I'm not sure how to retrieve the first name in the JSON object. What code do I need to use to get the procedure name? procName = ???what code goes here with the this object???; Do we know that the first name/value

How do I get the last accessed time stamp for the table in the snowflake?

霸气de小男生 提交于 2020-04-07 06:42:07
问题 I want to get the last accessed timestamp for a table in the snowflake 回答1: Not always ideal, but a quick way to find this for one-off questions is to use QUERY_HISTORY SELECT START_TIME, * FROM TABLE(INFORMATION_SCHEMA.QUERY_HISTORY()) WHERE QUERY_TEXT LIKE '%MYSCHEMA.MYTABLE%'; Update : Query to specifically get just the most recent query time. Have to filter out the QUERY_HISTORY queries themselves. This is not especailly fast, and does require that the role that's running this has access