sql-glider 0.1.15__py3-none-any.whl → 0.1.16__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sql-glider
3
- Version: 0.1.15
3
+ Version: 0.1.16
4
4
  Summary: SQL Utility Toolkit for better understanding, use, and governance of your queries in a native environment.
5
5
  Project-URL: Homepage, https://github.com/rycowhi/sql-glider/
6
6
  Project-URL: Repository, https://github.com/rycowhi/sql-glider/
@@ -1,5 +1,5 @@
1
1
  sqlglider/__init__.py,sha256=gDf7s52dMcX7JuCZ1SLawcB1vb3U0yJCohu9RQAATBY,125
2
- sqlglider/_version.py,sha256=HPqQHR9pVxIxlFt4vovkyoe7k6UO3ag2isBN2lHFL8g,706
2
+ sqlglider/_version.py,sha256=Fs2Vm6Mr4ZbSKXw60jeeSx9iEU9elx4fQcMl_5xXMJI,706
3
3
  sqlglider/cli.py,sha256=9zNMaw3rgcqb6uG05VJTYbLUXmZzdX87gAOJ4Zg3xjY,65319
4
4
  sqlglider/global_models.py,sha256=2vyJXAuXOsXQpE-D3F0ejj7eR9z0nDWFjTkielhzM8k,356
5
5
  sqlglider/catalog/__init__.py,sha256=2PqFPyzFXJ14FpSUcBmVK2L-a_ypWQHAbHFHxLDk_LE,814
@@ -18,7 +18,7 @@ sqlglider/graph/models.py,sha256=EYmjv_WzDSNp_WfhJ6H-qBIOkAcoNKS7GRUryfKrHuY,933
18
18
  sqlglider/graph/query.py,sha256=LHU8Cvn7ZPPSEnqdDn2pF8f1_LQjIvNIrZqs8cFlb6U,9433
19
19
  sqlglider/graph/serialization.py,sha256=vMXn7s35jA499e7l90vNVaJE_3QR_VHf3rEfQ9ZlgTQ,2781
20
20
  sqlglider/lineage/__init__.py,sha256=llXMeI5_PIZaiBo8tKk3-wOubF4m_6QBHbn1FtWxT7k,256
21
- sqlglider/lineage/analyzer.py,sha256=08pFR5aGFFPhSbRW6EqiX2d3mp91v-orcs6dm_T1FJg,76484
21
+ sqlglider/lineage/analyzer.py,sha256=ECgzl-aW8C1m_YsRXAKt5WRuOajLnXl-DD1bd0mcbg8,78106
22
22
  sqlglider/lineage/formatters.py,sha256=_Y9wcTX4JXn1vVnZ1xI656g1FF2rMjcAVc-GHjbd9QA,10389
23
23
  sqlglider/schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  sqlglider/schema/extractor.py,sha256=WW31wbHkL-V749pLb7EAyUOJuziZQK-5hLZVW6f970U,7234
@@ -31,8 +31,8 @@ sqlglider/utils/__init__.py,sha256=KGp9-UzKz_OFBOTFoSy-g-NXDZsvyWXG_9-1zcC6ePE,2
31
31
  sqlglider/utils/config.py,sha256=qx5zE9pjLCCzHQDFVPLVd7LgJ-lghxUa2x-aZOAHByY,4962
32
32
  sqlglider/utils/file_utils.py,sha256=5_ff28E0r1R7emZzsOnRuHd-7zIX6873eyr1SuPEr4E,1093
33
33
  sqlglider/utils/schema.py,sha256=-0Vd1A3EggBH3reXTiabO0zFeTENROgmDg861X1D7Qs,1867
34
- sql_glider-0.1.15.dist-info/METADATA,sha256=IF0dZD6rOriyausbDZhHPMfYnhHyRlxyi9v_ihTgCUo,28446
35
- sql_glider-0.1.15.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
36
- sql_glider-0.1.15.dist-info/entry_points.txt,sha256=HDuakHqHS5C0HFKsMIxMYmDU7-BLBGrnIJcYaVRu-s0,251
37
- sql_glider-0.1.15.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
- sql_glider-0.1.15.dist-info/RECORD,,
34
+ sql_glider-0.1.16.dist-info/METADATA,sha256=P9b4NwGmYzw96orLy9RyBHaoN05ut3kBXMOCUCl05B8,28446
35
+ sql_glider-0.1.16.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
36
+ sql_glider-0.1.16.dist-info/entry_points.txt,sha256=HDuakHqHS5C0HFKsMIxMYmDU7-BLBGrnIJcYaVRu-s0,251
37
+ sql_glider-0.1.16.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
38
+ sql_glider-0.1.16.dist-info/RECORD,,
sqlglider/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.1.15'
32
- __version_tuple__ = version_tuple = (0, 1, 15)
31
+ __version__ = version = '0.1.16'
32
+ __version_tuple__ = version_tuple = (0, 1, 16)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -11,6 +11,48 @@ from sqlglot.lineage import Node, lineage
11
11
  from sqlglider.global_models import AnalysisLevel
12
12
 
13
13
 
14
+ def _flat_schema_to_nested(
15
+ schema: Dict[str, Dict[str, str]],
16
+ ) -> Dict[str, object]:
17
+ """Convert flat dot-notation schema keys to the nested dict structure sqlglot expects.
18
+
19
+ sqlglot's MappingSchema requires consistent nesting depth across all tables.
20
+ Flat keys like ``"db.table"`` are split on dots and nested accordingly.
21
+ Shorter keys are padded with empty-string prefixes to match the max depth.
22
+
23
+ Examples::
24
+
25
+ {"users": {"id": "UNKNOWN"}}
26
+ → {"users": {"id": "UNKNOWN"}} (depth 1, no change)
27
+
28
+ {"db.users": {"id": "UNKNOWN"}, "my_view": {"x": "UNKNOWN"}}
29
+ → {"db": {"users": {"id": "UNKNOWN"}}, "": {"my_view": {"x": "UNKNOWN"}}}
30
+ """
31
+ if not schema:
32
+ return {}
33
+
34
+ # Split all keys into parts
35
+ entries = [(key.split("."), cols) for key, cols in schema.items()]
36
+ max_depth = max(len(parts) for parts, _ in entries)
37
+
38
+ # If all keys are single-part (unqualified), return as-is
39
+ if max_depth == 1:
40
+ return schema # type: ignore[return-value]
41
+
42
+ # Pad shorter keys with empty-string prefixes to match max depth
43
+ nested: Dict[str, object] = {}
44
+ for parts, cols in entries:
45
+ while len(parts) < max_depth:
46
+ parts.insert(0, "")
47
+ d: Dict[str, object] = nested
48
+ for part in parts[:-1]:
49
+ if part not in d:
50
+ d[part] = {}
51
+ d = d[part] # type: ignore[assignment]
52
+ d[parts[-1]] = cols
53
+ return nested
54
+
55
+
14
56
  class StarResolutionError(Exception):
15
57
  """Raised when SELECT * cannot be resolved and no_star mode is enabled."""
16
58
 
@@ -860,8 +902,10 @@ class LineageAnalyzer:
860
902
  current_query_sql = self.expr.sql(dialect=self.dialect)
861
903
 
862
904
  # Prune schema to only tables referenced in this query to avoid
863
- # sqlglot.lineage() performance degradation with large schema dicts
864
- pruned_schema: Optional[Dict[str, Dict[str, str]]] = None
905
+ # sqlglot.lineage() performance degradation with large schema dicts.
906
+ # Then convert from flat dot-notation keys to the nested dict structure
907
+ # that sqlglot's MappingSchema expects.
908
+ lineage_schema: Optional[Dict[str, object]] = None
865
909
  if self._file_schema:
866
910
  referenced = {t.lower() for t in self._get_query_tables()}
867
911
  pruned_schema = {
@@ -869,8 +913,8 @@ class LineageAnalyzer:
869
913
  for table, cols in self._file_schema.items()
870
914
  if table.lower() in referenced
871
915
  }
872
- if not pruned_schema:
873
- pruned_schema = None
916
+ if pruned_schema:
917
+ lineage_schema = _flat_schema_to_nested(pruned_schema)
874
918
 
875
919
  for col in columns_to_analyze:
876
920
  try:
@@ -883,7 +927,7 @@ class LineageAnalyzer:
883
927
  lineage_col,
884
928
  current_query_sql,
885
929
  dialect=self.dialect,
886
- schema=pruned_schema,
930
+ schema=lineage_schema,
887
931
  )
888
932
 
889
933
  # Collect all source columns