Skip to content

Commit a594547

Browse files
authored
Add SQLite tests for table masked columns (#411)
Adding a new CRYPTBANK sqlite database to the testing suite with metadata for masked columns. Creates relational/sql/e2e tests for this new database with refsols included. The data, during the data generation step, gets "encrypted" via various schemes for most columns which can be reversed (the encryption/decryption schemes are included in the metadata). The e2e tests were written with refsols before the encryption was added, then marked for skipping since they won't be possible to get the right answer until relational handling for masked table columns is added.
1 parent 2cc9a51 commit a594547

File tree

89 files changed

+2533
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2533
-7
lines changed

pydough/unqualified/unqualified_transform.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,9 @@ def from_string(
468468
try:
469469
tree: ast.AST = ast.parse(source)
470470
except SyntaxError as e:
471-
raise ValueError(f"Syntax error in source PyDough code:\n{str(e)}") from e
471+
raise ValueError(
472+
f"Syntax error in source PyDough code:\n{source}\n{str(e)}"
473+
) from e
472474
assert isinstance(tree, ast.AST)
473475
new_tree: ast.AST = ast.fix_missing_locations(visitor.visit(tree))
474476
assert isinstance(new_tree, ast.AST)

tests/conftest.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,20 @@ def impl(name: str) -> GraphMetadata:
485485
return impl
486486

487487

488+
@pytest.fixture(scope="session")
489+
def masked_graphs() -> graph_fetcher:
490+
"""
491+
Returns the graphs for the masked databases.
492+
"""
493+
494+
@cache
495+
def impl(name: str) -> GraphMetadata:
496+
path: str = f"{os.path.dirname(__file__)}/test_metadata/masked_graphs.json"
497+
return pydough.parse_json_metadata_from_file(file_path=path, graph_name=name)
498+
499+
return impl
500+
501+
488502
@pytest.fixture(scope="session")
489503
def sqlite_defog_connection() -> DatabaseContext:
490504
"""
@@ -540,6 +554,24 @@ def sqlite_technograph_connection() -> DatabaseContext:
540554
return DatabaseContext(DatabaseConnection(connection), DatabaseDialect.SQLITE)
541555

542556

557+
@pytest.fixture(scope="session")
558+
def sqlite_cryptbank_connection() -> DatabaseContext:
559+
"""
560+
Returns the SQLITE database connection for the CRYPTBANK database.
561+
"""
562+
# Setup the directory to be the main PyDough directory.
563+
base_dir: str = os.path.dirname(os.path.dirname(__file__))
564+
# Setup the cryptbank database.
565+
subprocess.run(
566+
"cd tests; rm -fv gen_data/cryptbank.db; sqlite3 gen_data/cryptbank.db < gen_data/init_cryptbank.sql",
567+
shell=True,
568+
)
569+
path: str = os.path.join(base_dir, "tests/gen_data/cryptbank.db")
570+
connection: sqlite3.Connection = sqlite3.connect(":memory:")
571+
connection.execute(f"attach database '{path}' as CRBNK")
572+
return DatabaseContext(DatabaseConnection(connection), DatabaseDialect.SQLITE)
573+
574+
543575
SF_ENVS = ["SF_USERNAME", "SF_PASSWORD", "SF_ACCOUNT"]
544576
"""
545577
Snowflake environment variables required for connection.

tests/gen_data/init_cryptbank.sql

Lines changed: 500 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)