Skip to content

Commit

Permalink
chore: update workbench for 1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
z3z1ma committed Jan 3, 2025
1 parent 1ea0c8d commit 2a5e8e8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/dbt_osmosis/core/osmosis.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,10 @@ def normalize_column_name(column: str, credentials_type: str) -> str:
"""Apply case normalization to a column name based on the credentials type."""
if credentials_type == "snowflake" and column.startswith('"') and column.endswith('"'):
logger.debug(":snowflake: Column name found with double-quotes => %s", column)
return column.strip('"')
if credentials_type == "snowflake":
pass
elif credentials_type == "snowflake":
return column.upper()
return column
return column.strip('"').strip("`").strip("[]")


def _maybe_use_precise_dtype(
Expand Down
22 changes: 14 additions & 8 deletions src/dbt_osmosis/workbench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def _parse_args() -> dict[str, t.Any]:
def change_target() -> None:
"""Change the target profile"""
ctx: DbtProject = state.w.ctx
if ctx.config.target_name != state.w.target_profile:
if ctx.runtime_cfg.target_name != state.w.target_profile:
print(f"Changing target to {state.w.target_profile}")
ctx.config.target_name = state.w.target_profile
ctx.runtime_cfg.target_name = state.w.target_profile
_reload_manifest(ctx)
state.w.raw_sql += " " # invalidate cache on next compile?
state.w.cache_version += 1
Expand All @@ -136,7 +136,7 @@ def inject_model() -> None:
"""Inject model into editor"""
ctx: DbtProject = state.w.ctx
if state.model is not None and state.model != "SCRATCH":
path = os.path.join(ctx.config.project_root, state.model.original_file_path)
path = os.path.join(ctx.runtime_cfg.project_root, state.model.original_file_path)
with open(path, "r") as f:
state.w.raw_sql = f.read()
state.w.editor.update_content("SQL", state.w.raw_sql)
Expand All @@ -149,7 +149,7 @@ def save_model() -> None:
"""Save model to disk"""
ctx: DbtProject = state.w.ctx
if state.model is not None and state.model != "SCRATCH":
path = os.path.join(ctx.config.project_root, state.model.original_file_path)
path = os.path.join(ctx.runtime_cfg.project_root, state.model.original_file_path)
with open(path, "w") as f:
_ = f.write(state.w.editor.get_content("SQL"))
print(f"Saved model to {path}")
Expand Down Expand Up @@ -179,8 +179,11 @@ def sidebar(ctx: DbtProject) -> None:
"Select a profile used for materializing, compiling, and testing models.\n\nIf you change profiles, you may need to modify the workbench query to invalidate the cache."
)
state.w.target_profile = st.radio(
f"Loaded profiles from {ctx.config.profile_name}",
[target for target in state.w.raw_profiles[ctx.config.profile_name].get("outputs", [])],
f"Loaded profiles from {ctx.runtime_cfg.profile_name}",
[
target
for target in state.w.raw_profiles[ctx.runtime_cfg.profile_name].get("outputs", [])
],
on_change=change_target,
key="target_profile",
)
Expand Down Expand Up @@ -326,14 +329,17 @@ def main():
w.ctx = create_dbt_project_context(
config=DbtConfiguration(project_dir=w.project_dir, profiles_dir=w.profiles_dir)
)
w.target_profile = w.ctx.config.target_name
w.target_profile = w.ctx.runtime_cfg.target_name
# Demo compilation hook + seed editor
w.editor.tabs[EditorTabs.SQL]["content"] = w.raw_sql
w.compiled_sql = compile(w.ctx, w.raw_sql) if w.raw_sql else ""
# Grab nodes
model_nodes: list[t.Any] = []
for node in w.ctx.manifest.nodes.values():
if node.resource_type == "model" and node.package_name == w.ctx.config.project_name:
if (
node.resource_type == "model"
and node.package_name == w.ctx.runtime_cfg.project_name
):
model_nodes.append(node)
w.model_nodes = model_nodes
w.model_opts = ["SCRATCH"] + [node for node in model_nodes]
Expand Down
2 changes: 1 addition & 1 deletion src/dbt_osmosis/workbench/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dbt-osmosis[workbench,duckdb]==1.1.4
dbt-osmosis[workbench,duckdb]==1.1.5
setuptools>=70

0 comments on commit 2a5e8e8

Please sign in to comment.