Skip to content

Instantly share code, notes, and snippets.

@sualeh
Last active August 19, 2021 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sualeh/950a96308228613026029a58320e5bec to your computer and use it in GitHub Desktop.
Save sualeh/950a96308228613026029a58320e5bec to your computer and use it in GitHub Desktop.
SchemaCrawler issue #503
package schemacrawler.test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import java.util.regex.Pattern;
import org.junit.jupiter.api.Test;
import schemacrawler.inclusionrule.RegularExpressionRule;
public class Issue503 {
@Test
public void regexSchemas() throws Exception {
String sil = "^SNOWFLAKE_SAMPLE_DATA\\.TPCDS_SF100TCL";
Pattern schemaInclusionList = Pattern.compile(sil);
Pattern schemaExclusionList = Pattern.compile("");
RegularExpressionRule schemaInclusionRule =
new RegularExpressionRule(schemaInclusionList, schemaExclusionList);
assertThat(schemaInclusionRule.test(""), is(false));
assertThat(schemaInclusionRule.test(null), is(false));
assertThat(schemaInclusionRule.test("OTHER_SCHEMA"), is(false));
assertThat(schemaInclusionRule.test("SNOWFLAKE_SAMPLE_DATA.OTHER_SCHEMA"), is(false));
assertThat(schemaInclusionRule.test("SNOWFLAKE_SAMPLE_DATA@TPCDS_SF100TCL"), is(false));
assertThat(schemaInclusionRule.test("SNOWFLAKE_SAMPLE_DATA.TPCDS_SF100TCL"), is(true));
}
@Test
public void regexTables() throws Exception {
String sil = "^SNOWFLAKE_SAMPLE_DATA\\.TPCDS_SF100TCL\\..*";
Pattern tableInclusionList = Pattern.compile(sil);
Pattern tableExclusionList = null;
RegularExpressionRule tableInclusionRule =
new RegularExpressionRule(tableInclusionList, tableExclusionList);
assertThat(tableInclusionRule.test(""), is(false));
assertThat(tableInclusionRule.test(null), is(false));
assertThat(tableInclusionRule.test("SOME_TABLE"), is(false));
assertThat(tableInclusionRule.test("SNOWFLAKE_SAMPLE_DATA.OTHER_SCHEMA.SOME_TABLE"), is(false));
assertThat(tableInclusionRule.test("SNOWFLAKE_SAMPLE_DATA@TPCDS_SF100TCL@SOME_TABLE"),
is(false));
assertThat(tableInclusionRule.test("SNOWFLAKE_SAMPLE_DATA.TPCDS_SF100TCL.SOME_TABLE"),
is(true));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment