snowlib 0.4.2__tar.gz → 0.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {snowlib-0.4.2 → snowlib-0.4.4}/PKG-INFO +1 -1
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/__init__.py +1 -1
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/schema.py +52 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/stage.py +21 -2
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/PKG-INFO +1 -1
- {snowlib-0.4.2 → snowlib-0.4.4}/LICENSE +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/README.md +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/licenses/THIRD_PARTY.md +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/pyproject.toml +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/setup.cfg +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/_data/connections.toml.example +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/_data/test_config.toml.example +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/__init__.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/base.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/connection.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/paths.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/connection/profiles.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/context.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/__init__.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/__init__.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/core.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/fqn.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/schema_child.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/base/show.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/column.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/database.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/__init__.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/base.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/dynamic_table.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/materialized_view.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/table.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/models/table/view.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/primitives/__init__.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/primitives/async_query.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/primitives/execute.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/primitives/result.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/py.typed +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/session.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/sqlalchemy.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/utils/identifiers.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/utils/json_columns.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/utils/query.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib/utils/schema.py +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/SOURCES.txt +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/dependency_links.txt +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/requires.txt +0 -0
- {snowlib-0.4.2 → snowlib-0.4.4}/src/snowlib.egg-info/top_level.txt +0 -0
|
@@ -23,6 +23,58 @@ class Schema(Container):
|
|
|
23
23
|
super().__init__(context)
|
|
24
24
|
self._fqn = FQN.from_parts(database, name)
|
|
25
25
|
|
|
26
|
+
@classmethod
|
|
27
|
+
def from_name(
|
|
28
|
+
cls,
|
|
29
|
+
name: str,
|
|
30
|
+
context: SnowflakeContext,
|
|
31
|
+
default_database: str | None = None,
|
|
32
|
+
default_schema: str | None = None,
|
|
33
|
+
**kwargs: object
|
|
34
|
+
) -> 'Schema':
|
|
35
|
+
"""Parse qualified name and resolve missing parts from context.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
name: Schema name in format 'DATABASE.SCHEMA' or 'SCHEMA'
|
|
39
|
+
context: SnowflakeContext to use for resolution
|
|
40
|
+
default_database: Ignored (Schema doesn't use default_database)
|
|
41
|
+
default_schema: Ignored (Schema doesn't use default_schema)
|
|
42
|
+
**kwargs: Additional arguments (ignored)
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
Schema instance
|
|
46
|
+
|
|
47
|
+
Raises:
|
|
48
|
+
ValueError: If name cannot be resolved
|
|
49
|
+
|
|
50
|
+
Examples:
|
|
51
|
+
>>> Schema.from_name("MY_DB.MY_SCHEMA", ctx)
|
|
52
|
+
>>> Schema.from_name("MY_SCHEMA", ctx) # Uses current database
|
|
53
|
+
"""
|
|
54
|
+
parts = name.split(".")
|
|
55
|
+
|
|
56
|
+
if len(parts) == 2:
|
|
57
|
+
# Fully qualified: DATABASE.SCHEMA
|
|
58
|
+
return cls(parts[0], parts[1], context)
|
|
59
|
+
|
|
60
|
+
elif len(parts) == 1:
|
|
61
|
+
# Need database from context: SCHEMA
|
|
62
|
+
db = context.current_database
|
|
63
|
+
if not db:
|
|
64
|
+
msg = (
|
|
65
|
+
f"Cannot resolve '{name}': no database in context. "
|
|
66
|
+
"Use DATABASE.SCHEMA format or USE DATABASE first."
|
|
67
|
+
)
|
|
68
|
+
raise ValueError(msg)
|
|
69
|
+
return cls(db, parts[0], context)
|
|
70
|
+
|
|
71
|
+
else:
|
|
72
|
+
msg = (
|
|
73
|
+
f"Invalid schema name '{name}'. "
|
|
74
|
+
"Expected format: 'DATABASE.SCHEMA' or 'SCHEMA'."
|
|
75
|
+
)
|
|
76
|
+
raise ValueError(msg)
|
|
77
|
+
|
|
26
78
|
@property
|
|
27
79
|
def database(self) -> 'Database':
|
|
28
80
|
"""Get parent database object"""
|
|
@@ -127,10 +127,29 @@ class Stage(SchemaChild):
|
|
|
127
127
|
auto_compress: bool = True,
|
|
128
128
|
overwrite: bool = False,
|
|
129
129
|
show_progress: bool = True,
|
|
130
|
+
prefix: Optional[str] = None,
|
|
130
131
|
) -> list[dict[str, Any]]:
|
|
131
|
-
"""Upload local files to the stage with progress bar
|
|
132
|
+
"""Upload local files to the stage with progress bar
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
files: List of local file paths to upload
|
|
136
|
+
auto_compress: Whether to automatically compress files during upload
|
|
137
|
+
overwrite: Whether to overwrite existing files in the stage
|
|
138
|
+
show_progress: Whether to show progress bar (requires tqdm)
|
|
139
|
+
prefix: Optional subdirectory path within the stage (e.g., 'courses', 'data/2024')
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
List of dicts with upload results for each file
|
|
143
|
+
"""
|
|
132
144
|
results = []
|
|
133
145
|
|
|
146
|
+
# Build target path with optional prefix
|
|
147
|
+
target_path = self.stage_path
|
|
148
|
+
if prefix:
|
|
149
|
+
# Normalize prefix (strip leading/trailing slashes)
|
|
150
|
+
prefix = prefix.strip('/')
|
|
151
|
+
target_path = f"{self.stage_path}/{prefix}"
|
|
152
|
+
|
|
134
153
|
iterator = tqdm(files, desc="Uploading") if (show_progress and HAS_TQDM and tqdm is not None) else files
|
|
135
154
|
|
|
136
155
|
for file_path in iterator:
|
|
@@ -142,7 +161,7 @@ class Stage(SchemaChild):
|
|
|
142
161
|
})
|
|
143
162
|
continue
|
|
144
163
|
|
|
145
|
-
sql = f"PUT 'file://{file_path.as_posix()}' {
|
|
164
|
+
sql = f"PUT 'file://{file_path.as_posix()}' {target_path}"
|
|
146
165
|
sql += f" AUTO_COMPRESS = {str(auto_compress).upper()}"
|
|
147
166
|
sql += f" OVERWRITE = {str(overwrite).upper()}"
|
|
148
167
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|