如何防止人们在雪花桌上跑步 *?
出于合规性,我们要阻止SQL分析师在表上运行选择 *
。相反,我们要强迫他们明确要求他们选择的列。我该如何用雪花执行此操作?
我使用计算出的列看到了SQL Server的提示,雪花有等效吗?
For compliance reasons we want to block SQL analysts from running SELECT *
on a table. Instead, we want to force them to explicitly ask for the columns they want to select. How can I enforce this with Snowflake?
I saw a tip for SQL server using a calculated column, does Snowflake have an equivalent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
可以使用截断错误显示自定义消息:
QUERY:
QUERY: utume:
It is possible to use truncation error to display custom message:
Query:
Output:
为什么不使用行访问策略?它可能需要进行一些调整,但是您可以创建类似的行访问策略:
如果查询中存在
选择 *
,将此策略应用于表格将不会返回任何记录。您可以将此策略应用于每个表,并且不会以任何方式影响您的架构。Why not use a row access policy, instead? It might take some tweaking, but you could create a row access policy similar to:
Applying this policy to a table would not return any records if a
select *
was present in the query. You could apply this policy to every table and it wouldn't affect your schema in any way.这是另一种方法。
没有狡猾的列
无模式污染
向用户自定义的教育消息
本地雪花功能
手柄' *'在任何位置(选择col, * ...)
的手柄' *'确实需要更多的思考来设置 - >必须应用于每列
可以使用一个新的错误消息更新所有表格。
可扩展/可自动加以包含其他可爱的用户梦dream以求的任何其他狡猾的sql
您可以学习
要在生产中使用您需要处理所有数据类型 - >如果整个桌子都有动态面膜,那会很好。
仍然在后台运行SQL,但希望在用户厌倦了看到“坏坏”之后,他们会改变自己的方式。
允许您豁免某些用户(例如,将自己豁免为“选择前10 *”)
Here's an alternative approach.
No dodgy columns
No schema pollution
Education message to user customisable
Native Snowflake functionality
Handles '*' in any position (select col , * ...)
Does take more thought to set up -> must be applied to each column
Can update ALL your tables with new error messages in one fell swoop
Extendable/adaptable to include any other dodgy SQL your lovely users dream up
You get to learn about Dynamic Masking which is super cool!
To use in production you'd need to handle ALL datatypes -> would be nice if there was a Dynamic Mask for the entire table.
Still runs the SQL in background but hopefully after the users get sick of seeing 'bad bad bad' they'll change their ways.
Allows you to exempt SOME users (e.g. exempt yourself for select top 10 *)
当然,您可以在Snowflake中使用派生/计算的列创建表:
一旦该表具有数据,您将无法在其上运行
选择 *
,因为分别为0是一个无效的数字:您还可以将计算的列附加到现有表中,以获得相同的效果
:
< a href =“ https://i.sstatic.net/zfe9g.png” rel =“ noreferrer”>
Sure, you can create tables with derived/computed columns in Snowflake:
Once that table has data, you won't be able to run
select *
on it, as the division by 0 is an invalid number:You can also append a computed column to an existing table for the same effects:
In action: