snowflakedefinitiveguide / 1st-edition Goto Github PK
View Code? Open in Web Editor NEWSource Code Collection and Supplemental Material for the O'Reilly Snowflake Definitive Guide 1st Edition book
Source Code Collection and Supplemental Material for the O'Reilly Snowflake Definitive Guide 1st Edition book
CREATE OR REPLACE FUNCTION FACTORIAL(n variant)
RETURNS variant LANGUAGE JAVASCRIPT AS
'var f=n;
for (i=n-1; i>0; i--) {
f=f*i}
return f';
The reason the above code works is because snowflake has in built function factorial. If you rename the function to Factorial_gt and run it like:
CREATE OR REPLACE FUNCTION FACTORIAL_GT(n variant)
RETURNS variant LANGUAGE JAVASCRIPT AS
'var f=n;
for (i=n-1; i>0; i--) {
f=f*i}
return f';
and try running it using SELECT FACTORIAL_GT(5)
you will get following stacktrace 100132 (P0000): JavaScript execution error: Uncaught ReferenceError: n is not defined in FACTORIAL_GT at 'var f=n;' position 6
The comment for page 65 is the same as the one for line 62. It should say schemas
instead of tables
.
// Page 65 - Using the SHOW TABLES command to see the details of tables
SHOW SCHEMAS;
1st-Edition/Chapter Code/Chapter03.sql
Line 69 in 8889756
The section defines a masking policy, but does not provide the code to apply the masking policy to the table. Something like the following should be added:
ALTER TABLE DEMO7_DB.HRDATA.EMPLOYEES MODIFY COLUMN EMP_ID set masking policy DEMO7_DB.HRDATA.namemask using (EMP_ID, DEPT_ID);
The code for the masking policy namemask is:
CREATE OR REPLACE masking policy DEMO7_DB.HRDATA.namemask
AS (EMP_ID integer, DEPT_ID integer) returns integer ->
CASE WHEN current_role() = 'HR_ROLE'
then EMP_ID WHEN DEPT_ID = '100'
then EMP_ID
ELSE '**MASKED**' END;
When you select from the table, the following error message is generated:
Numeric value '**MASKED**' is not recognized
It appears the code for the masking policy should be something like:
CREATE OR REPLACE masking policy DEMO7_DB.HRDATA.namemask
AS (EMP_ID integer, DEPT_ID integer) returns integer ->
CASE WHEN current_role() = 'HR_ROLE'
then EMP_ID WHEN DEPT_ID = '100'
then EMP_ID
ELSE -99 END;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.