pytrilogy 0.0.2.1__py3-none-any.whl → 0.0.2.3__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.

Potentially problematic release.


This version of pytrilogy might be problematic. Click here for more details.

trilogy/parsing/render.py CHANGED
@@ -131,11 +131,15 @@ class Renderer:
131
131
  @to_string.register
132
132
  def _(self, arg: Datasource):
133
133
  assignments = ",\n\t".join([self.to_string(x) for x in arg.columns])
134
- return f"""datasource {arg.name} (
134
+ base = f"""datasource {arg.name} (
135
135
  {assignments}
136
136
  )
137
137
  {self.to_string(arg.grain)}
138
- {self.to_string(arg.address)};"""
138
+ {self.to_string(arg.address)}"""
139
+ if arg.where:
140
+ base += f"\n{self.to_string(arg.where)}"
141
+ base += ";"
142
+ return base
139
143
 
140
144
  @to_string.register
141
145
  def _(self, arg: "Grain"):
@@ -196,7 +200,7 @@ class Renderer:
196
200
 
197
201
  @to_string.register
198
202
  def _(self, arg: "ColumnAssignment"):
199
- return f"{arg.alias}:{self.to_string(arg.concept)}"
203
+ return f"{arg.alias}: {self.to_string(arg.concept)}"
200
204
 
201
205
  @to_string.register
202
206
  def _(self, arg: "ConceptDeclarationStatement"):
@@ -35,7 +35,7 @@
35
35
  prop_ident: "<" IDENTIFIER ("," IDENTIFIER )* ","? ">" "." IDENTIFIER
36
36
 
37
37
  // datasource concepts
38
- datasource: "datasource" IDENTIFIER "(" column_assignment_list ")" grain_clause? (address | query)
38
+ datasource: "datasource" IDENTIFIER "(" column_assignment_list ")" grain_clause? (address | query) where?
39
39
 
40
40
  grain_clause: "grain" "(" column_list ")"
41
41
 
@@ -274,12 +274,14 @@
274
274
  float_lit: /[0-9]*\.[0-9]+/
275
275
 
276
276
  array_lit: "[" (literal ",")* literal ","? "]"()
277
+
278
+ map_lit: "{" (literal ":" literal ",")* literal ":" literal ","? "}"
277
279
 
278
280
  !bool_lit: "True"i | "False"i
279
281
 
280
282
  !null_lit.1: "null"i
281
283
 
282
- literal: null_lit | _string_lit | int_lit | float_lit | bool_lit | array_lit
284
+ literal: null_lit | _string_lit | int_lit | float_lit | bool_lit | array_lit | map_lit
283
285
 
284
286
  MODIFIER: "Optional"i | "Partial"i | "Nullable"i
285
287
 
@@ -291,8 +293,9 @@
291
293
 
292
294
  numeric_type: "numeric"i "(" int_lit "," int_lit ")"
293
295
 
296
+ map_type: "map"i "<" data_type "," data_type ">"
294
297
 
295
- !data_type: "string"i | "number"i | "numeric"i | "map"i | "list"i | "array"i | "any"i | "int"i | "bigint"i | "date"i | "datetime"i | "timestamp"i | "float"i | "bool"i | numeric_type | struct_type | list_type
298
+ !data_type: "string"i | "number"i | "numeric"i | "map"i | "list"i | "array"i | "any"i | "int"i | "bigint"i | "date"i | "datetime"i | "timestamp"i | "float"i | "bool"i | numeric_type | map_type | struct_type | list_type
296
299
 
297
300
  PURPOSE: "key"i | "metric"i | CONST
298
301
  PROPERTY: "property"i