map-conform 0.1.0__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.
Files changed (79) hide show
  1. map_conform/__init__.py +5 -0
  2. map_conform/__main__.py +7 -0
  3. map_conform/batch/__init__.py +1 -0
  4. map_conform/batch/arrow.py +80 -0
  5. map_conform/batch/columnar.py +125 -0
  6. map_conform/batch/engine.py +191 -0
  7. map_conform/batch/files.py +207 -0
  8. map_conform/cli.py +460 -0
  9. map_conform/doctor.py +178 -0
  10. map_conform/errors.py +107 -0
  11. map_conform/expr/__init__.py +6 -0
  12. map_conform/expr/compiler.py +562 -0
  13. map_conform/expr/functions.py +542 -0
  14. map_conform/expr/sandbox.py +333 -0
  15. map_conform/expr/sdk.py +116 -0
  16. map_conform/map-conform-spec.schema.json +1204 -0
  17. map_conform/mapper.py +355 -0
  18. map_conform/metadata.py +73 -0
  19. map_conform/metrics.py +62 -0
  20. map_conform/naming/__init__.py +1 -0
  21. map_conform/naming/ascii-table.json +980 -0
  22. map_conform/naming/conform.py +262 -0
  23. map_conform/naming/flatten.py +148 -0
  24. map_conform/naming/nested.py +117 -0
  25. map_conform/naming/reserved/ansi.txt +369 -0
  26. map_conform/naming/reserved/duckdb.txt +114 -0
  27. map_conform/naming/reserved/postgres.txt +105 -0
  28. map_conform/naming/reserved/snowflake.txt +90 -0
  29. map_conform/naming/reserved.py +34 -0
  30. map_conform/naming/shape.py +96 -0
  31. map_conform/naming/streams.py +76 -0
  32. map_conform/naming/translit.py +170 -0
  33. map_conform/plan/__init__.py +1 -0
  34. map_conform/plan/chain.py +667 -0
  35. map_conform/plan/compile.py +551 -0
  36. map_conform/plan/lower.py +281 -0
  37. map_conform/plan/ops.py +336 -0
  38. map_conform/plan/row.py +212 -0
  39. map_conform/plan/vector.py +71 -0
  40. map_conform/rejects.py +92 -0
  41. map_conform/settings.py +157 -0
  42. map_conform/spec/__init__.py +1 -0
  43. map_conform/spec/_struct.py +483 -0
  44. map_conform/spec/bridge.py +109 -0
  45. map_conform/spec/check.py +380 -0
  46. map_conform/spec/errors.py +22 -0
  47. map_conform/spec/importer.py +87 -0
  48. map_conform/spec/jsonschema.py +54 -0
  49. map_conform/spec/load.py +357 -0
  50. map_conform/spec/model.py +473 -0
  51. map_conform/spec/reference.py +179 -0
  52. map_conform/spec/steps.py +297 -0
  53. map_conform/spec/stream_maps.py +233 -0
  54. map_conform/spec/zamboni.py +99 -0
  55. map_conform/transforms/__init__.py +1 -0
  56. map_conform/transforms/builtins.py +63 -0
  57. map_conform/transforms/casts.py +310 -0
  58. map_conform/transforms/fake.py +150 -0
  59. map_conform/transforms/nested.py +111 -0
  60. map_conform/transforms/numeric.py +318 -0
  61. map_conform/transforms/polars_vector.py +151 -0
  62. map_conform/transforms/privacy.py +220 -0
  63. map_conform/transforms/registry.py +116 -0
  64. map_conform/transforms/temporal.py +410 -0
  65. map_conform/transforms/text.py +249 -0
  66. map_conform/transforms/vector.py +386 -0
  67. map_conform/types/__init__.py +1 -0
  68. map_conform/types/canonical.py +255 -0
  69. map_conform/types/from_jsonschema.py +177 -0
  70. map_conform/types/jsontext.py +63 -0
  71. map_conform/types/to_arrow.py +52 -0
  72. map_conform/types/to_jsonschema.py +65 -0
  73. map_conform/types/wire.py +53 -0
  74. map_conform/udfs.py +327 -0
  75. map_conform-0.1.0.dist-info/METADATA +157 -0
  76. map_conform-0.1.0.dist-info/RECORD +79 -0
  77. map_conform-0.1.0.dist-info/WHEEL +4 -0
  78. map_conform-0.1.0.dist-info/entry_points.txt +2 -0
  79. map_conform-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,369 @@
1
+ # SQL:2016 reserved words, from PostgreSQL's doc/src/sgml/keywords/sql2016-02-reserved.txt,
2
+ # postgres/postgres at commit 9b5d4e333175 (retrieved 2026-11-22). Opt-in: it reserves
3
+ # common column names such as date, year and value. END-EXEC is left out: no conformed
4
+ # name can contain '-'.
5
+ # One lowercase word per line; matching ignores case.
6
+ abs
7
+ absent
8
+ acos
9
+ all
10
+ allocate
11
+ alter
12
+ and
13
+ any
14
+ are
15
+ array
16
+ array_agg
17
+ array_max_cardinality
18
+ as
19
+ asensitive
20
+ asin
21
+ asymmetric
22
+ at
23
+ atan
24
+ atomic
25
+ authorization
26
+ avg
27
+ begin
28
+ begin_frame
29
+ begin_partition
30
+ between
31
+ bigint
32
+ binary
33
+ blob
34
+ boolean
35
+ both
36
+ by
37
+ call
38
+ called
39
+ cardinality
40
+ cascaded
41
+ case
42
+ cast
43
+ ceil
44
+ ceiling
45
+ char
46
+ char_length
47
+ character
48
+ character_length
49
+ check
50
+ classifier
51
+ clob
52
+ close
53
+ coalesce
54
+ collate
55
+ collect
56
+ column
57
+ commit
58
+ condition
59
+ connect
60
+ constraint
61
+ contains
62
+ convert
63
+ copy
64
+ corr
65
+ corresponding
66
+ cos
67
+ cosh
68
+ count
69
+ covar_pop
70
+ covar_samp
71
+ create
72
+ cross
73
+ cube
74
+ cume_dist
75
+ current
76
+ current_catalog
77
+ current_date
78
+ current_default_transform_group
79
+ current_path
80
+ current_role
81
+ current_row
82
+ current_schema
83
+ current_time
84
+ current_timestamp
85
+ current_transform_group_for_type
86
+ current_user
87
+ cursor
88
+ cycle
89
+ date
90
+ day
91
+ deallocate
92
+ dec
93
+ decfloat
94
+ decimal
95
+ declare
96
+ default
97
+ define
98
+ delete
99
+ dense_rank
100
+ deref
101
+ describe
102
+ deterministic
103
+ disconnect
104
+ distinct
105
+ double
106
+ drop
107
+ dynamic
108
+ each
109
+ element
110
+ else
111
+ empty
112
+ end
113
+ end_frame
114
+ end_partition
115
+ equals
116
+ escape
117
+ every
118
+ except
119
+ exec
120
+ execute
121
+ exists
122
+ exp
123
+ external
124
+ extract
125
+ false
126
+ fetch
127
+ filter
128
+ first_value
129
+ float
130
+ floor
131
+ for
132
+ foreign
133
+ frame_row
134
+ free
135
+ from
136
+ full
137
+ function
138
+ fusion
139
+ get
140
+ global
141
+ grant
142
+ group
143
+ grouping
144
+ groups
145
+ having
146
+ hold
147
+ hour
148
+ identity
149
+ in
150
+ indicator
151
+ initial
152
+ inner
153
+ inout
154
+ insensitive
155
+ insert
156
+ int
157
+ integer
158
+ intersect
159
+ intersection
160
+ interval
161
+ into
162
+ is
163
+ join
164
+ json_array
165
+ json_arrayagg
166
+ json_exists
167
+ json_object
168
+ json_objectagg
169
+ json_query
170
+ json_table
171
+ json_table_primitive
172
+ json_value
173
+ lag
174
+ language
175
+ large
176
+ last_value
177
+ lateral
178
+ lead
179
+ leading
180
+ left
181
+ like
182
+ like_regex
183
+ listagg
184
+ ln
185
+ local
186
+ localtime
187
+ localtimestamp
188
+ log
189
+ log10
190
+ lower
191
+ match
192
+ match_number
193
+ match_recognize
194
+ matches
195
+ max
196
+ member
197
+ merge
198
+ method
199
+ min
200
+ minute
201
+ mod
202
+ modifies
203
+ module
204
+ month
205
+ multiset
206
+ national
207
+ natural
208
+ nchar
209
+ nclob
210
+ new
211
+ no
212
+ none
213
+ normalize
214
+ not
215
+ nth_value
216
+ ntile
217
+ null
218
+ nullif
219
+ numeric
220
+ occurrences_regex
221
+ octet_length
222
+ of
223
+ offset
224
+ old
225
+ omit
226
+ on
227
+ one
228
+ only
229
+ open
230
+ or
231
+ order
232
+ out
233
+ outer
234
+ over
235
+ overlaps
236
+ overlay
237
+ parameter
238
+ partition
239
+ pattern
240
+ per
241
+ percent
242
+ percent_rank
243
+ percentile_cont
244
+ percentile_disc
245
+ period
246
+ portion
247
+ position
248
+ position_regex
249
+ power
250
+ precedes
251
+ precision
252
+ prepare
253
+ primary
254
+ procedure
255
+ ptf
256
+ range
257
+ rank
258
+ reads
259
+ real
260
+ recursive
261
+ ref
262
+ references
263
+ referencing
264
+ regr_avgx
265
+ regr_avgy
266
+ regr_count
267
+ regr_intercept
268
+ regr_r2
269
+ regr_slope
270
+ regr_sxx
271
+ regr_sxy
272
+ regr_syy
273
+ release
274
+ result
275
+ return
276
+ returns
277
+ revoke
278
+ right
279
+ rollback
280
+ rollup
281
+ row
282
+ row_number
283
+ rows
284
+ running
285
+ savepoint
286
+ scope
287
+ scroll
288
+ search
289
+ second
290
+ seek
291
+ select
292
+ sensitive
293
+ session_user
294
+ set
295
+ show
296
+ similar
297
+ sin
298
+ sinh
299
+ skip
300
+ smallint
301
+ some
302
+ specific
303
+ specifictype
304
+ sql
305
+ sqlexception
306
+ sqlstate
307
+ sqlwarning
308
+ sqrt
309
+ start
310
+ static
311
+ stddev_pop
312
+ stddev_samp
313
+ submultiset
314
+ subset
315
+ substring
316
+ substring_regex
317
+ succeeds
318
+ sum
319
+ symmetric
320
+ system
321
+ system_time
322
+ system_user
323
+ table
324
+ tablesample
325
+ tan
326
+ tanh
327
+ then
328
+ time
329
+ timestamp
330
+ timezone_hour
331
+ timezone_minute
332
+ to
333
+ trailing
334
+ translate
335
+ translate_regex
336
+ translation
337
+ treat
338
+ trigger
339
+ trim
340
+ trim_array
341
+ true
342
+ truncate
343
+ uescape
344
+ union
345
+ unique
346
+ unknown
347
+ unnest
348
+ update
349
+ upper
350
+ user
351
+ using
352
+ value
353
+ value_of
354
+ values
355
+ var_pop
356
+ var_samp
357
+ varbinary
358
+ varchar
359
+ varying
360
+ versioning
361
+ when
362
+ whenever
363
+ where
364
+ width_bucket
365
+ window
366
+ with
367
+ within
368
+ without
369
+ year
@@ -0,0 +1,114 @@
1
+ # DuckDB keywords that cannot be bare column names: duckdb_keywords() rows with
2
+ # keyword_category 'reserved' or 'type_function', DuckDB 2.0.1 (retrieved 2026-11-22).
3
+ # One lowercase word per line; matching ignores case.
4
+ all
5
+ analyse
6
+ analyze
7
+ and
8
+ anti
9
+ any
10
+ array
11
+ as
12
+ asc
13
+ asof
14
+ asymmetric
15
+ at
16
+ authorization
17
+ binary
18
+ both
19
+ by
20
+ case
21
+ cast
22
+ check
23
+ collate
24
+ collation
25
+ column
26
+ columns
27
+ concurrently
28
+ constraint
29
+ create
30
+ cross
31
+ default
32
+ deferrable
33
+ desc
34
+ describe
35
+ distinct
36
+ do
37
+ else
38
+ end
39
+ except
40
+ false
41
+ fetch
42
+ for
43
+ foreign
44
+ freeze
45
+ from
46
+ full
47
+ generated
48
+ glob
49
+ group
50
+ having
51
+ ilike
52
+ in
53
+ initially
54
+ inner
55
+ intersect
56
+ into
57
+ is
58
+ isnull
59
+ join
60
+ lambda
61
+ lateral
62
+ leading
63
+ left
64
+ like
65
+ limit
66
+ map
67
+ natural
68
+ not
69
+ notnull
70
+ null
71
+ offset
72
+ on
73
+ only
74
+ or
75
+ order
76
+ outer
77
+ overlaps
78
+ pivot
79
+ pivot_longer
80
+ pivot_wider
81
+ placing
82
+ positional
83
+ primary
84
+ qualify
85
+ references
86
+ returning
87
+ right
88
+ select
89
+ semi
90
+ show
91
+ similar
92
+ some
93
+ struct
94
+ summarize
95
+ symmetric
96
+ table
97
+ tablesample
98
+ then
99
+ to
100
+ trailing
101
+ true
102
+ try_cast
103
+ tuple
104
+ union
105
+ unique
106
+ unpack
107
+ unpivot
108
+ using
109
+ variadic
110
+ verbose
111
+ when
112
+ where
113
+ window
114
+ with
@@ -0,0 +1,105 @@
1
+ # PostgreSQL keywords that cannot be bare column names: the RESERVED_KEYWORD and
2
+ # TYPE_FUNC_NAME_KEYWORD entries of src/include/parser/kwlist.h,
3
+ # postgres/postgres at commit 9b5d4e333175 (retrieved 2026-11-22).
4
+ # One lowercase word per line; matching ignores case.
5
+ all
6
+ analyse
7
+ analyze
8
+ and
9
+ any
10
+ array
11
+ as
12
+ asc
13
+ asymmetric
14
+ authorization
15
+ binary
16
+ both
17
+ case
18
+ cast
19
+ check
20
+ collate
21
+ collation
22
+ column
23
+ concurrently
24
+ constraint
25
+ create
26
+ cross
27
+ current_catalog
28
+ current_date
29
+ current_role
30
+ current_schema
31
+ current_time
32
+ current_timestamp
33
+ current_user
34
+ default
35
+ deferrable
36
+ desc
37
+ distinct
38
+ do
39
+ else
40
+ end
41
+ except
42
+ false
43
+ fetch
44
+ for
45
+ foreign
46
+ freeze
47
+ from
48
+ full
49
+ grant
50
+ group
51
+ having
52
+ ilike
53
+ in
54
+ initially
55
+ inner
56
+ intersect
57
+ into
58
+ is
59
+ isnull
60
+ join
61
+ lateral
62
+ leading
63
+ left
64
+ like
65
+ limit
66
+ localtime
67
+ localtimestamp
68
+ natural
69
+ not
70
+ notnull
71
+ null
72
+ offset
73
+ on
74
+ only
75
+ or
76
+ order
77
+ outer
78
+ overlaps
79
+ placing
80
+ primary
81
+ references
82
+ returning
83
+ right
84
+ select
85
+ session_user
86
+ similar
87
+ some
88
+ symmetric
89
+ system_user
90
+ table
91
+ tablesample
92
+ then
93
+ to
94
+ trailing
95
+ true
96
+ union
97
+ unique
98
+ user
99
+ using
100
+ variadic
101
+ verbose
102
+ when
103
+ where
104
+ window
105
+ with
@@ -0,0 +1,90 @@
1
+ # Snowflake reserved and limited keywords, from
2
+ # https://docs.snowflake.com/en/sql-reference/reserved-keywords (retrieved 2026-11-22).
3
+ # Left out: the eight keywords restricted only as SHOW ... IN <identifier> targets
4
+ # (account, connection, database, gscluster, issue, organization, schema, view), which
5
+ # are legal column names.
6
+ # One lowercase word per line; matching ignores case.
7
+ all
8
+ alter
9
+ and
10
+ any
11
+ as
12
+ between
13
+ by
14
+ case
15
+ cast
16
+ check
17
+ column
18
+ connect
19
+ constraint
20
+ create
21
+ cross
22
+ current
23
+ current_date
24
+ current_time
25
+ current_timestamp
26
+ current_user
27
+ delete
28
+ distinct
29
+ drop
30
+ else
31
+ exists
32
+ false
33
+ following
34
+ for
35
+ from
36
+ full
37
+ grant
38
+ group
39
+ having
40
+ ilike
41
+ in
42
+ increment
43
+ inner
44
+ insert
45
+ intersect
46
+ into
47
+ is
48
+ join
49
+ lateral
50
+ left
51
+ like
52
+ localtime
53
+ localtimestamp
54
+ minus
55
+ natural
56
+ not
57
+ null
58
+ of
59
+ on
60
+ or
61
+ order
62
+ qualify
63
+ regexp
64
+ revoke
65
+ right
66
+ rlike
67
+ row
68
+ rows
69
+ sample
70
+ select
71
+ set
72
+ some
73
+ start
74
+ table
75
+ tablesample
76
+ then
77
+ to
78
+ trigger
79
+ true
80
+ try_cast
81
+ union
82
+ unique
83
+ update
84
+ using
85
+ values
86
+ when
87
+ whenever
88
+ where
89
+ window
90
+ with
@@ -0,0 +1,34 @@
1
+ """Reserved-word lists per SQL dialect (data files in ``reserved/``).
2
+
3
+ Each list holds the words that dialect will not accept as an unquoted column name. The
4
+ sources, versions and selection rules are in each file's header. The default dialects are
5
+ postgres, duckdb and snowflake; ``ansi`` (SQL:2016) is opt-in because it reserves common
6
+ column names such as ``date``, ``year`` and ``value``.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import functools
12
+ from pathlib import Path
13
+ from typing import TYPE_CHECKING
14
+
15
+ if TYPE_CHECKING:
16
+ from collections.abc import Iterable
17
+
18
+ DATA = Path(__file__).resolve().parent / "reserved"
19
+
20
+
21
+ @functools.cache
22
+ def dialect_words(dialect: str) -> frozenset[str]:
23
+ """The reserved words of one dialect, lowercase."""
24
+ text = (DATA / f"{dialect}.txt").read_text(encoding="utf-8")
25
+ return frozenset(
26
+ line.strip().lower()
27
+ for line in text.splitlines()
28
+ if line.strip() and not line.startswith("#")
29
+ )
30
+
31
+
32
+ def reserved_words(dialects: Iterable[str]) -> frozenset[str]:
33
+ """The union of the given dialects' reserved words."""
34
+ return frozenset().union(*(dialect_words(d) for d in dialects))