mirror of
https://github.com/Snowflake-Labs/dlsync.git
synced 2025-12-18 00:51:27 +00:00
removed dependency parsing to remove in quote dependencies
This commit is contained in:
@@ -31,7 +31,7 @@ public class SqlTokenizer {
|
||||
|
||||
private static final String DDL_REGEX = ";\\n+(CREATE\\s+OR\\s+REPLACE\\s+(TRANSIENT\\s|HYBRID\\s|SECURE\\s)?(?<type>FILE FORMAT|\\w+)\\s+(?<name>[\\w.]+)([\\s\\S]+?)(?=(;\\nCREATE\\s+)|(;$)))";
|
||||
|
||||
private static final String STRING_LITERAL_REGEX = "(?<!as\\s{1,5})(?<!=\\s{0,5})'([^'\\\\]*(?:\\\\.[^'\\\\]*)*(?:''[^'\\\\]*)*)'";
|
||||
private static final String STRING_LITERAL_REGEX = "(?<!as\\s{1,5})'([^'\\\\]*(?:\\\\.[^'\\\\]*)*(?:''[^'\\\\]*)*)'";
|
||||
|
||||
private static final String VIEW_BODY_REGEX = "(CREATE\\s+OR\\s+REPLACE\\s+VIEW\\s+)(?<name>[\\w.${}]+)(\\s*\\([^\\)]+\\))?\\s+AS\\s+(?<body>[\\s\\S]+)$";
|
||||
private static final String FUNCTION_BODY_REGEX = "(CREATE\\s+OR\\s+REPLACE\\s+FUNCTION\\s+)(?<name>[\\w.${}]+)(?:[\\s\\S]*?AS\\s+('|\\$\\$)\\s*)(?<body>[\\s\\S]+)('|\\$\\$)\\s*;$";
|
||||
|
||||
@@ -368,7 +368,7 @@ class DependencyExtractorTest {
|
||||
@Test
|
||||
void extractScriptDependenciesIdentifierInQuotes() {
|
||||
String content = "create or replace streamlit TEST_SCHEMA1.STREAMLIT_1\n" +
|
||||
"root_location='@TEST_SCHEMA2.STAGE1'\n" +
|
||||
"root_location=@TEST_SCHEMA2.STAGE1\n" +
|
||||
"\tmain_file='/streamlit_app.py'\n" +
|
||||
"\tquery_warehouse='${MY_WAREHOUSE}'";
|
||||
Script script = ScriptFactory.getStateScript("TEST_DB", "TEST_SCHEMA1", ScriptObjectType.STREAMLITS, "STREAMLIT_1", content);
|
||||
|
||||
@@ -268,6 +268,21 @@ class SqlTokenizerTest {
|
||||
assertEquals(expected, actual, "Remove string literal assertion failed!");
|
||||
}
|
||||
|
||||
@Test
|
||||
void removeStringLiterals() {
|
||||
String sql = "create or replace view view1 " +
|
||||
" comment='some comments'" +
|
||||
" as select * from table1 where id = 'some values ' " +
|
||||
" and date <= current_date();";
|
||||
String expected = "create or replace view view1 " +
|
||||
" comment=''" +
|
||||
" as select * from table1 where id = '' " +
|
||||
" and date <= current_date();";
|
||||
|
||||
String actual = SqlTokenizer.removeSqlStringLiterals(sql);
|
||||
assertEquals(expected, actual, "Failed to remove comments.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseScriptTypeView() {
|
||||
String filePath = "db_scripts/db1/schema1/VIEWS/VIEW1.SQL";
|
||||
|
||||
Reference in New Issue
Block a user