Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import streamlit as st | |
import json | |
from snowflake.snowpark import Session | |
session = Session.builder.getOrCreate() | |
st.title("☃️ Frosty") | |
# Initialize the chat messages history | |
if "messages" not in st.session_state.keys(): | |
st.session_state.messages = [{"role": "assistant", "content": "How can I help?"}] |
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
COPY INTO @MYSTAGE/erwin_sample.xml | |
FROM ( | |
SELECT $$<?xml version="1.0" standalone="yes"?> | |
<erwin | |
xmlns="http://www.erwin.com/dm" | |
xmlns:UDP="http://www.erwin.com/dm/metadata" | |
xmlns:EMX="http://www.erwin.com/dm/data" | |
xmlns:EM2="http://www.erwin.com/dm/EM2data" FileVersion="9.98.29174" Format="erwin"> | |
<EMX:Model xmlns="http://www.erwin.com/dm/data" id="{700A0000-D99A-CCC5-999A-7CCCE2230F33}+00000001" name="Model_1"> | |
<ModelEnvProps> |
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
from sqlalchemy import create_engine | |
import sqlalchemy | |
import logging | |
def get_engine_from_session(session): | |
# Your existing Snowflake connection (replace with your actual connection) | |
existing_snowflake_connection = session._conn._conn | |
setattr(existing_snowflake_connection,"_interpolate_empty_sequences",False) | |
# sql alchemy needs pyformat binding | |
existing_snowflake_connection._paramstyle = "pyformat" |
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
CREATE OR REPLACE FUNCTION EXTRACT_XML(FILE_PATH STRING, QUERY STRING, ITER BOOLEAN DEFAULT FALSE, OPTIONS OBJECT DEFAULT {}) | |
RETURNS TABLE(DATA VARIANT) | |
LANGUAGE PYTHON | |
RUNTIME_VERSION='3.8' | |
PACKAGES = ('snowflake-snowpark-python','lxml') | |
HANDLER = 'XmlProcess' | |
AS | |
$$ | |
import gzip | |
import tarfile |
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
create or replace procedure ingest_table_from_dbx( | |
username string,password string, host string, qualified_table_name string, page_size int default 5000, max_rows int default -1) | |
returns string language python runtime_version = 3.11 | |
packages =('snowflake-snowpark-python') | |
handler = 'main' execute as caller as $$ | |
import snowflake.snowpark as snowpark | |
from snowflake.snowpark.functions import col, lit, object_construct | |
def main(session: snowpark.Session, username, password, host, qualified_table_name, page_size, max_rows): | |
# connection_settings |
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
# How to use: | |
# 1. In VS Code, perform a search. | |
# 2. Click "Open in editor" to open the search results in a `.code-search` file | |
# 3. The Save the file | |
# 4. In terminal, run `python export-vscode-search-to-csv.py search-results.code-search path/to/exported.csv` | |
import csv | |
import sys | |
import os | |
import re |
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
/* | |
XPATHGET_TO_TABLE Function | |
Description: | |
The XPATHGET_TO_TABLE function is designed to extract and return XML nodes as a table based on the provided XPath expression. It takes as input an XML string, an XPath expression, and an object specifying namespace prefixes. | |
Parameters: | |
xml (String): The XML string from which the function extracts nodes. | |
xpath (String): The XPath expression used to navigate and locate nodes in the XML document. |
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
/* | |
XPATHGET Function | |
============== | |
Description: | |
The XPATHGET function is designed to extract values from XML documents using XPath expressions. It takes as input an XML string, an XPath expression, an optional instance parameter, and an optional prefixes parameter. | |
Parameters: | |
============ | |
xml (String): The XML string from which the function extracts values. | |
xpath (String): The XPath expression used to navigate and locate elements in the XML document. |
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
/* | |
Go to https://mvnrepository.com/artifact/com.bedatadriven.spss/spss-reader | |
and download the jar file. | |
And upload it into an stage | |
*/ | |
create or replace function read_spss_metadata(filename string) | |
RETURNS TABLE(COLUMN_NAME TEXT,TYPE TEXT,NULLABLE BOOLEAN,EXPRESSION TEXT,FILENAMES TEXT,ORDER_ID INT) | |
language java | |
imports = ('@mystage/spss-reader-1.3.jar') |
NewerOlder