@malloydata/render 0.0.264 → 0.0.265-dev250416031350

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.
@@ -119517,10 +119517,28 @@ var J$ = {}, rp = {}, Qle = {};
119517
119517
  }
119518
119518
  }
119519
119519
  }, x = {
119520
+ extract: {
119521
+ takes: {
119522
+ input_val: "string",
119523
+ pattern: ["string", "regular expression"]
119524
+ },
119525
+ returns: "string",
119526
+ impl: { function: "regexp_extract" }
119527
+ },
119528
+ extract_group: {
119529
+ takes: {
119530
+ input_val: "string",
119531
+ pattern: ["string", "regular expression"],
119532
+ group: "number"
119533
+ },
119534
+ returns: "string",
119535
+ impl: { function: "regexp_extract" }
119536
+ }
119537
+ }, h = {
119520
119538
  takes: {},
119521
119539
  returns: { calculation: "number" },
119522
119540
  impl: { function: "PERCENT_RANK", needsWindowOrderBy: !0 }
119523
- }, h = {
119541
+ }, p = {
119524
119542
  skip_nulls: {
119525
119543
  takes: {
119526
119544
  array_v: { array: r },
@@ -119540,7 +119558,7 @@ var J$ = {}, rp = {}, Qle = {};
119540
119558
  returns: "string",
119541
119559
  impl: { function: "ARRAY_JOIN" }
119542
119560
  }
119543
- }, p = {
119561
+ }, m = {
119544
119562
  num_to_num: {
119545
119563
  takes: { start: "number", stop: "number" },
119546
119564
  returns: { array: "number" },
@@ -119556,14 +119574,14 @@ var J$ = {}, rp = {}, Qle = {};
119556
119574
  returns: { array: "date" },
119557
119575
  impl: { function: "SEQUENCE" }
119558
119576
  }
119559
- }, m = {
119577
+ }, g = {
119560
119578
  takes: { str: "string" },
119561
119579
  returns: "string",
119562
119580
  impl: { sql: "REVERSE(CAST(${str} AS VARCHAR))" }
119563
119581
  };
119564
119582
  t.TRINO_DIALECT_FUNCTIONS = {
119565
119583
  // string functions
119566
- reverse: m,
119584
+ reverse: g,
119567
119585
  // aggregate functions
119568
119586
  // TODO: Approx percentile can be called with a third argument; we probably
119569
119587
  // want to implement that at some point
@@ -119638,8 +119656,10 @@ var J$ = {}, rp = {}, Qle = {};
119638
119656
  date_parse: a,
119639
119657
  ...(0, e.def)("from_unixtime", { unixtime: "number" }, "timestamp"),
119640
119658
  json_extract_scalar: l,
119659
+ // regex fnctions
119641
119660
  regexp_like: c,
119642
119661
  regexp_replace: f,
119662
+ regexp_extract: x,
119643
119663
  ...(0, e.def)("to_unixtime", { ts_val: "timestamp" }, "number"),
119644
119664
  ...(0, e.def)("url_extract_fragment", { url: "string" }, "string"),
119645
119665
  ...(0, e.def)("url_extract_host", { url: "string" }, "string"),
@@ -119649,10 +119669,10 @@ var J$ = {}, rp = {}, Qle = {};
119649
119669
  ...(0, e.def)("url_extract_protocol", { url: "string" }, "string"),
119650
119670
  ...(0, e.def)("url_extract_query", { url: "string" }, "string"),
119651
119671
  // window functions
119652
- percent_rank: x,
119672
+ percent_rank: h,
119653
119673
  // array function
119654
- array_join: h,
119655
- sequence: p,
119674
+ array_join: p,
119675
+ sequence: m,
119656
119676
  ...(0, e.def)("array_distinct", { x: { array: r } }, { array: r }),
119657
119677
  ...(0, e.def)("array_except", { x: { array: r }, y: { array: r } }, { array: r }),
119658
119678
  ...(0, e.def)("array_intersect", { x: { array: r }, y: { array: r } }, { array: r }),
@@ -119673,6 +119693,7 @@ var J$ = {}, rp = {}, Qle = {};
119673
119693
  ...(0, e.def)("repeat", { x: r, n: "number" }, { array: r }),
119674
119694
  ...(0, e.def)("slice", { x: { array: r }, start: "number", len: "number" }, { array: r }),
119675
119695
  ...(0, e.def)("split", { to_split: "string", seperator: "string" }, { array: "string" }),
119696
+ ...(0, e.def)("split_part", { to_split: "string", seperator: "string", idx: "number" }, "string"),
119676
119697
  ...(0, e.def)("trim_array", { x: { array: r }, n: "number" }, { array: r }),
119677
119698
  ...(0, e.def)("array_split_into_chunks", { x: { array: r }, n: "number" }, { array: { array: r } })
119678
119699
  }, t.PRESTO_DIALECT_FUNCTIONS = {
@@ -119705,7 +119726,7 @@ var J$ = {}, rp = {}, Qle = {};
119705
119726
  }
119706
119727
  },
119707
119728
  reverse: {
119708
- string_reverse: m,
119729
+ string_reverse: g,
119709
119730
  ...(0, e.def)("reverse", { x: { array: r } }, { array: r })
119710
119731
  },
119711
119732
  ...(0, e.def)("array_average", { x: { array: r } }, "number"),
@@ -149366,7 +149387,7 @@ yp.malloyToQuery = Lxt;
149366
149387
  var we = {}, u6 = {};
149367
149388
  Object.defineProperty(u6, "__esModule", { value: !0 });
149368
149389
  u6.MALLOY_VERSION = void 0;
149369
- u6.MALLOY_VERSION = "0.0.264";
149390
+ u6.MALLOY_VERSION = "0.0.265";
149370
149391
  Object.defineProperty(we, "__esModule", { value: !0 });
149371
149392
  we.InMemoryModelCache = we.CacheManager = we.CSVWriter = we.JSONWriter = we.DataWriter = we.DataRecord = we.DataArray = we.Result = we.ExploreMaterializer = we.PreparedResultMaterializer = we.QueryMaterializer = we.ModelMaterializer = we.SingleConnectionRuntime = we.ConnectionRuntime = we.Runtime = we.ExploreField = we.JoinRelationship = we.QueryField = we.Query = we.StringField = we.UnsupportedField = we.JSONField = we.BooleanField = we.NumberField = we.TimestampField = we.DateField = we.TimestampTimeframe = we.DateTimeframe = we.AtomicField = we.AtomicFieldType = we.Explore = we.SourceRelationship = we.FixedConnectionMap = we.InMemoryURLReader = we.EmptyURLReader = we.PreparedResult = we.DocumentCompletion = we.DocumentSymbol = we.DocumentPosition = we.DocumentRange = we.DocumentTablePath = we.Parse = we.PreparedQuery = we.Model = we.MalloyError = we.Malloy = void 0;
149372
149393
  const eY = xT, Xr = ji, tY = zy, E7 = x2, Ixt = u6, Bxt = d2, In = ui, $xt = Il, nY = "internal://internal.malloy";
@@ -891,7 +891,7 @@ ${(0,YKe.indent)(r)}
891
891
  EXTRACT('epoch_${s}', ${i.sql}) - EXTRACT('epoch_${s}', ${r.sql}),
892
892
  '1970-01-01 00:00:00'::TIMESTAMP_NTZ
893
893
  )
894
- )`}sqlRegexpMatch(e){return`REGEXP_INSTR(${e.kids.expr.sql}, ${e.kids.regex.sql}) != 0`}sqlSampleTable(e,r){if(r!==void 0){if((0,Ns.isSamplingEnable)(r)&&r.enable&&(r=this.defaultSampling),(0,Ns.isSamplingRows)(r))return`(SELECT * FROM ${e} TABLESAMPLE (${r.rows} ROWS))`;if((0,Ns.isSamplingPercent)(r))return`(SELECT * FROM ${e} TABLESAMPLE (${r.percent}))`}return e}sqlOrderBy(e){return`ORDER BY ${e.map(r=>`${r} NULLS LAST`).join(",")}`}sqlLiteralString(e){return"'"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"}sqlLiteralRegexp(e){return"'"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"}getDialectFunctionOverrides(){return(0,Xue.expandOverrideMap)(JKe.SNOWFLAKE_MALLOY_STANDARD_OVERLOADS)}getDialectFunctions(){return(0,Xue.expandBlueprintMap)(KKe.SNOWFLAKE_DIALECT_FUNCTIONS)}malloyTypeToSQLType(e){if(e.type==="string")return"VARCHAR";if(e.type==="number")return e.numberType==="integer"?"INTEGER":"DOUBLE";if(e.type==="record"||(0,Ns.isRepeatedRecord)(e)){const i=`OBJECT(${e.fields.reduce((s,o)=>{var u;if((0,Ns.isAtomic)(o)){const a=(u=o.as)!==null&&u!==void 0?u:o.name,l=`${this.sqlMaybeQuoteIdentifier(a)} ${this.malloyTypeToSQLType(o)}`;s.push(l)}return s},[]).join(",")})`;return e.type==="record"?i:`ARRAY(${i})`}else if((0,Ns.isBasicArray)(e))return`ARRAY(${this.malloyTypeToSQLType(e.elementTypeDef)})`;return e.type}sqlTypeToMalloyType(e){var r,i;const s=(i=(r=e.match(/^([\w\s]+)/))===null||r===void 0?void 0:r.at(0))!==null&&i!==void 0?i:e;return ZKe[s.trim().toLowerCase()]||{type:"sql native",rawType:e}}castToString(e){return`TO_VARCHAR(${e})`}concat(...e){return e.join(" || ")}validateTypeName(e){return e.match(/^[A-Za-z\s(),[\]0-9]*$/)!==null}sqlLiteralRecord(e){var r,i;const s=[];for(const o of e.typeDef.fields){const u=(r=o.as)!==null&&r!==void 0?r:o.name,a=`'${u}'`,l=(i=e.kids[u].sql)!==null&&i!==void 0?i:"internal-error-record-literal";s.push(`${a},${l}`)}return`OBJECT_CONSTRUCT_KEEP_NULL(${s.join(",")})`}sqlLiteralArray(e){return`[${e.kids.values.map(s=>s.sql).join(",")}]`}}O4.SnowflakeDialect=eJe,function(t){var e=T&&T.__createBinding||(Object.create?function(i,s,o,u){u===void 0&&(u=o);var a=Object.getOwnPropertyDescriptor(s,o);(!a||("get"in a?!s.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return s[o]}}),Object.defineProperty(i,u,a)}:function(i,s,o,u){u===void 0&&(u=o),i[u]=s[o]}),r=T&&T.__exportStar||function(i,s){for(var o in i)o!=="default"&&!Object.prototype.hasOwnProperty.call(s,o)&&e(s,i,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(O4,t)}(qB);var QB={},jp={},Zue={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.PRESTO_DIALECT_FUNCTIONS=t.TRINO_DIALECT_FUNCTIONS=void 0;const e=ot,r={generic:"T"},i={generic:{T:["string","number","date","timestamp","boolean","json"]},takes:{value:{dimension:r},order_by_val:{dimension:"any"}},returns:{measure:r},impl:{function:"MAX_BY"},isSymmetric:!0},s={generic:{T:["string","number","date","timestamp","boolean","json"]},takes:{value:{dimension:r},order_by_val:{dimension:"any"}},returns:{measure:r},impl:{function:"MIN_BY"},isSymmetric:!0},o={default_separator:{takes:{value:{dimension:"string"}},returns:{measure:"string"},supportsOrderBy:!0,impl:{sql:"ARRAY_JOIN(ARRAY_AGG(${value} ${order_by:}), ',')"}},with_separator:{takes:{value:{dimension:"string"},separator:{literal:"string"}},returns:{measure:"string"},supportsOrderBy:!0,impl:{sql:"ARRAY_JOIN(ARRAY_AGG(${value} ${order_by:}), ${separator})"}}},u={default_separator:{...o.default_separator,isSymmetric:!0,impl:{sql:"ARRAY_JOIN(ARRAY_AGG(DISTINCT ${value} ${order_by:}), ',')"}},with_separator:{...o.with_separator,isSymmetric:!0,impl:{sql:"ARRAY_JOIN(ARRAY_AGG(DISTINCT ${value} ${order_by:}), ${separator})"}}},a={takes:{ts_string:"string",format:"string"},returns:"timestamp",impl:{sql:"DATE_PARSE(${ts_string}, ${format})"}},l={takes:{json_val:"string",json_path:"string"},returns:"string",impl:{function:"JSON_EXTRACT_SCALAR"}},c={takes:{str:"string",pattern:["string","regular expression"]},returns:"boolean",impl:{function:"REGEXP_LIKE"}},f={remove_matches:{takes:{input_val:"string",regexp_pattern:["string","regular expression"]},returns:"string",impl:{function:"REGEXP_REPLACE"}},replace_matches:{takes:{input_val:"string",regexp_pattern:["string","regular expression"],replacement:"string"},returns:"string",impl:{function:"REGEXP_REPLACE"}}},x={takes:{},returns:{calculation:"number"},impl:{function:"PERCENT_RANK",needsWindowOrderBy:!0}},h={skip_nulls:{takes:{array_v:{array:r},sep:"string"},generic:{T:["any"]},returns:"string",impl:{function:"ARRAY_JOIN"}},null_aware:{takes:{array_v:r,sep:"string",nullStr:"string"},generic:{T:["any"]},returns:"string",impl:{function:"ARRAY_JOIN"}}},p={num_to_num:{takes:{start:"number",stop:"number"},returns:{array:"number"},impl:{function:"SEQUENCE"}},num_to_num_step:{takes:{start:"number",stop:"number",step:"number"},returns:{array:"number"},impl:{function:"SEQUENCE"}},date_to_date:{takes:{start:"date",stop:"date"},returns:{array:"date"},impl:{function:"SEQUENCE"}}},m={takes:{str:"string"},returns:"string",impl:{sql:"REVERSE(CAST(${str} AS VARCHAR))"}};t.TRINO_DIALECT_FUNCTIONS={reverse:m,...(0,e.def)("approx_percentile",{value:"number",percentage:"number"},{measure:"number"}),...(0,e.def)("arbitrary",{value:{dimension:r}},{measure:r},{generic:{T:["string","number","date","timestamp","boolean","json"]}}),...(0,e.def)("bitwise_and_agg",{value:{dimension:"number"}},{measure:"number"},{isSymmetric:!0}),...(0,e.def)("bitwise_or_agg",{value:{dimension:"number"}},{measure:"number"},{isSymmetric:!0}),...(0,e.def)("bitwise_xor_agg",{value:{dimension:"number"}},{measure:"number"},{isSymmetric:!0}),...(0,e.def)("bool_and",{value:{dimension:"boolean"}},{measure:"boolean"}),...(0,e.def)("bool_or",{value:{dimension:"boolean"}},{measure:"boolean"}),...(0,e.def)("corr",{y:{dimension:"number"},x:{dimension:"number"}},{measure:"number"}),...(0,e.def)("count_approx",{value:{dimension:"any"}},{measure:"number"},{impl:{function:"APPROX_DISTINCT"},isSymmetric:!0}),hll_accumulate:{default:{takes:{value:{dimension:r}},returns:{measure:{sql_native:"hyperloglog"}},generic:{T:["string","number","date","timestamp","boolean","json"]},isSymmetric:!0,impl:{function:"APPROX_SET"}},with_percent:{takes:{value:{dimension:r},accuracy:"number"},returns:{measure:{sql_native:"hyperloglog"}},generic:{T:["string","number","date","timestamp","boolean","json"]},isSymmetric:!0,impl:{function:"APPROX_SET"}}},hll_combine:{takes:{value:{sql_native:"hyperloglog"}},returns:{measure:{sql_native:"hyperloglog"}},impl:{function:"MERGE"},isSymmetric:!0},hll_estimate:{takes:{value:{sql_native:"hyperloglog"}},returns:{dimension:"number"},impl:{function:"CARDINALITY"}},hll_export:{takes:{value:{sql_native:"hyperloglog"}},returns:{dimension:{sql_native:"varbinary"}},impl:{sql:"CAST(${value} AS VARBINARY)"}},hll_import:{takes:{value:{sql_native:"varbinary"}},returns:{dimension:{sql_native:"hyperloglog"}},impl:{sql:"CAST(${value} AS HyperLogLog)"}},max_by:i,min_by:s,string_agg:o,string_agg_distinct:u,...(0,e.def)("variance",{n:"number"},{measure:"number"}),...(0,e.def)("bitwise_and",{val1:"number",val2:"number"},"number"),...(0,e.def)("bitwise_or",{val1:"number",val2:"number"},"number"),...(0,e.def)("date_format",{ts_val:"timestamp",format:"string"},"string"),date_parse:a,...(0,e.def)("from_unixtime",{unixtime:"number"},"timestamp"),json_extract_scalar:l,regexp_like:c,regexp_replace:f,...(0,e.def)("to_unixtime",{ts_val:"timestamp"},"number"),...(0,e.def)("url_extract_fragment",{url:"string"},"string"),...(0,e.def)("url_extract_host",{url:"string"},"string"),...(0,e.def)("url_extract_parameter",{url:"string",parameter:"string"},"string"),...(0,e.def)("url_extract_path",{url:"string"},"string"),...(0,e.def)("url_extract_port",{url:"string"},"number"),...(0,e.def)("url_extract_protocol",{url:"string"},"string"),...(0,e.def)("url_extract_query",{url:"string"},"string"),percent_rank:x,array_join:h,sequence:p,...(0,e.def)("array_distinct",{x:{array:r}},{array:r}),...(0,e.def)("array_except",{x:{array:r},y:{array:r}},{array:r}),...(0,e.def)("array_intersect",{x:{array:r},y:{array:r}},{array:r}),...(0,e.def)("array_max",{x:{array:r}},r),...(0,e.def)("array_min",{x:{array:r}},r),...(0,e.def)("array_normalize",{x:{array:r},p:"number"},{array:r}),...(0,e.def)("array_remove",{x:{array:r},element:r},{array:r}),...(0,e.def)("array_sort",{x:{array:r}},{array:r}),...(0,e.def)("arrays_overlap",{x:{array:r},y:{array:r}},"boolean"),...(0,e.def)("array_union",{x:{array:r},y:{array:r}},{array:r}),...(0,e.def)("cardinality",{x:{array:r}},"number"),...(0,e.def)("shuffle",{x:{array:r}},{array:r}),...(0,e.def)("combinations",{x:{array:r},n:"number"},{array:{array:r}}),...(0,e.def)("contains",{x:{array:r},element:r},"boolean"),...(0,e.def)("element_at",{x:{array:r},oridnal:"number"},r),...(0,e.def)("flatten",{x:{array:{array:r}}},{array:r}),...(0,e.def)("ngrams",{x:{array:r},n:"number"},{array:{array:r}}),...(0,e.def)("repeat",{x:r,n:"number"},{array:r}),...(0,e.def)("slice",{x:{array:r},start:"number",len:"number"},{array:r}),...(0,e.def)("split",{to_split:"string",seperator:"string"},{array:"string"}),...(0,e.def)("trim_array",{x:{array:r},n:"number"},{array:r}),...(0,e.def)("array_split_into_chunks",{x:{array:r},n:"number"},{array:{array:r}})},t.PRESTO_DIALECT_FUNCTIONS={...t.TRINO_DIALECT_FUNCTIONS,array_intersect:{...(0,e.def)("array_intersect",{x:{array:r},y:{array:r}},{array:r}),nested_array:{takes:{x:{array:{array:r}}},generic:{T:["any"]},returns:{array:r},impl:{function:"ARRAY_INTERSECT"}}},array_least_frequent:{...(0,e.def)("array_least_frequent",{x:{array:r}},{array:r}),bottom_n:{takes:{array_v:{array:r},n:"number"},returns:{array:r},generic:{T:["any"]},impl:{function:"ARRAY_LEAST_FREQUENT"}}},array_position:{...(0,e.def)("array_position",{x:{array:r},el:r},"number"),nth_instance:{takes:{x:{array:r},el:r,instance:"number"},generic:{T:["any"]},returns:"number",impl:{function:"ARRAY_POSITION"}}},reverse:{string_reverse:m,...(0,e.def)("reverse",{x:{array:r}},{array:r})},...(0,e.def)("array_average",{x:{array:r}},"number"),...(0,e.def)("array_has_duplicates",{x:{array:r}},"boolean"),...(0,e.def)("array_cum_sum",{numeric_array:{array:r}},{array:"number"}),...(0,e.def)("array_duplicates",{x:{array:r}},{array:r}),...(0,e.def)("array_sum",{x:{array:r}},"number"),...(0,e.def)("array_sort_desc",{x:{array:r}},{array:r}),...(0,e.def)("remove_nulls",{x:{array:r}},{array:r}),...(0,e.def)("array_top_n",{x:{array:r},n:"number"},{array:r})}})(Zue);var L4={};Object.defineProperty(L4,"__esModule",{value:!0}),L4.TRINO_MALLOY_STANDARD_OVERLOADS=void 0;const zB=ot;L4.TRINO_MALLOY_STANDARD_OVERLOADS={byte_length:{sql:"(LENGTH(CAST(${value} AS VARBINARY)))"},chr:{sql:"CASE WHEN ${value} = 0 THEN '' ELSE CHR(${value}) END"},ascii:{sql:"CODEPOINT(NULLIF(CAST(${value} as VARCHAR(1)),''))"},unicode:{sql:"CODEPOINT(NULLIF(CAST(${value} as VARCHAR(1)),''))"},concat:{variadic:{expr:(0,zB.sql)`CONCAT(${(0,zB.spread)((0,zB.arg)("values"),"CAST(","AS VARCHAR)")})`}},div:{sql:"FLOOR(${dividend} / ${divisor})"},ifnull:{sql:"COALESCE(${value}, ${default})"},is_inf:{sql:"COALESCE(IS_INFINITE(${value}), false)"},log:{sql:"(LN(${value}) / LN(${base}))"},string_repeat:{sql:"ARRAY_JOIN(REPEAT(${value}, CASE WHEN ${value} IS NOT NULL THEN ${count} END),'')"},starts_with:{sql:"COALESCE(STARTS_WITH(${value}, ${prefix}), false)"},ends_with:{sql:"COALESCE(STARTS_WITH(REVERSE(CAST(${value} AS VARCHAR)), REVERSE(CAST(${suffix} AS VARCHAR))), false)"},trunc:{to_integer:{sql:"CASE WHEN ${value} < 0 THEN CEIL(${value}) ELSE FLOOR(${value}) END"},to_precision:{sql:"CASE WHEN ${value} < 0 THEN CEIL(${value} * POW(10, ${precision})) / POW(10, ${precision}) ELSE FLOOR(${value} * POW(10, ${precision})) / POW(10, ${precision}) END"}}},Object.defineProperty(jp,"__esModule",{value:!0}),jp.PrestoDialect=jp.TrinoDialect=void 0;const eae=Bt,go=Xe,GB=vc,tae=C4,nae=Zue,tJe=L4;function nJe(t){return["microsecond","millisecond","second","minute","hour","day"].includes(t)}function WB(t){const e=t.queryTimezone;if(e&&e!=="UTC")return e}const rJe={varchar:{type:"string"},integer:{type:"number",numberType:"integer"},bigint:{type:"number",numberType:"integer"},smallint:{type:"number",numberType:"integer"},tinyint:{type:"number",numberType:"integer"},double:{type:"number",numberType:"float"},decimal:{type:"number",numberType:"float"},string:{type:"string"},date:{type:"date"},timestamp:{type:"timestamp"},boolean:{type:"boolean"}};class Cc extends tae.PostgresBase{constructor(){super(...arguments),this.name="trino",this.experimental=!1,this.defaultNumberType="DOUBLE",this.defaultDecimalType="DECIMAL",this.udfPrefix="__udf",this.hasFinalStage=!1,this.divisionIsInteger=!0,this.supportsSumDistinctFunction=!0,this.unnestWithNumbers=!1,this.defaultSampling={enable:!1},this.supportUnnestArrayAgg=!1,this.supportsAggDistinct=!1,this.supportsCTEinCoorelatedSubQueries=!1,this.dontUnionIndex=!0,this.supportsQualify=!0,this.supportsSafeCast=!0,this.supportsNesting=!0,this.cantPartitionWindowFunctionsOnExpressions=!1,this.orderByClause="output_name",this.nullMatchesFunctionSignature=!1,this.supportsSelectReplace=!1,this.supportsComplexFilteredSources=!1,this.supportsTempTables=!1,this.supportsCountApprox=!0,this.supportsHyperLogLog=!0,this.keywords=`
894
+ )`}sqlRegexpMatch(e){return`REGEXP_INSTR(${e.kids.expr.sql}, ${e.kids.regex.sql}) != 0`}sqlSampleTable(e,r){if(r!==void 0){if((0,Ns.isSamplingEnable)(r)&&r.enable&&(r=this.defaultSampling),(0,Ns.isSamplingRows)(r))return`(SELECT * FROM ${e} TABLESAMPLE (${r.rows} ROWS))`;if((0,Ns.isSamplingPercent)(r))return`(SELECT * FROM ${e} TABLESAMPLE (${r.percent}))`}return e}sqlOrderBy(e){return`ORDER BY ${e.map(r=>`${r} NULLS LAST`).join(",")}`}sqlLiteralString(e){return"'"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"}sqlLiteralRegexp(e){return"'"+e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"}getDialectFunctionOverrides(){return(0,Xue.expandOverrideMap)(JKe.SNOWFLAKE_MALLOY_STANDARD_OVERLOADS)}getDialectFunctions(){return(0,Xue.expandBlueprintMap)(KKe.SNOWFLAKE_DIALECT_FUNCTIONS)}malloyTypeToSQLType(e){if(e.type==="string")return"VARCHAR";if(e.type==="number")return e.numberType==="integer"?"INTEGER":"DOUBLE";if(e.type==="record"||(0,Ns.isRepeatedRecord)(e)){const i=`OBJECT(${e.fields.reduce((s,o)=>{var u;if((0,Ns.isAtomic)(o)){const a=(u=o.as)!==null&&u!==void 0?u:o.name,l=`${this.sqlMaybeQuoteIdentifier(a)} ${this.malloyTypeToSQLType(o)}`;s.push(l)}return s},[]).join(",")})`;return e.type==="record"?i:`ARRAY(${i})`}else if((0,Ns.isBasicArray)(e))return`ARRAY(${this.malloyTypeToSQLType(e.elementTypeDef)})`;return e.type}sqlTypeToMalloyType(e){var r,i;const s=(i=(r=e.match(/^([\w\s]+)/))===null||r===void 0?void 0:r.at(0))!==null&&i!==void 0?i:e;return ZKe[s.trim().toLowerCase()]||{type:"sql native",rawType:e}}castToString(e){return`TO_VARCHAR(${e})`}concat(...e){return e.join(" || ")}validateTypeName(e){return e.match(/^[A-Za-z\s(),[\]0-9]*$/)!==null}sqlLiteralRecord(e){var r,i;const s=[];for(const o of e.typeDef.fields){const u=(r=o.as)!==null&&r!==void 0?r:o.name,a=`'${u}'`,l=(i=e.kids[u].sql)!==null&&i!==void 0?i:"internal-error-record-literal";s.push(`${a},${l}`)}return`OBJECT_CONSTRUCT_KEEP_NULL(${s.join(",")})`}sqlLiteralArray(e){return`[${e.kids.values.map(s=>s.sql).join(",")}]`}}O4.SnowflakeDialect=eJe,function(t){var e=T&&T.__createBinding||(Object.create?function(i,s,o,u){u===void 0&&(u=o);var a=Object.getOwnPropertyDescriptor(s,o);(!a||("get"in a?!s.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return s[o]}}),Object.defineProperty(i,u,a)}:function(i,s,o,u){u===void 0&&(u=o),i[u]=s[o]}),r=T&&T.__exportStar||function(i,s){for(var o in i)o!=="default"&&!Object.prototype.hasOwnProperty.call(s,o)&&e(s,i,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(O4,t)}(qB);var QB={},jp={},Zue={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.PRESTO_DIALECT_FUNCTIONS=t.TRINO_DIALECT_FUNCTIONS=void 0;const e=ot,r={generic:"T"},i={generic:{T:["string","number","date","timestamp","boolean","json"]},takes:{value:{dimension:r},order_by_val:{dimension:"any"}},returns:{measure:r},impl:{function:"MAX_BY"},isSymmetric:!0},s={generic:{T:["string","number","date","timestamp","boolean","json"]},takes:{value:{dimension:r},order_by_val:{dimension:"any"}},returns:{measure:r},impl:{function:"MIN_BY"},isSymmetric:!0},o={default_separator:{takes:{value:{dimension:"string"}},returns:{measure:"string"},supportsOrderBy:!0,impl:{sql:"ARRAY_JOIN(ARRAY_AGG(${value} ${order_by:}), ',')"}},with_separator:{takes:{value:{dimension:"string"},separator:{literal:"string"}},returns:{measure:"string"},supportsOrderBy:!0,impl:{sql:"ARRAY_JOIN(ARRAY_AGG(${value} ${order_by:}), ${separator})"}}},u={default_separator:{...o.default_separator,isSymmetric:!0,impl:{sql:"ARRAY_JOIN(ARRAY_AGG(DISTINCT ${value} ${order_by:}), ',')"}},with_separator:{...o.with_separator,isSymmetric:!0,impl:{sql:"ARRAY_JOIN(ARRAY_AGG(DISTINCT ${value} ${order_by:}), ${separator})"}}},a={takes:{ts_string:"string",format:"string"},returns:"timestamp",impl:{sql:"DATE_PARSE(${ts_string}, ${format})"}},l={takes:{json_val:"string",json_path:"string"},returns:"string",impl:{function:"JSON_EXTRACT_SCALAR"}},c={takes:{str:"string",pattern:["string","regular expression"]},returns:"boolean",impl:{function:"REGEXP_LIKE"}},f={remove_matches:{takes:{input_val:"string",regexp_pattern:["string","regular expression"]},returns:"string",impl:{function:"REGEXP_REPLACE"}},replace_matches:{takes:{input_val:"string",regexp_pattern:["string","regular expression"],replacement:"string"},returns:"string",impl:{function:"REGEXP_REPLACE"}}},x={extract:{takes:{input_val:"string",pattern:["string","regular expression"]},returns:"string",impl:{function:"regexp_extract"}},extract_group:{takes:{input_val:"string",pattern:["string","regular expression"],group:"number"},returns:"string",impl:{function:"regexp_extract"}}},h={takes:{},returns:{calculation:"number"},impl:{function:"PERCENT_RANK",needsWindowOrderBy:!0}},p={skip_nulls:{takes:{array_v:{array:r},sep:"string"},generic:{T:["any"]},returns:"string",impl:{function:"ARRAY_JOIN"}},null_aware:{takes:{array_v:r,sep:"string",nullStr:"string"},generic:{T:["any"]},returns:"string",impl:{function:"ARRAY_JOIN"}}},m={num_to_num:{takes:{start:"number",stop:"number"},returns:{array:"number"},impl:{function:"SEQUENCE"}},num_to_num_step:{takes:{start:"number",stop:"number",step:"number"},returns:{array:"number"},impl:{function:"SEQUENCE"}},date_to_date:{takes:{start:"date",stop:"date"},returns:{array:"date"},impl:{function:"SEQUENCE"}}},g={takes:{str:"string"},returns:"string",impl:{sql:"REVERSE(CAST(${str} AS VARCHAR))"}};t.TRINO_DIALECT_FUNCTIONS={reverse:g,...(0,e.def)("approx_percentile",{value:"number",percentage:"number"},{measure:"number"}),...(0,e.def)("arbitrary",{value:{dimension:r}},{measure:r},{generic:{T:["string","number","date","timestamp","boolean","json"]}}),...(0,e.def)("bitwise_and_agg",{value:{dimension:"number"}},{measure:"number"},{isSymmetric:!0}),...(0,e.def)("bitwise_or_agg",{value:{dimension:"number"}},{measure:"number"},{isSymmetric:!0}),...(0,e.def)("bitwise_xor_agg",{value:{dimension:"number"}},{measure:"number"},{isSymmetric:!0}),...(0,e.def)("bool_and",{value:{dimension:"boolean"}},{measure:"boolean"}),...(0,e.def)("bool_or",{value:{dimension:"boolean"}},{measure:"boolean"}),...(0,e.def)("corr",{y:{dimension:"number"},x:{dimension:"number"}},{measure:"number"}),...(0,e.def)("count_approx",{value:{dimension:"any"}},{measure:"number"},{impl:{function:"APPROX_DISTINCT"},isSymmetric:!0}),hll_accumulate:{default:{takes:{value:{dimension:r}},returns:{measure:{sql_native:"hyperloglog"}},generic:{T:["string","number","date","timestamp","boolean","json"]},isSymmetric:!0,impl:{function:"APPROX_SET"}},with_percent:{takes:{value:{dimension:r},accuracy:"number"},returns:{measure:{sql_native:"hyperloglog"}},generic:{T:["string","number","date","timestamp","boolean","json"]},isSymmetric:!0,impl:{function:"APPROX_SET"}}},hll_combine:{takes:{value:{sql_native:"hyperloglog"}},returns:{measure:{sql_native:"hyperloglog"}},impl:{function:"MERGE"},isSymmetric:!0},hll_estimate:{takes:{value:{sql_native:"hyperloglog"}},returns:{dimension:"number"},impl:{function:"CARDINALITY"}},hll_export:{takes:{value:{sql_native:"hyperloglog"}},returns:{dimension:{sql_native:"varbinary"}},impl:{sql:"CAST(${value} AS VARBINARY)"}},hll_import:{takes:{value:{sql_native:"varbinary"}},returns:{dimension:{sql_native:"hyperloglog"}},impl:{sql:"CAST(${value} AS HyperLogLog)"}},max_by:i,min_by:s,string_agg:o,string_agg_distinct:u,...(0,e.def)("variance",{n:"number"},{measure:"number"}),...(0,e.def)("bitwise_and",{val1:"number",val2:"number"},"number"),...(0,e.def)("bitwise_or",{val1:"number",val2:"number"},"number"),...(0,e.def)("date_format",{ts_val:"timestamp",format:"string"},"string"),date_parse:a,...(0,e.def)("from_unixtime",{unixtime:"number"},"timestamp"),json_extract_scalar:l,regexp_like:c,regexp_replace:f,regexp_extract:x,...(0,e.def)("to_unixtime",{ts_val:"timestamp"},"number"),...(0,e.def)("url_extract_fragment",{url:"string"},"string"),...(0,e.def)("url_extract_host",{url:"string"},"string"),...(0,e.def)("url_extract_parameter",{url:"string",parameter:"string"},"string"),...(0,e.def)("url_extract_path",{url:"string"},"string"),...(0,e.def)("url_extract_port",{url:"string"},"number"),...(0,e.def)("url_extract_protocol",{url:"string"},"string"),...(0,e.def)("url_extract_query",{url:"string"},"string"),percent_rank:h,array_join:p,sequence:m,...(0,e.def)("array_distinct",{x:{array:r}},{array:r}),...(0,e.def)("array_except",{x:{array:r},y:{array:r}},{array:r}),...(0,e.def)("array_intersect",{x:{array:r},y:{array:r}},{array:r}),...(0,e.def)("array_max",{x:{array:r}},r),...(0,e.def)("array_min",{x:{array:r}},r),...(0,e.def)("array_normalize",{x:{array:r},p:"number"},{array:r}),...(0,e.def)("array_remove",{x:{array:r},element:r},{array:r}),...(0,e.def)("array_sort",{x:{array:r}},{array:r}),...(0,e.def)("arrays_overlap",{x:{array:r},y:{array:r}},"boolean"),...(0,e.def)("array_union",{x:{array:r},y:{array:r}},{array:r}),...(0,e.def)("cardinality",{x:{array:r}},"number"),...(0,e.def)("shuffle",{x:{array:r}},{array:r}),...(0,e.def)("combinations",{x:{array:r},n:"number"},{array:{array:r}}),...(0,e.def)("contains",{x:{array:r},element:r},"boolean"),...(0,e.def)("element_at",{x:{array:r},oridnal:"number"},r),...(0,e.def)("flatten",{x:{array:{array:r}}},{array:r}),...(0,e.def)("ngrams",{x:{array:r},n:"number"},{array:{array:r}}),...(0,e.def)("repeat",{x:r,n:"number"},{array:r}),...(0,e.def)("slice",{x:{array:r},start:"number",len:"number"},{array:r}),...(0,e.def)("split",{to_split:"string",seperator:"string"},{array:"string"}),...(0,e.def)("split_part",{to_split:"string",seperator:"string",idx:"number"},"string"),...(0,e.def)("trim_array",{x:{array:r},n:"number"},{array:r}),...(0,e.def)("array_split_into_chunks",{x:{array:r},n:"number"},{array:{array:r}})},t.PRESTO_DIALECT_FUNCTIONS={...t.TRINO_DIALECT_FUNCTIONS,array_intersect:{...(0,e.def)("array_intersect",{x:{array:r},y:{array:r}},{array:r}),nested_array:{takes:{x:{array:{array:r}}},generic:{T:["any"]},returns:{array:r},impl:{function:"ARRAY_INTERSECT"}}},array_least_frequent:{...(0,e.def)("array_least_frequent",{x:{array:r}},{array:r}),bottom_n:{takes:{array_v:{array:r},n:"number"},returns:{array:r},generic:{T:["any"]},impl:{function:"ARRAY_LEAST_FREQUENT"}}},array_position:{...(0,e.def)("array_position",{x:{array:r},el:r},"number"),nth_instance:{takes:{x:{array:r},el:r,instance:"number"},generic:{T:["any"]},returns:"number",impl:{function:"ARRAY_POSITION"}}},reverse:{string_reverse:g,...(0,e.def)("reverse",{x:{array:r}},{array:r})},...(0,e.def)("array_average",{x:{array:r}},"number"),...(0,e.def)("array_has_duplicates",{x:{array:r}},"boolean"),...(0,e.def)("array_cum_sum",{numeric_array:{array:r}},{array:"number"}),...(0,e.def)("array_duplicates",{x:{array:r}},{array:r}),...(0,e.def)("array_sum",{x:{array:r}},"number"),...(0,e.def)("array_sort_desc",{x:{array:r}},{array:r}),...(0,e.def)("remove_nulls",{x:{array:r}},{array:r}),...(0,e.def)("array_top_n",{x:{array:r},n:"number"},{array:r})}})(Zue);var L4={};Object.defineProperty(L4,"__esModule",{value:!0}),L4.TRINO_MALLOY_STANDARD_OVERLOADS=void 0;const zB=ot;L4.TRINO_MALLOY_STANDARD_OVERLOADS={byte_length:{sql:"(LENGTH(CAST(${value} AS VARBINARY)))"},chr:{sql:"CASE WHEN ${value} = 0 THEN '' ELSE CHR(${value}) END"},ascii:{sql:"CODEPOINT(NULLIF(CAST(${value} as VARCHAR(1)),''))"},unicode:{sql:"CODEPOINT(NULLIF(CAST(${value} as VARCHAR(1)),''))"},concat:{variadic:{expr:(0,zB.sql)`CONCAT(${(0,zB.spread)((0,zB.arg)("values"),"CAST(","AS VARCHAR)")})`}},div:{sql:"FLOOR(${dividend} / ${divisor})"},ifnull:{sql:"COALESCE(${value}, ${default})"},is_inf:{sql:"COALESCE(IS_INFINITE(${value}), false)"},log:{sql:"(LN(${value}) / LN(${base}))"},string_repeat:{sql:"ARRAY_JOIN(REPEAT(${value}, CASE WHEN ${value} IS NOT NULL THEN ${count} END),'')"},starts_with:{sql:"COALESCE(STARTS_WITH(${value}, ${prefix}), false)"},ends_with:{sql:"COALESCE(STARTS_WITH(REVERSE(CAST(${value} AS VARCHAR)), REVERSE(CAST(${suffix} AS VARCHAR))), false)"},trunc:{to_integer:{sql:"CASE WHEN ${value} < 0 THEN CEIL(${value}) ELSE FLOOR(${value}) END"},to_precision:{sql:"CASE WHEN ${value} < 0 THEN CEIL(${value} * POW(10, ${precision})) / POW(10, ${precision}) ELSE FLOOR(${value} * POW(10, ${precision})) / POW(10, ${precision}) END"}}},Object.defineProperty(jp,"__esModule",{value:!0}),jp.PrestoDialect=jp.TrinoDialect=void 0;const eae=Bt,go=Xe,GB=vc,tae=C4,nae=Zue,tJe=L4;function nJe(t){return["microsecond","millisecond","second","minute","hour","day"].includes(t)}function WB(t){const e=t.queryTimezone;if(e&&e!=="UTC")return e}const rJe={varchar:{type:"string"},integer:{type:"number",numberType:"integer"},bigint:{type:"number",numberType:"integer"},smallint:{type:"number",numberType:"integer"},tinyint:{type:"number",numberType:"integer"},double:{type:"number",numberType:"float"},decimal:{type:"number",numberType:"float"},string:{type:"string"},date:{type:"date"},timestamp:{type:"timestamp"},boolean:{type:"boolean"}};class Cc extends tae.PostgresBase{constructor(){super(...arguments),this.name="trino",this.experimental=!1,this.defaultNumberType="DOUBLE",this.defaultDecimalType="DECIMAL",this.udfPrefix="__udf",this.hasFinalStage=!1,this.divisionIsInteger=!0,this.supportsSumDistinctFunction=!0,this.unnestWithNumbers=!1,this.defaultSampling={enable:!1},this.supportUnnestArrayAgg=!1,this.supportsAggDistinct=!1,this.supportsCTEinCoorelatedSubQueries=!1,this.dontUnionIndex=!0,this.supportsQualify=!0,this.supportsSafeCast=!0,this.supportsNesting=!0,this.cantPartitionWindowFunctionsOnExpressions=!1,this.orderByClause="output_name",this.nullMatchesFunctionSignature=!1,this.supportsSelectReplace=!1,this.supportsComplexFilteredSources=!1,this.supportsTempTables=!1,this.supportsCountApprox=!0,this.supportsHyperLogLog=!0,this.keywords=`
895
895
  ALL
896
896
  AND
897
897
  ANY
@@ -1463,7 +1463,7 @@ xyyzz{{||}}~~~Ҳ
1463
1463
  | ${c}`,a>0&&(s=s+`
1464
1464
  | ${" ".repeat(a)}^`)}else s=`line ${u+1}: char ${a}: ${i.message}`}r!==o&&(s=`FILE: ${o}
1465
1465
  `+s,r=o),e!==""?e=`${e}
1466
- ${s}`:e=s}return e}childRequest(e){var r;const i=decodeURI(new URL(e,this.sourceURL).toString()),s=(r=this.childTranslators.get(i))===null||r===void 0?void 0:r.translate();if(s!=null&&s.compileSQL)return{compileSQL:s.compileSQL}}getChildExports(e){const r={},i=decodeURI(new URL(e,this.sourceURL).toString()),s=this.childTranslators.get(i);if(s&&s.translate().modelDef)for(const u of s.modelDef.exports){const a=s.modelDef.contents[u];((0,Sft.isSourceDef)(a)||a.type==="query")&&(r[u]=a)}return r}translate(e){if(this.finalAnswer)return this.finalAnswer;const r=this.translateStep.step(this,e);return r.final&&(this.finalAnswer=r),r}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let r=0;r<this.imports.length;r++){const i=this.imports[r];if((0,kM.locationContainsPosition)(i.location,e))return i}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return(0,kM.rangeFromContext)(this.parseStep.sourceInfo,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const r=this.compilerFlags.tag("experimental");return r!==void 0&&(r.bare()||r.has("dialect",e))}}Tc.MalloyTranslation=MM;class Qfe extends MM{constructor(e,r){super(e),this.root=r}}Tc.MalloyChildTranslator=Qfe;class zft extends MM{constructor(e,r=null,i=null,s=null){super(e,r),this.eventStream=s,this.schemaZone=new $M.Zone,this.importZone=new $M.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new $M.Zone,this.root=this,this.logger=new Hfe.BaseMessageLogger(s),i&&this.update(i)}update(e){var r,i,s;this.schemaZone.updateFrom(e.tables,(r=e.errors)===null||r===void 0?void 0:r.tables),this.importZone.updateFrom(e.urls,(i=e.errors)===null||i===void 0?void 0:i.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(s=e.errors)===null||s===void 0?void 0:s.compileSQL);for(const o in e.translations)this.pretranslatedModels.set(o,e.translations[o])}logError(e,r,i){return this.logger.log((0,Hfe.makeLogMessage)(e,r,{severity:"error",...i})),e}}Tc.MalloyTranslator=zft;function zfe(t){return[...Object.keys(t),...Object.keys(t).map(e=>zfe(t[e])).flat()]}var T2={};Object.defineProperty(T2,"__esModule",{value:!0}),T2.exploreQueryWalkerBuilder=T2.ExploreQueryWalker=void 0;const Gft=uc;class Gfe{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}filterAtOffset(e){const r=this.exploreQueryAtOffset(e);if(r)return r.filterRefs.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e)}hasFilterListAtOffset(e){const r=this.exploreQueryAtOffset(e);return r?!!r.filterLists.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}T2.ExploreQueryWalker=Gfe;function Wft(t,e){const r=new Gfe(t),i=r;return Gft.ParseTreeWalker.DEFAULT.walk(i,e),r}T2.exploreQueryWalkerBuilder=Wft;var R2={},mE={},La={};Object.defineProperty(La,"__esModule",{value:!0}),La.getResultStructMetadataAnnotation=La.convertFieldInfos=La.modelDefToModelInfo=void 0;const Ia=Pi,PM=Ls,UM=ui,Wfe=Zo;function Vft(t){const e={entries:[],anonymous_queries:[]};for(const[r,i]of Object.entries(t.contents))if(t.exports.includes(r)){if((0,Ia.isSourceDef)(i)){const s=i.parameters&&Object.entries(i.parameters).length>0?Object.entries(i.parameters).map(([u,a])=>(0,Ia.isAtomic)(a)?{name:u,type:vR(a),default_value:Vfe(a.value)}:{name:u,type:{kind:"filter_expression_type"},default_value:Vfe(a.value)}):void 0,o={kind:"source",name:r,schema:{fields:D2(i,i.fields)},parameters:s,annotations:jM(i)};e.entries.push(o)}else if(i.type==="query"){const s=(0,PM.getResultStructDefForQuery)(t,i),o=jM(i),u=s.resultMetadata?_R(s,s.resultMetadata):void 0,a=[...o??[],...u?[u]:[]],l={kind:"source",name:r,schema:{fields:D2(s,s.fields)},annotations:a.length>0?a:void 0};e.entries.push(l)}}for(const r of t.queryList){const i=(0,PM.getResultStructDefForQuery)(t,r),s=jM(r),o=i.resultMetadata?_R(i,i.resultMetadata):void 0,u=[...s??[],...o?[o]:[]],a={schema:{fields:D2(i,i.fields)},annotations:u.length>0?u:void 0};e.anonymous_queries.push(a)}return e}La.modelDefToModelInfo=Vft;function Vfe(t){if(t!==null)switch(t.node){case"numberLiteral":return{kind:"number_literal",number_value:parseFloat(t.literal)};case"stringLiteral":return{kind:"string_literal",string_value:t.literal};case"filterLiteral":return{kind:"filter_expression_literal",filter_expression_value:t.filterSrc};case"timeLiteral":return{kind:"timestamp_literal",timestamp_value:t.literal};case"true":return{kind:"boolean_literal",boolean_value:!0};case"false":return{kind:"boolean_literal",boolean_value:!1};case"null":return{kind:"null_literal"};default:throw new Error("Invalid parameter default value")}}function jM(t){return(0,UM.annotationToTaglines)(t.annotation).map(r=>({value:r}))}function D2(t,e){var r,i,s;const o=[];for(const u of e){if(!(u.accessModifier===void 0))continue;const c=(0,UM.annotationToTaglines)(u.annotation).map(x=>({value:x})),f=c.length>0?c:void 0;if((0,Ia.isTurtle)(u)){const x=(0,PM.getResultStructDefForView)(t,u),h=x.resultMetadata?_R(x,x.resultMetadata):void 0,p=[...f??[],...h?[h]:[]],m={kind:"view",name:(r=u.as)!==null&&r!==void 0?r:u.name,annotations:p.length>0?p:void 0,schema:{fields:D2(x,x.fields)}};o.push(m)}else if((0,Ia.isAtomic)(u)){const x=(0,Ia.expressionIsAggregate)(u.expressionType),h=(0,Ia.expressionIsScalar)(u.expressionType);if(!x&&!h||u.type==="error")continue;const p=u.resultMetadata?Yfe(u,u.resultMetadata):void 0,m=[...f??[],...p?[p]:[]],g={kind:x?"measure":"dimension",name:(i=u.as)!==null&&i!==void 0?i:u.name,type:vR(u),annotations:m.length>0?m:void 0};o.push(g)}else if((0,Ia.isJoinedSource)(u)){const x={kind:"join",name:(s=u.as)!==null&&s!==void 0?s:u.name,annotations:f,schema:{fields:D2(u,u.fields)},relationship:u.join};o.push(x)}}return o}La.convertFieldInfos=D2;function Yfe(t,e){const r=Wfe.Tag.withPrefix("#(malloy) ");let i=!1;if(e.referenceId!==void 0&&(r.set(["reference_id"],e.referenceId),i=!0),e.fieldKind==="measure"&&(r.set(["calculation"]),i=!0),e.filterList){const s=e.filterList.filter(o=>o.expressionType==="scalar").map(o=>o.code);r.set(["drill_filters"],s),i=!0}if(e.fieldKind==="dimension"){const o=(e==null?void 0:e.sourceExpression)||(e!=null&&e.sourceField.includes(".")?e==null?void 0:e.sourceField:Kft(t.name));r.set(["drill_expression"],o),i=!0}return i?{value:r.toString()}:void 0}function Yft(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}function Kft(t){return t.match(/^[A-Za-z_][0-9A-Za-z_]*$/)?t:`\`${Yft(t)}\``}function _R(t,e){var r,i;const s=Wfe.Tag.withPrefix("#(malloy) ");let o=!1;if(e.limit!==void 0&&(s.set(["limit"],e.limit),o=!0),e.filterList){const u=e.filterList.filter(a=>a.expressionType==="scalar").map(a=>a.code);u.length>0&&(s.set(["drill_filters"],u),o=!0)}if(e.orderBy){for(let u=0;u<e.orderBy.length;u++){const a=e.orderBy[u],l=typeof a.field=="number"?(r=t.fields[a.field-1].as)!==null&&r!==void 0?r:t.fields[a.field-1].name:a.field,c=(i=a.dir)!==null&&i!==void 0?i:null;s.set(["ordered_by",u,l],c)}o=!0}return o?{value:s.toString()}:void 0}La.getResultStructMetadataAnnotation=_R;function vR(t){if((0,Ia.isBasicAtomic)(t))switch(t.type){case"string":return{kind:"string_type"};case"number":return{kind:"number_type",subtype:t.numberType==="float"?"decimal":t.numberType==="integer"?"integer":void 0};case"boolean":return{kind:"boolean_type"};case"date":{const e=t.timeframe;return e&&!Jft(e)?{kind:"timestamp_type",timeframe:t.timeframe}:{kind:"date_type",timeframe:Xft(t.timeframe)}}case"timestamp":return{kind:"timestamp_type",timeframe:t.timeframe};case"json":return{kind:"json_type"};case"sql native":return{kind:"sql_native_type",sql_type:t.rawType};case"error":throw new Error("Error type is not supported in stable interface")}else{if((0,Ia.isRepeatedRecord)(t))return{kind:"array_type",element_type:Kfe(t)};if(t.type==="record")return Kfe(t);if(t.type==="array")return{kind:"array_type",element_type:vR(t.elementTypeDef)}}throw new Error("Unexpected field type")}function Kfe(t){return{kind:"record_type",fields:t.fields.map(e=>{const r=[];if("resultMetadata"in e&&e.resultMetadata){const i=Yfe(e,e.resultMetadata);i&&r.push(i)}if(e.annotation){const i=(0,UM.annotationToTaglines)(e.annotation);r.push(...i.map(s=>({value:s})))}if((0,Ia.isAtomic)(e))return{name:e.name,annotations:r.length>0?r:void 0,type:vR(e)};throw new Error("Expected record type to not have a table as its child")})}}function Jft(t){switch(t){case"day":case"week":case"month":case"year":case"quarter":return!0;default:return!1}}function Xft(t){switch(t){case void 0:return;case"day":case"week":case"month":case"year":case"quarter":return t;default:throw new Error(`Invalid date timeframe ${t}`)}}function hht(t){return t}function pht(t){return t}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.mapLogs=t.DEFAULT_LOG_RANGE=t.wrapResult=t.mapData=t.wrapLegacyConnection=t.wrapLegacyInfoConnection=void 0;const e=Zo,r=ui,i=La,s=by;function o(x){return{get dialectName(){return x.dialectName},async fetchSchemaForSQLQuery(h){const p=await x.fetchSchemaForSQLStruct({connection:x.name,selectStr:h},{}),m=p.structDef;if(m===void 0)throw new Error(p.error);return{fields:(0,i.convertFieldInfos)(m,m.fields)}},async fetchSchemaForTable(h){const p=`${x.name}:${h}`,m=await x.fetchSchemaForTables({[p]:h},{}),g=m.schemas[p];if(g===void 0)throw new Error(m.errors[p]);return{fields:(0,i.convertFieldInfos)(g,g.fields)}}}}t.wrapLegacyInfoConnection=o;function u(x){return{...o(x),runSQL:async(h,p)=>{const m=await x.runSQL(h);return l(m.rows,p)}}}t.wrapLegacyConnection=u;function a(x){if(x instanceof Date)return x;if(x.constructor.name==="Date")return new Date(x);if(typeof x=="number")return new Date(x);if(typeof x!="string")return new Date(x.value);{let p=s.DateTime.fromISO(x,{zone:"UTC"});return p.isValid||(p=s.DateTime.fromSQL(x,{zone:"UTC"})),p.toJSDate()}}function l(x,h){function p(y,E){if(y===null)return{kind:"null_cell"};if(E.type.kind==="date_type"||E.type.kind==="timestamp_type"){const A=a(y).toISOString();return E.type.kind==="date_type"?{kind:"date_cell",date_value:A}:{kind:"timestamp_cell",timestamp_value:A}}else if(E.type.kind==="boolean_type"){if(typeof y=="number")return{kind:"boolean_cell",boolean_value:y!==0};if(typeof y!="boolean")throw new Error(`Invalid boolean ${y}`);return{kind:"boolean_cell",boolean_value:y}}else if(E.type.kind==="number_type"){if(typeof y!="number")throw new Error(`Invalid number ${y}`);return{kind:"number_cell",number_value:y}}else if(E.type.kind==="string_type"){if(typeof y!="string")throw new Error(`Invalid string ${y}`);return{kind:"string_cell",string_value:y}}else if(E.type.kind==="array_type"){if(!Array.isArray(y))throw new Error(`Invalid array ${y}`);return{kind:"array_cell",array_value:y.map(A=>p(A,{name:"array_element",type:E.type.element_type}))}}else{if(E.type.kind==="json_type")return{kind:"json_cell",json_value:JSON.stringify(y)};if(E.type.kind==="sql_native_type")return{kind:"sql_native_cell",sql_native_value:JSON.stringify(y)};{const A=E.type;if(A.kind!=="record_type")throw new Error(`Invalid record in result ${JSON.stringify(E)}, ${JSON.stringify(y)}`);return m(y,{kind:"join",relationship:"many",name:"array_element",schema:{fields:A.fields.map(_=>({kind:"dimension",..._}))}})}}}function m(y,E){const A=[];for(const _ of E.schema.fields){const v=y[_.name];if(_.kind!=="dimension")throw new Error("Invalid result -- expected all fields to be dimensions");const C=p(v,_);A.push(C)}return{kind:"record_cell",record_value:A}}const g={kind:"join",schema:h,name:"root",relationship:"one"};return{kind:"array_cell",array_value:x.map(y=>m(y,g))}}t.mapData=l;function c(x){const h=x._queryResult.structs,p=h[h.length-1],m={fields:(0,i.convertFieldInfos)(p,p.fields)},g=(0,r.annotationToTaglines)(x.annotation).map(E=>({value:E})),y=p.resultMetadata?(0,i.getResultStructMetadataAnnotation)(p,p.resultMetadata):void 0;return y&&g.push(y),g.push(...p.resultMetadata?[]:[]),x.sourceExplore&&g.push({value:e.Tag.withPrefix("#(malloy) ").set(["source_name"],x.sourceExplore.name).toString()}),g.push({value:e.Tag.withPrefix("#(malloy) ").set(["query_name"],x.resultExplore.name).toString()}),{schema:m,data:l(x.data.toObject(),m),connection_name:x.connectionName,annotations:g.length>0?g:void 0,query_timezone:x.data.field.queryTimezone}}t.wrapResult=c,t.DEFAULT_LOG_RANGE={start:{line:0,character:0},end:{line:0,character:0}};function f(x,h){return x.map(p=>{var m,g,y,E;return{severity:p.severity,message:p.message,range:(g=(m=p.at)===null||m===void 0?void 0:m.range)!==null&&g!==void 0?g:t.DEFAULT_LOG_RANGE,url:(E=(y=p.at)===null||y===void 0?void 0:y.url)!==null&&E!==void 0?E:h}})}t.mapLogs=f})(mE);var Zft=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),ext=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),txt=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Zft(e,t,r);return ext(e,t),e};Object.defineProperty(R2,"__esModule",{value:!0}),R2.malloyToQuery=R2.MalloyToQuery=void 0;const nxt=Kh,On=txt(w),Jfe=Yp,gE=Bn,rxt=Xe,ixt=aE,Xfe=Vn,sxt=mE,qM="Malloy query documents";class Zfe extends nxt.AbstractParseTreeVisitor{constructor(e,r){super(),this.parseInfo=e,this.msgLog=r}internalError(e,r){return this.contextError(e,"internal-translator-error",{message:r}),new Error(`Internal Translator Error: ${r}`)}getLocation(e){return{url:this.parseInfo.sourceURL,range:(0,Xfe.rangeFromContext)(this.parseInfo.sourceInfo,e)}}contextError(e,r,i,s){this.msgLog.log((0,Jfe.makeLogMessage)(r,i,{at:this.getLocation(e),...s}))}getNumber(e){return Number.parseInt(e.text)}defaultResult(){return null}getAnnotations(e){const r=e.ANNOTATION().map(i=>({value:i.text}));return r.length>0?r:void 0}getIsAnnotations(e){var r,i;if(e===void 0)return;const o=((r=this.getAnnotations(e._beforeIs))!==null&&r!==void 0?r:[]).concat((i=this.getAnnotations(e._afterIs))!==null&&i!==void 0?i:[]);return o.length>0?o:void 0}notAllowed(e,r){this.illegal(e,`${r} are not allowed in ${qM}`)}illegal(e,r){this.contextError(e,"invalid-malloy-query-document",r)}visitMalloyDocument(e){const r=e.malloyStatement();let i;for(const s of r)s.defineSourceStatement()?this.notAllowed(s,"Source definitions"):s.defineQuery()?this.notAllowed(s,"Query definitions"):s.importStatement()?this.notAllowed(s,"Import statements"):s.docAnnotations()?this.notAllowed(s,"Model annotations"):s.ignoredObjectAnnotations()?this.notAllowed(s,"Detatched object annotations"):s.experimentalStatementForTesting()?this.notAllowed(s,"Experimental testing statements"):i===void 0?i=s.runStatement():this.illegal(s,`${qM} may only have one run statement`);return i===void 0?(this.illegal(e,`${qM} must have a run statement`),null):this.visitRunStatement(i)}visitRunStatement(e){const r=e.topLevelAnonQueryDef(),i=this.getQueryDefinition(r.sqExpr()),s=this.getAnnotations(e.topLevelAnonQueryDef().tags());return i!==null?{annotations:s,definition:i}:null}getQueryReference(e){if(e.sourceArguments())this.illegal(e,"Queries do not support parameters");else return{name:(0,gE.getId)(e)};return null}getQueryDefinition(e){if(e instanceof On.SQIDContext){const r=this.getQueryReference(e);if(r!==null)return{kind:"query_reference",...r}}else{if(e instanceof On.SQParensContext)return this.getQueryDefinition(e.sqExpr());if(e instanceof On.SQComposeContext)this.notAllowed(e,"Source compositions");else if(e instanceof On.SQRefinedQueryContext){const r=e.sqExpr(),i=this.getQueryDefinition(r),s=this.getRefinementSegment(e.segExpr());return s===null||i===null?null:(s.kind==="arrow"&&this.notAllowed(e,"Queries against refined queries"),{kind:"refinement",base:i,refinement:s})}else if(e instanceof On.SQExtendedSourceContext)this.notAllowed(e,"Source extensions");else if(e instanceof On.SQIncludeContext)this.notAllowed(e,"Source inclusions");else if(e instanceof On.SQTableContext)this.notAllowed(e,"Table statements");else if(e instanceof On.SQSQLContext)this.notAllowed(e,"SQL statements");else if(e instanceof On.SQArrowContext){const r=e.sqExpr(),i=this.getQueryDefinition(r),s=this.getRefinementSegment(e.segExpr());return s===null||i===null?null:i.kind==="query_reference"?{kind:"arrow",source:{...i,kind:"source_reference"},view:s}:i.kind==="arrow"?{kind:"arrow",source:i.source,view:{kind:"arrow",source:i.view,view:s}}:{kind:"arrow",source:i,view:s}}}return null}getRefinementSegment(e){if(e instanceof On.SegOpsContext){const r=e.queryProperties().queryStatement().flatMap(i=>this.getSegmentOperation(i));return r.some(i=>i===null)?null:{kind:"segment",operations:r}}else if(e instanceof On.SegFieldContext){const{name:r,path:i}=this.getFieldPath(e.fieldPath());return{kind:"view_reference",name:r,path:i}}else{if(e instanceof On.SegParenContext)return this.getViewExpression(e.vExpr());if(e instanceof On.SegRefineContext){const r=this.getRefinementSegment(e._lhs),i=this.getRefinementSegment(e._rhs);return r===null||i===null?null:{kind:"refinement",base:r,refinement:i}}}return null}getGroupByStatement(e){const r=this.getAnnotations(e.tags()),s=e.queryFieldList().queryFieldEntry().map(o=>this.getQueryField(o));return s.some(o=>o===null)||s===null?null:s.map(o=>{var u;const a=[...r??[],...(u=o.field.annotations)!==null&&u!==void 0?u:[]];return{kind:"group_by",name:o.name,field:{...o.field,annotations:a.length>0?a:void 0}}})}getAggregateStatement(e){const r=this.getAnnotations(e.tags()),s=e.queryFieldList().queryFieldEntry().map(o=>this.getQueryField(o));return s.some(o=>o===null)||s===null?null:s.map(o=>{var u;const a=[...r??[],...(u=o.field.annotations)!==null&&u!==void 0?u:[]];return{kind:"aggregate",name:o.name,field:{...o.field,annotations:a.length>0?a:void 0}}})}getOrderByStatement(e){const r=e.ordering().orderBySpec(),i=[];for(const s of r)if(s.INTEGER_LITERAL())this.notAllowed(s,"Indexed order by statements");else if(s.fieldName()){const o=(0,gE.getId)(s.fieldName()),u=s.ASC()?"asc":s.DESC()?"desc":void 0;i.push({kind:"order_by",direction:u,field_reference:{name:o}})}else return null;return i}getNestStatement(e){const r=this.getAnnotations(e.tags()),i=e.nestedQueryList().nestEntry(),s=[];for(const o of i){if(!(o instanceof On.NestDefContext))return this.internalError(o,"Expected nestDef"),null;const u=this.getAnnotations(o.tags()),a=this.getIsAnnotations(o.isDefine()),l=o.queryName(),c=l?(0,gE.getId)(l):void 0,f=this.getViewExpression(o.vExpr());if(f===null)return null;s.push({kind:"nest",name:c,view:{definition:f,annotations:this.combineAnnotations(r,u,a)}})}return s}getViewExpression(e){if(e instanceof On.VSegContext)return this.getRefinementSegment(e.segExpr());if(e instanceof On.VArrowContext){const r=this.getRefinementSegment(e),i=this.getViewExpression(e._rhs);return r===null||i===null?null:{kind:"arrow",source:r,view:i}}else return this.internalError(e,"Unexpected VExpr node"),null}getLimitStatement(e){return{kind:"limit",limit:this.getNumber(e.INTEGER_LITERAL())}}getSegmentOperation(e){if(e.groupByStatement()){const r=e.groupByStatement();return this.getGroupByStatement(r)}else if(e.aggregateStatement()){const r=e.aggregateStatement();return this.getAggregateStatement(r)}else if(e.limitStatement()){const r=e.limitStatement(),i=this.getLimitStatement(r);return i===null?null:[i]}else if(e.declareStatement())this.notAllowed(e,"Declare statements");else if(e.queryJoinStatement())this.notAllowed(e,"Query join statements");else if(e.queryExtend())this.notAllowed(e,"Query extend statements");else if(e.projectStatement())this.notAllowed(e,"Select statements");else if(e.indexStatement())this.notAllowed(e,"Index statements");else if(e.calculateStatement())this.notAllowed(e,"Calculate statements");else if(e.topStatement())this.notAllowed(e,"Top statements");else if(e.orderByStatement()){const r=e.orderByStatement();return this.getOrderByStatement(r)}else if(e.whereStatement()){const r=e.whereStatement(),i=this.getWhere(r);return i===null?null:i.map(s=>({kind:"where",...s}))}else if(e.havingStatement()){const r=e.havingStatement(),i=this.getHaving(r);return i===null?null:i.map(s=>({kind:"having",...s}))}else if(e.nestStatement()){const r=e.nestStatement();return this.getNestStatement(r)}else e.sampleStatement()?this.notAllowed(e,"Sample statements"):e.timezoneStatement()?this.notAllowed(e,"Timezone statements"):(e.queryAnnotation()||e.ignoredModelAnnotations())&&this.notAllowed(e,"Detached annotation statements");return null}getFieldPath(e){const r=e.fieldName().map(o=>(0,gE.getId)(o)),i=r[0],s=r.slice(1);return{name:i,path:s.length>0?s:void 0}}getTimeframe(e){const r=e.text;return(0,rxt.isTimestampUnit)(r)?r:(this.illegal(e,`Invalid timeframe ${r}`),null)}getQueryField(e){if(e.taggedRef()){const r=e.taggedRef(),i=this.getAnnotations(r.tags()),{name:s,path:o}=this.getFieldPath(r.fieldPath());if(r.refExpr()){const u=r.refExpr();if(u.timeframe()){const a=this.getTimeframe(u.timeframe());return a===null?null:{name:void 0,field:{annotations:i,expression:{kind:"time_truncation",field_reference:{name:s,path:o},truncation:a}}}}else u.aggregate()&&this.notAllowed(u,"Aggregate expressions")}else return{name:void 0,field:{annotations:i,expression:{kind:"field_reference",name:s,path:o}}}}else if(e.fieldDef()){const r=e.fieldDef(),i=this.getAnnotations(r.tags()),s=this.getIsAnnotations(r.isDefine()),o=(0,gE.getId)(r.fieldNameDef()),u=this.getFieldExpression(r.fieldExpr());return u===null?null:{name:o,field:{expression:u,annotations:this.combineAnnotations(i,s)}}}return null}getFieldExpression(e){if(e instanceof On.ExprFieldPathContext){const{name:r,path:i}=this.getFieldPath(e.fieldPath());return{kind:"field_reference",name:r,path:i}}else if(e instanceof On.ExprTimeTruncContext){const r=this.getTimeframe(e.timeframe()),i=e.fieldExpr(),s=this.getFieldExpression(i);return s===null||r===null?null:s.kind!=="field_reference"?(this.illegal(i,"Left hand side of time truncation must be a field reference"),null):{kind:"time_truncation",truncation:r,field_reference:{name:s.name,path:s.path,parameters:s.parameters}}}else if(e instanceof On.ExprFieldPropsContext){const r=e.fieldExpr(),i=this.getFieldExpression(r);if(i===null)return null;if(i.kind!=="field_reference")return this.illegal(r,"Left hand side of filtered field must be a field reference"),null;const s=e.fieldProperties().fieldPropertyStatement(),o=[];for(const u of s){const a=u.whereStatement();if(a){const l=this.getWhere(a);if(l===null)return null;o.push(...l)}}return{kind:"filtered_field",field_reference:{name:i.name,path:i.path,parameters:i.parameters},where:o}}return null}stripQuote(e,r){return e.slice(e.indexOf(r)+r.length,e.lastIndexOf(r))}getFilterString(e){const r=e.tripFilterString(),i=e.tickFilterString();if(r){const s=r.BQ3_FILTER(),o=r.DQ3_FILTER(),u=r.SQ3_FILTER();if(s)return this.stripQuote(s.text,"```");if(o)return this.stripQuote(o.text,'"""');if(u)return this.stripQuote(u.text,"'''")}else if(i){const s=i.BQ_FILTER(),o=i.DQ_FILTER(),u=i.SQ_FILTER();if(s)return this.stripQuote(s.text,"`");if(o)return this.stripQuote(o.text,'"');if(u)return this.stripQuote(u.text,"'")}return null}getFilterExpr(e){if(e instanceof On.ExprCompareContext&&e.compareOp().MATCH()){const r=e.fieldExpr()[0],i=e.fieldExpr()[1];if(r instanceof On.ExprFieldPathContext&&i instanceof On.ExprLiteralContext){const{path:s,name:o}=this.getFieldPath(r.fieldPath()),u=i.literal();if(u instanceof On.FilterString_stubContext){const a=this.getFilterString(u.filterString());return a===null?null:{filter:{kind:"filter_string",field_reference:{name:o,path:s},filter:a}}}}}return this.notAllowed(e,"Filters other than comparisons with filter strings"),null}getWhere(e){const i=e.filterClauseList().fieldExpr().map(s=>this.getFilterExpr(s));return i.some(s=>s===null)?null:i}getHaving(e){const i=e.filterClauseList().fieldExpr().map(s=>this.getFilterExpr(s));return i.some(s=>s===null)?null:i}combineAnnotations(...e){const r=e.flatMap(i=>i??[]);return r.length>0?r:void 0}}R2.MalloyToQuery=Zfe;function oxt(t){const e=(0,Xfe.getSourceInfo)(t),r=new Jfe.BaseMessageLogger(null),i="internal://query.malloy",s=(0,ixt.runMalloyParser)(t,i,e,r),u=new Zfe(s,r).visit(s.root),a=(0,sxt.mapLogs)(r.getLog(),i);if(u===null)return{logs:a};if(!("definition"in u))throw new Error("Expected a query");return{query:u,logs:a}}R2.malloyToQuery=oxt,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.malloyToQuery=t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=Tc;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var r=T2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return r.exploreQueryWalkerBuilder}});var i=R2;Object.defineProperty(t,"malloyToQuery",{enumerable:!0,get:function(){return i.malloyToQuery}})}(H4);var we={},CR={};Object.defineProperty(CR,"__esModule",{value:!0}),CR.MALLOY_VERSION=void 0,CR.MALLOY_VERSION="0.0.264",Object.defineProperty(we,"__esModule",{value:!0}),we.InMemoryModelCache=we.CacheManager=we.CSVWriter=we.JSONWriter=we.DataWriter=we.DataRecord=we.DataArray=we.Result=we.ExploreMaterializer=we.PreparedResultMaterializer=we.QueryMaterializer=we.ModelMaterializer=we.SingleConnectionRuntime=we.ConnectionRuntime=we.Runtime=we.ExploreField=we.JoinRelationship=we.QueryField=we.Query=we.StringField=we.UnsupportedField=we.JSONField=we.BooleanField=we.NumberField=we.TimestampField=we.DateField=we.TimestampTimeframe=we.DateTimeframe=we.AtomicField=we.AtomicFieldType=we.Explore=we.SourceRelationship=we.FixedConnectionMap=we.InMemoryURLReader=we.EmptyURLReader=we.PreparedResult=we.DocumentCompletion=we.DocumentSymbol=we.DocumentPosition=we.DocumentRange=we.DocumentTablePath=we.Parse=we.PreparedQuery=we.Model=we.MalloyError=we.Malloy=void 0;const exe=H4,li=Pi,txe=by,HM=kp,uxt=CR,axt=Pp,$n=ui,lxt=Yl,nxe="internal://internal.malloy";let n0=class E6{static get version(){return uxt.MALLOY_VERSION}static _parse(e,r,i,s,o){r===void 0&&(r=new URL(nxe));let u=r;s!=null&&s.importBaseURL&&(u=s==null?void 0:s.importBaseURL);const a=new exe.MalloyTranslator(r.toString(),u.toString(),{urls:{[r.toString()]:e}},i);return s!=null&&s.testEnvironment&&(a.allDialectsEnabled=!0),new ixe(a,o)}static parse({url:e,urlReader:r,source:i,eventStream:s,options:o}){if(i!==void 0)return E6._parse(i,e,s,o);if(r===void 0)throw new Error("Internal Error: urlReader is required.");if(e===void 0)throw new Error("Internal Error: url is required if source not present.");return NR(r,e).then(({contents:u,invalidationKey:a})=>E6._parse(u,e,s,o,a))}static async compile({url:e,source:r,parse:i,urlReader:s,connections:o,model:u,refreshSchemaCache:a,noThrowOnError:l,eventStream:c,importBaseURL:f,cacheManager:x}){var h,p,m,g,y;let E;if(a&&(E=typeof a=="number"?a:Date.now()),e===void 0&&r===void 0&&i===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(i!==void 0?e=new URL(i._translator.sourceURL):e=new URL(nxe));const A={};if(r===void 0&&x!==void 0){const C=await x.getCachedModelDef(s,e.toString());if(C)return new O2(C.modelDef,[],[e.toString(),...wR(C.modelDef.dependencies)])}f??(f=e);let _;const v=e.toString();if(i!==void 0){_=i._translator;const C=(h=i._invalidationKey)!==null&&h!==void 0?h:await nP(s,e);A[v]=C}else{if(r===void 0){const{contents:C,invalidationKey:b}=await NR(s,e);A[v]=b,r=C}else{const C=await nP(s,e);A[v]=C}_=new exe.MalloyTranslator(v,f.toString(),{urls:{[v]:r}},c)}for(;;){const C=_.translate(u==null?void 0:u._modelDef);if(C.final)if(C.modelDef){await(x==null?void 0:x.setCachedModelDef(e.toString(),{modelDef:C.modelDef,invalidationKeys:A}));for(const b of _.newlyTranslatedDependencies())await(x==null?void 0:x.setCachedModelDef(b.url,{modelDef:b.modelDef,invalidationKeys:A}));return new O2(C.modelDef,C.problems||[],[...(p=u==null?void 0:u.fromSources)!==null&&p!==void 0?p:[],...(m=C.fromSources)!==null&&m!==void 0?m:[]],b=>_.referenceAt(b),b=>_.importAt(b))}else if(l){const b={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},S=(u==null?void 0:u._modelDef)||b;return new O2(S,C.problems||[],[...(g=u==null?void 0:u.fromSources)!==null&&g!==void 0?g:[],...(y=C.fromSources)!==null&&y!==void 0?y:[]],R=>_.referenceAt(R),R=>_.importAt(R))}else{const b=C.problems||[],S=_.prettyErrors();throw new rxe(`Error(s) compiling model:
1466
+ ${s}`:e=s}return e}childRequest(e){var r;const i=decodeURI(new URL(e,this.sourceURL).toString()),s=(r=this.childTranslators.get(i))===null||r===void 0?void 0:r.translate();if(s!=null&&s.compileSQL)return{compileSQL:s.compileSQL}}getChildExports(e){const r={},i=decodeURI(new URL(e,this.sourceURL).toString()),s=this.childTranslators.get(i);if(s&&s.translate().modelDef)for(const u of s.modelDef.exports){const a=s.modelDef.contents[u];((0,Sft.isSourceDef)(a)||a.type==="query")&&(r[u]=a)}return r}translate(e){if(this.finalAnswer)return this.finalAnswer;const r=this.translateStep.step(this,e);return r.final&&(this.finalAnswer=r),r}translatorForDependency(e){return this.childTranslators.get(e)}importAt(e){for(let r=0;r<this.imports.length;r++){const i=this.imports[r];if((0,kM.locationContainsPosition)(i.location,e))return i}}metadata(){return this.metadataStep.step(this)}modelAnnotation(e){return this.modelAnnotationStep.step(this,e)}tablePathInfo(){return this.tablePathInfoStep.step(this)}completions(e){return this.completionsStep.step(this,e)}helpContext(e){return this.helpContextStep.step(this,e)}defaultLocation(){return{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}rangeFromContext(e){return(0,kM.rangeFromContext)(this.parseStep.sourceInfo,e)}firstReferenceToDialect(e){return this.dialectAlreadyChecked[e]?!1:(this.dialectAlreadyChecked[e]=!0,!0)}experimentalDialectEnabled(e){if(this.allDialectsEnabled)return!0;const r=this.compilerFlags.tag("experimental");return r!==void 0&&(r.bare()||r.has("dialect",e))}}Tc.MalloyTranslation=MM;class Qfe extends MM{constructor(e,r){super(e),this.root=r}}Tc.MalloyChildTranslator=Qfe;class zft extends MM{constructor(e,r=null,i=null,s=null){super(e,r),this.eventStream=s,this.schemaZone=new $M.Zone,this.importZone=new $M.Zone,this.pretranslatedModels=new Map,this.sqlQueryZone=new $M.Zone,this.root=this,this.logger=new Hfe.BaseMessageLogger(s),i&&this.update(i)}update(e){var r,i,s;this.schemaZone.updateFrom(e.tables,(r=e.errors)===null||r===void 0?void 0:r.tables),this.importZone.updateFrom(e.urls,(i=e.errors)===null||i===void 0?void 0:i.urls),this.sqlQueryZone.updateFrom(e.compileSQL,(s=e.errors)===null||s===void 0?void 0:s.compileSQL);for(const o in e.translations)this.pretranslatedModels.set(o,e.translations[o])}logError(e,r,i){return this.logger.log((0,Hfe.makeLogMessage)(e,r,{severity:"error",...i})),e}}Tc.MalloyTranslator=zft;function zfe(t){return[...Object.keys(t),...Object.keys(t).map(e=>zfe(t[e])).flat()]}var T2={};Object.defineProperty(T2,"__esModule",{value:!0}),T2.exploreQueryWalkerBuilder=T2.ExploreQueryWalker=void 0;const Gft=uc;class Gfe{constructor(e){this.inDocument=!1,this.exploreClauseRefs=[],this.tokens=e}exploreQueryAtOffset(e){return this.exploreClauseRefs.find(r=>r.range[0]===void 0||r.range[1]===void 0?!1:r.range[0]<=e&&r.range[1]>=e)}filterAtOffset(e){const r=this.exploreQueryAtOffset(e);if(r)return r.filterRefs.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e)}hasFilterListAtOffset(e){const r=this.exploreQueryAtOffset(e);return r?!!r.filterLists.find(i=>i.range[0]===void 0||i.range[1]===void 0?!1:i.range[0]<=e&&i.range[1]>=e):!1}enterMalloyDocument(){this.inDocument=!0}}T2.ExploreQueryWalker=Gfe;function Wft(t,e){const r=new Gfe(t),i=r;return Gft.ParseTreeWalker.DEFAULT.walk(i,e),r}T2.exploreQueryWalkerBuilder=Wft;var R2={},mE={},La={};Object.defineProperty(La,"__esModule",{value:!0}),La.getResultStructMetadataAnnotation=La.convertFieldInfos=La.modelDefToModelInfo=void 0;const Ia=Pi,PM=Ls,UM=ui,Wfe=Zo;function Vft(t){const e={entries:[],anonymous_queries:[]};for(const[r,i]of Object.entries(t.contents))if(t.exports.includes(r)){if((0,Ia.isSourceDef)(i)){const s=i.parameters&&Object.entries(i.parameters).length>0?Object.entries(i.parameters).map(([u,a])=>(0,Ia.isAtomic)(a)?{name:u,type:vR(a),default_value:Vfe(a.value)}:{name:u,type:{kind:"filter_expression_type"},default_value:Vfe(a.value)}):void 0,o={kind:"source",name:r,schema:{fields:D2(i,i.fields)},parameters:s,annotations:jM(i)};e.entries.push(o)}else if(i.type==="query"){const s=(0,PM.getResultStructDefForQuery)(t,i),o=jM(i),u=s.resultMetadata?_R(s,s.resultMetadata):void 0,a=[...o??[],...u?[u]:[]],l={kind:"source",name:r,schema:{fields:D2(s,s.fields)},annotations:a.length>0?a:void 0};e.entries.push(l)}}for(const r of t.queryList){const i=(0,PM.getResultStructDefForQuery)(t,r),s=jM(r),o=i.resultMetadata?_R(i,i.resultMetadata):void 0,u=[...s??[],...o?[o]:[]],a={schema:{fields:D2(i,i.fields)},annotations:u.length>0?u:void 0};e.anonymous_queries.push(a)}return e}La.modelDefToModelInfo=Vft;function Vfe(t){if(t!==null)switch(t.node){case"numberLiteral":return{kind:"number_literal",number_value:parseFloat(t.literal)};case"stringLiteral":return{kind:"string_literal",string_value:t.literal};case"filterLiteral":return{kind:"filter_expression_literal",filter_expression_value:t.filterSrc};case"timeLiteral":return{kind:"timestamp_literal",timestamp_value:t.literal};case"true":return{kind:"boolean_literal",boolean_value:!0};case"false":return{kind:"boolean_literal",boolean_value:!1};case"null":return{kind:"null_literal"};default:throw new Error("Invalid parameter default value")}}function jM(t){return(0,UM.annotationToTaglines)(t.annotation).map(r=>({value:r}))}function D2(t,e){var r,i,s;const o=[];for(const u of e){if(!(u.accessModifier===void 0))continue;const c=(0,UM.annotationToTaglines)(u.annotation).map(x=>({value:x})),f=c.length>0?c:void 0;if((0,Ia.isTurtle)(u)){const x=(0,PM.getResultStructDefForView)(t,u),h=x.resultMetadata?_R(x,x.resultMetadata):void 0,p=[...f??[],...h?[h]:[]],m={kind:"view",name:(r=u.as)!==null&&r!==void 0?r:u.name,annotations:p.length>0?p:void 0,schema:{fields:D2(x,x.fields)}};o.push(m)}else if((0,Ia.isAtomic)(u)){const x=(0,Ia.expressionIsAggregate)(u.expressionType),h=(0,Ia.expressionIsScalar)(u.expressionType);if(!x&&!h||u.type==="error")continue;const p=u.resultMetadata?Yfe(u,u.resultMetadata):void 0,m=[...f??[],...p?[p]:[]],g={kind:x?"measure":"dimension",name:(i=u.as)!==null&&i!==void 0?i:u.name,type:vR(u),annotations:m.length>0?m:void 0};o.push(g)}else if((0,Ia.isJoinedSource)(u)){const x={kind:"join",name:(s=u.as)!==null&&s!==void 0?s:u.name,annotations:f,schema:{fields:D2(u,u.fields)},relationship:u.join};o.push(x)}}return o}La.convertFieldInfos=D2;function Yfe(t,e){const r=Wfe.Tag.withPrefix("#(malloy) ");let i=!1;if(e.referenceId!==void 0&&(r.set(["reference_id"],e.referenceId),i=!0),e.fieldKind==="measure"&&(r.set(["calculation"]),i=!0),e.filterList){const s=e.filterList.filter(o=>o.expressionType==="scalar").map(o=>o.code);r.set(["drill_filters"],s),i=!0}if(e.fieldKind==="dimension"){const o=(e==null?void 0:e.sourceExpression)||(e!=null&&e.sourceField.includes(".")?e==null?void 0:e.sourceField:Kft(t.name));r.set(["drill_expression"],o),i=!0}return i?{value:r.toString()}:void 0}function Yft(t){return t.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}function Kft(t){return t.match(/^[A-Za-z_][0-9A-Za-z_]*$/)?t:`\`${Yft(t)}\``}function _R(t,e){var r,i;const s=Wfe.Tag.withPrefix("#(malloy) ");let o=!1;if(e.limit!==void 0&&(s.set(["limit"],e.limit),o=!0),e.filterList){const u=e.filterList.filter(a=>a.expressionType==="scalar").map(a=>a.code);u.length>0&&(s.set(["drill_filters"],u),o=!0)}if(e.orderBy){for(let u=0;u<e.orderBy.length;u++){const a=e.orderBy[u],l=typeof a.field=="number"?(r=t.fields[a.field-1].as)!==null&&r!==void 0?r:t.fields[a.field-1].name:a.field,c=(i=a.dir)!==null&&i!==void 0?i:null;s.set(["ordered_by",u,l],c)}o=!0}return o?{value:s.toString()}:void 0}La.getResultStructMetadataAnnotation=_R;function vR(t){if((0,Ia.isBasicAtomic)(t))switch(t.type){case"string":return{kind:"string_type"};case"number":return{kind:"number_type",subtype:t.numberType==="float"?"decimal":t.numberType==="integer"?"integer":void 0};case"boolean":return{kind:"boolean_type"};case"date":{const e=t.timeframe;return e&&!Jft(e)?{kind:"timestamp_type",timeframe:t.timeframe}:{kind:"date_type",timeframe:Xft(t.timeframe)}}case"timestamp":return{kind:"timestamp_type",timeframe:t.timeframe};case"json":return{kind:"json_type"};case"sql native":return{kind:"sql_native_type",sql_type:t.rawType};case"error":throw new Error("Error type is not supported in stable interface")}else{if((0,Ia.isRepeatedRecord)(t))return{kind:"array_type",element_type:Kfe(t)};if(t.type==="record")return Kfe(t);if(t.type==="array")return{kind:"array_type",element_type:vR(t.elementTypeDef)}}throw new Error("Unexpected field type")}function Kfe(t){return{kind:"record_type",fields:t.fields.map(e=>{const r=[];if("resultMetadata"in e&&e.resultMetadata){const i=Yfe(e,e.resultMetadata);i&&r.push(i)}if(e.annotation){const i=(0,UM.annotationToTaglines)(e.annotation);r.push(...i.map(s=>({value:s})))}if((0,Ia.isAtomic)(e))return{name:e.name,annotations:r.length>0?r:void 0,type:vR(e)};throw new Error("Expected record type to not have a table as its child")})}}function Jft(t){switch(t){case"day":case"week":case"month":case"year":case"quarter":return!0;default:return!1}}function Xft(t){switch(t){case void 0:return;case"day":case"week":case"month":case"year":case"quarter":return t;default:throw new Error(`Invalid date timeframe ${t}`)}}function hht(t){return t}function pht(t){return t}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.mapLogs=t.DEFAULT_LOG_RANGE=t.wrapResult=t.mapData=t.wrapLegacyConnection=t.wrapLegacyInfoConnection=void 0;const e=Zo,r=ui,i=La,s=by;function o(x){return{get dialectName(){return x.dialectName},async fetchSchemaForSQLQuery(h){const p=await x.fetchSchemaForSQLStruct({connection:x.name,selectStr:h},{}),m=p.structDef;if(m===void 0)throw new Error(p.error);return{fields:(0,i.convertFieldInfos)(m,m.fields)}},async fetchSchemaForTable(h){const p=`${x.name}:${h}`,m=await x.fetchSchemaForTables({[p]:h},{}),g=m.schemas[p];if(g===void 0)throw new Error(m.errors[p]);return{fields:(0,i.convertFieldInfos)(g,g.fields)}}}}t.wrapLegacyInfoConnection=o;function u(x){return{...o(x),runSQL:async(h,p)=>{const m=await x.runSQL(h);return l(m.rows,p)}}}t.wrapLegacyConnection=u;function a(x){if(x instanceof Date)return x;if(x.constructor.name==="Date")return new Date(x);if(typeof x=="number")return new Date(x);if(typeof x!="string")return new Date(x.value);{let p=s.DateTime.fromISO(x,{zone:"UTC"});return p.isValid||(p=s.DateTime.fromSQL(x,{zone:"UTC"})),p.toJSDate()}}function l(x,h){function p(y,E){if(y===null)return{kind:"null_cell"};if(E.type.kind==="date_type"||E.type.kind==="timestamp_type"){const A=a(y).toISOString();return E.type.kind==="date_type"?{kind:"date_cell",date_value:A}:{kind:"timestamp_cell",timestamp_value:A}}else if(E.type.kind==="boolean_type"){if(typeof y=="number")return{kind:"boolean_cell",boolean_value:y!==0};if(typeof y!="boolean")throw new Error(`Invalid boolean ${y}`);return{kind:"boolean_cell",boolean_value:y}}else if(E.type.kind==="number_type"){if(typeof y!="number")throw new Error(`Invalid number ${y}`);return{kind:"number_cell",number_value:y}}else if(E.type.kind==="string_type"){if(typeof y!="string")throw new Error(`Invalid string ${y}`);return{kind:"string_cell",string_value:y}}else if(E.type.kind==="array_type"){if(!Array.isArray(y))throw new Error(`Invalid array ${y}`);return{kind:"array_cell",array_value:y.map(A=>p(A,{name:"array_element",type:E.type.element_type}))}}else{if(E.type.kind==="json_type")return{kind:"json_cell",json_value:JSON.stringify(y)};if(E.type.kind==="sql_native_type")return{kind:"sql_native_cell",sql_native_value:JSON.stringify(y)};{const A=E.type;if(A.kind!=="record_type")throw new Error(`Invalid record in result ${JSON.stringify(E)}, ${JSON.stringify(y)}`);return m(y,{kind:"join",relationship:"many",name:"array_element",schema:{fields:A.fields.map(_=>({kind:"dimension",..._}))}})}}}function m(y,E){const A=[];for(const _ of E.schema.fields){const v=y[_.name];if(_.kind!=="dimension")throw new Error("Invalid result -- expected all fields to be dimensions");const C=p(v,_);A.push(C)}return{kind:"record_cell",record_value:A}}const g={kind:"join",schema:h,name:"root",relationship:"one"};return{kind:"array_cell",array_value:x.map(y=>m(y,g))}}t.mapData=l;function c(x){const h=x._queryResult.structs,p=h[h.length-1],m={fields:(0,i.convertFieldInfos)(p,p.fields)},g=(0,r.annotationToTaglines)(x.annotation).map(E=>({value:E})),y=p.resultMetadata?(0,i.getResultStructMetadataAnnotation)(p,p.resultMetadata):void 0;return y&&g.push(y),g.push(...p.resultMetadata?[]:[]),x.sourceExplore&&g.push({value:e.Tag.withPrefix("#(malloy) ").set(["source_name"],x.sourceExplore.name).toString()}),g.push({value:e.Tag.withPrefix("#(malloy) ").set(["query_name"],x.resultExplore.name).toString()}),{schema:m,data:l(x.data.toObject(),m),connection_name:x.connectionName,annotations:g.length>0?g:void 0,query_timezone:x.data.field.queryTimezone}}t.wrapResult=c,t.DEFAULT_LOG_RANGE={start:{line:0,character:0},end:{line:0,character:0}};function f(x,h){return x.map(p=>{var m,g,y,E;return{severity:p.severity,message:p.message,range:(g=(m=p.at)===null||m===void 0?void 0:m.range)!==null&&g!==void 0?g:t.DEFAULT_LOG_RANGE,url:(E=(y=p.at)===null||y===void 0?void 0:y.url)!==null&&E!==void 0?E:h}})}t.mapLogs=f})(mE);var Zft=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),ext=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),txt=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Zft(e,t,r);return ext(e,t),e};Object.defineProperty(R2,"__esModule",{value:!0}),R2.malloyToQuery=R2.MalloyToQuery=void 0;const nxt=Kh,On=txt(w),Jfe=Yp,gE=Bn,rxt=Xe,ixt=aE,Xfe=Vn,sxt=mE,qM="Malloy query documents";class Zfe extends nxt.AbstractParseTreeVisitor{constructor(e,r){super(),this.parseInfo=e,this.msgLog=r}internalError(e,r){return this.contextError(e,"internal-translator-error",{message:r}),new Error(`Internal Translator Error: ${r}`)}getLocation(e){return{url:this.parseInfo.sourceURL,range:(0,Xfe.rangeFromContext)(this.parseInfo.sourceInfo,e)}}contextError(e,r,i,s){this.msgLog.log((0,Jfe.makeLogMessage)(r,i,{at:this.getLocation(e),...s}))}getNumber(e){return Number.parseInt(e.text)}defaultResult(){return null}getAnnotations(e){const r=e.ANNOTATION().map(i=>({value:i.text}));return r.length>0?r:void 0}getIsAnnotations(e){var r,i;if(e===void 0)return;const o=((r=this.getAnnotations(e._beforeIs))!==null&&r!==void 0?r:[]).concat((i=this.getAnnotations(e._afterIs))!==null&&i!==void 0?i:[]);return o.length>0?o:void 0}notAllowed(e,r){this.illegal(e,`${r} are not allowed in ${qM}`)}illegal(e,r){this.contextError(e,"invalid-malloy-query-document",r)}visitMalloyDocument(e){const r=e.malloyStatement();let i;for(const s of r)s.defineSourceStatement()?this.notAllowed(s,"Source definitions"):s.defineQuery()?this.notAllowed(s,"Query definitions"):s.importStatement()?this.notAllowed(s,"Import statements"):s.docAnnotations()?this.notAllowed(s,"Model annotations"):s.ignoredObjectAnnotations()?this.notAllowed(s,"Detatched object annotations"):s.experimentalStatementForTesting()?this.notAllowed(s,"Experimental testing statements"):i===void 0?i=s.runStatement():this.illegal(s,`${qM} may only have one run statement`);return i===void 0?(this.illegal(e,`${qM} must have a run statement`),null):this.visitRunStatement(i)}visitRunStatement(e){const r=e.topLevelAnonQueryDef(),i=this.getQueryDefinition(r.sqExpr()),s=this.getAnnotations(e.topLevelAnonQueryDef().tags());return i!==null?{annotations:s,definition:i}:null}getQueryReference(e){if(e.sourceArguments())this.illegal(e,"Queries do not support parameters");else return{name:(0,gE.getId)(e)};return null}getQueryDefinition(e){if(e instanceof On.SQIDContext){const r=this.getQueryReference(e);if(r!==null)return{kind:"query_reference",...r}}else{if(e instanceof On.SQParensContext)return this.getQueryDefinition(e.sqExpr());if(e instanceof On.SQComposeContext)this.notAllowed(e,"Source compositions");else if(e instanceof On.SQRefinedQueryContext){const r=e.sqExpr(),i=this.getQueryDefinition(r),s=this.getRefinementSegment(e.segExpr());return s===null||i===null?null:(s.kind==="arrow"&&this.notAllowed(e,"Queries against refined queries"),{kind:"refinement",base:i,refinement:s})}else if(e instanceof On.SQExtendedSourceContext)this.notAllowed(e,"Source extensions");else if(e instanceof On.SQIncludeContext)this.notAllowed(e,"Source inclusions");else if(e instanceof On.SQTableContext)this.notAllowed(e,"Table statements");else if(e instanceof On.SQSQLContext)this.notAllowed(e,"SQL statements");else if(e instanceof On.SQArrowContext){const r=e.sqExpr(),i=this.getQueryDefinition(r),s=this.getRefinementSegment(e.segExpr());return s===null||i===null?null:i.kind==="query_reference"?{kind:"arrow",source:{...i,kind:"source_reference"},view:s}:i.kind==="arrow"?{kind:"arrow",source:i.source,view:{kind:"arrow",source:i.view,view:s}}:{kind:"arrow",source:i,view:s}}}return null}getRefinementSegment(e){if(e instanceof On.SegOpsContext){const r=e.queryProperties().queryStatement().flatMap(i=>this.getSegmentOperation(i));return r.some(i=>i===null)?null:{kind:"segment",operations:r}}else if(e instanceof On.SegFieldContext){const{name:r,path:i}=this.getFieldPath(e.fieldPath());return{kind:"view_reference",name:r,path:i}}else{if(e instanceof On.SegParenContext)return this.getViewExpression(e.vExpr());if(e instanceof On.SegRefineContext){const r=this.getRefinementSegment(e._lhs),i=this.getRefinementSegment(e._rhs);return r===null||i===null?null:{kind:"refinement",base:r,refinement:i}}}return null}getGroupByStatement(e){const r=this.getAnnotations(e.tags()),s=e.queryFieldList().queryFieldEntry().map(o=>this.getQueryField(o));return s.some(o=>o===null)||s===null?null:s.map(o=>{var u;const a=[...r??[],...(u=o.field.annotations)!==null&&u!==void 0?u:[]];return{kind:"group_by",name:o.name,field:{...o.field,annotations:a.length>0?a:void 0}}})}getAggregateStatement(e){const r=this.getAnnotations(e.tags()),s=e.queryFieldList().queryFieldEntry().map(o=>this.getQueryField(o));return s.some(o=>o===null)||s===null?null:s.map(o=>{var u;const a=[...r??[],...(u=o.field.annotations)!==null&&u!==void 0?u:[]];return{kind:"aggregate",name:o.name,field:{...o.field,annotations:a.length>0?a:void 0}}})}getOrderByStatement(e){const r=e.ordering().orderBySpec(),i=[];for(const s of r)if(s.INTEGER_LITERAL())this.notAllowed(s,"Indexed order by statements");else if(s.fieldName()){const o=(0,gE.getId)(s.fieldName()),u=s.ASC()?"asc":s.DESC()?"desc":void 0;i.push({kind:"order_by",direction:u,field_reference:{name:o}})}else return null;return i}getNestStatement(e){const r=this.getAnnotations(e.tags()),i=e.nestedQueryList().nestEntry(),s=[];for(const o of i){if(!(o instanceof On.NestDefContext))return this.internalError(o,"Expected nestDef"),null;const u=this.getAnnotations(o.tags()),a=this.getIsAnnotations(o.isDefine()),l=o.queryName(),c=l?(0,gE.getId)(l):void 0,f=this.getViewExpression(o.vExpr());if(f===null)return null;s.push({kind:"nest",name:c,view:{definition:f,annotations:this.combineAnnotations(r,u,a)}})}return s}getViewExpression(e){if(e instanceof On.VSegContext)return this.getRefinementSegment(e.segExpr());if(e instanceof On.VArrowContext){const r=this.getRefinementSegment(e),i=this.getViewExpression(e._rhs);return r===null||i===null?null:{kind:"arrow",source:r,view:i}}else return this.internalError(e,"Unexpected VExpr node"),null}getLimitStatement(e){return{kind:"limit",limit:this.getNumber(e.INTEGER_LITERAL())}}getSegmentOperation(e){if(e.groupByStatement()){const r=e.groupByStatement();return this.getGroupByStatement(r)}else if(e.aggregateStatement()){const r=e.aggregateStatement();return this.getAggregateStatement(r)}else if(e.limitStatement()){const r=e.limitStatement(),i=this.getLimitStatement(r);return i===null?null:[i]}else if(e.declareStatement())this.notAllowed(e,"Declare statements");else if(e.queryJoinStatement())this.notAllowed(e,"Query join statements");else if(e.queryExtend())this.notAllowed(e,"Query extend statements");else if(e.projectStatement())this.notAllowed(e,"Select statements");else if(e.indexStatement())this.notAllowed(e,"Index statements");else if(e.calculateStatement())this.notAllowed(e,"Calculate statements");else if(e.topStatement())this.notAllowed(e,"Top statements");else if(e.orderByStatement()){const r=e.orderByStatement();return this.getOrderByStatement(r)}else if(e.whereStatement()){const r=e.whereStatement(),i=this.getWhere(r);return i===null?null:i.map(s=>({kind:"where",...s}))}else if(e.havingStatement()){const r=e.havingStatement(),i=this.getHaving(r);return i===null?null:i.map(s=>({kind:"having",...s}))}else if(e.nestStatement()){const r=e.nestStatement();return this.getNestStatement(r)}else e.sampleStatement()?this.notAllowed(e,"Sample statements"):e.timezoneStatement()?this.notAllowed(e,"Timezone statements"):(e.queryAnnotation()||e.ignoredModelAnnotations())&&this.notAllowed(e,"Detached annotation statements");return null}getFieldPath(e){const r=e.fieldName().map(o=>(0,gE.getId)(o)),i=r[0],s=r.slice(1);return{name:i,path:s.length>0?s:void 0}}getTimeframe(e){const r=e.text;return(0,rxt.isTimestampUnit)(r)?r:(this.illegal(e,`Invalid timeframe ${r}`),null)}getQueryField(e){if(e.taggedRef()){const r=e.taggedRef(),i=this.getAnnotations(r.tags()),{name:s,path:o}=this.getFieldPath(r.fieldPath());if(r.refExpr()){const u=r.refExpr();if(u.timeframe()){const a=this.getTimeframe(u.timeframe());return a===null?null:{name:void 0,field:{annotations:i,expression:{kind:"time_truncation",field_reference:{name:s,path:o},truncation:a}}}}else u.aggregate()&&this.notAllowed(u,"Aggregate expressions")}else return{name:void 0,field:{annotations:i,expression:{kind:"field_reference",name:s,path:o}}}}else if(e.fieldDef()){const r=e.fieldDef(),i=this.getAnnotations(r.tags()),s=this.getIsAnnotations(r.isDefine()),o=(0,gE.getId)(r.fieldNameDef()),u=this.getFieldExpression(r.fieldExpr());return u===null?null:{name:o,field:{expression:u,annotations:this.combineAnnotations(i,s)}}}return null}getFieldExpression(e){if(e instanceof On.ExprFieldPathContext){const{name:r,path:i}=this.getFieldPath(e.fieldPath());return{kind:"field_reference",name:r,path:i}}else if(e instanceof On.ExprTimeTruncContext){const r=this.getTimeframe(e.timeframe()),i=e.fieldExpr(),s=this.getFieldExpression(i);return s===null||r===null?null:s.kind!=="field_reference"?(this.illegal(i,"Left hand side of time truncation must be a field reference"),null):{kind:"time_truncation",truncation:r,field_reference:{name:s.name,path:s.path,parameters:s.parameters}}}else if(e instanceof On.ExprFieldPropsContext){const r=e.fieldExpr(),i=this.getFieldExpression(r);if(i===null)return null;if(i.kind!=="field_reference")return this.illegal(r,"Left hand side of filtered field must be a field reference"),null;const s=e.fieldProperties().fieldPropertyStatement(),o=[];for(const u of s){const a=u.whereStatement();if(a){const l=this.getWhere(a);if(l===null)return null;o.push(...l)}}return{kind:"filtered_field",field_reference:{name:i.name,path:i.path,parameters:i.parameters},where:o}}return null}stripQuote(e,r){return e.slice(e.indexOf(r)+r.length,e.lastIndexOf(r))}getFilterString(e){const r=e.tripFilterString(),i=e.tickFilterString();if(r){const s=r.BQ3_FILTER(),o=r.DQ3_FILTER(),u=r.SQ3_FILTER();if(s)return this.stripQuote(s.text,"```");if(o)return this.stripQuote(o.text,'"""');if(u)return this.stripQuote(u.text,"'''")}else if(i){const s=i.BQ_FILTER(),o=i.DQ_FILTER(),u=i.SQ_FILTER();if(s)return this.stripQuote(s.text,"`");if(o)return this.stripQuote(o.text,'"');if(u)return this.stripQuote(u.text,"'")}return null}getFilterExpr(e){if(e instanceof On.ExprCompareContext&&e.compareOp().MATCH()){const r=e.fieldExpr()[0],i=e.fieldExpr()[1];if(r instanceof On.ExprFieldPathContext&&i instanceof On.ExprLiteralContext){const{path:s,name:o}=this.getFieldPath(r.fieldPath()),u=i.literal();if(u instanceof On.FilterString_stubContext){const a=this.getFilterString(u.filterString());return a===null?null:{filter:{kind:"filter_string",field_reference:{name:o,path:s},filter:a}}}}}return this.notAllowed(e,"Filters other than comparisons with filter strings"),null}getWhere(e){const i=e.filterClauseList().fieldExpr().map(s=>this.getFilterExpr(s));return i.some(s=>s===null)?null:i}getHaving(e){const i=e.filterClauseList().fieldExpr().map(s=>this.getFilterExpr(s));return i.some(s=>s===null)?null:i}combineAnnotations(...e){const r=e.flatMap(i=>i??[]);return r.length>0?r:void 0}}R2.MalloyToQuery=Zfe;function oxt(t){const e=(0,Xfe.getSourceInfo)(t),r=new Jfe.BaseMessageLogger(null),i="internal://query.malloy",s=(0,ixt.runMalloyParser)(t,i,e,r),u=new Zfe(s,r).visit(s.root),a=(0,sxt.mapLogs)(r.getLog(),i);if(u===null)return{logs:a};if(!("definition"in u))throw new Error("Expected a query");return{query:u,logs:a}}R2.malloyToQuery=oxt,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.malloyToQuery=t.exploreQueryWalkerBuilder=t.MalloyTranslation=t.MalloyTranslator=void 0;var e=Tc;Object.defineProperty(t,"MalloyTranslator",{enumerable:!0,get:function(){return e.MalloyTranslator}}),Object.defineProperty(t,"MalloyTranslation",{enumerable:!0,get:function(){return e.MalloyTranslation}});var r=T2;Object.defineProperty(t,"exploreQueryWalkerBuilder",{enumerable:!0,get:function(){return r.exploreQueryWalkerBuilder}});var i=R2;Object.defineProperty(t,"malloyToQuery",{enumerable:!0,get:function(){return i.malloyToQuery}})}(H4);var we={},CR={};Object.defineProperty(CR,"__esModule",{value:!0}),CR.MALLOY_VERSION=void 0,CR.MALLOY_VERSION="0.0.265",Object.defineProperty(we,"__esModule",{value:!0}),we.InMemoryModelCache=we.CacheManager=we.CSVWriter=we.JSONWriter=we.DataWriter=we.DataRecord=we.DataArray=we.Result=we.ExploreMaterializer=we.PreparedResultMaterializer=we.QueryMaterializer=we.ModelMaterializer=we.SingleConnectionRuntime=we.ConnectionRuntime=we.Runtime=we.ExploreField=we.JoinRelationship=we.QueryField=we.Query=we.StringField=we.UnsupportedField=we.JSONField=we.BooleanField=we.NumberField=we.TimestampField=we.DateField=we.TimestampTimeframe=we.DateTimeframe=we.AtomicField=we.AtomicFieldType=we.Explore=we.SourceRelationship=we.FixedConnectionMap=we.InMemoryURLReader=we.EmptyURLReader=we.PreparedResult=we.DocumentCompletion=we.DocumentSymbol=we.DocumentPosition=we.DocumentRange=we.DocumentTablePath=we.Parse=we.PreparedQuery=we.Model=we.MalloyError=we.Malloy=void 0;const exe=H4,li=Pi,txe=by,HM=kp,uxt=CR,axt=Pp,$n=ui,lxt=Yl,nxe="internal://internal.malloy";let n0=class E6{static get version(){return uxt.MALLOY_VERSION}static _parse(e,r,i,s,o){r===void 0&&(r=new URL(nxe));let u=r;s!=null&&s.importBaseURL&&(u=s==null?void 0:s.importBaseURL);const a=new exe.MalloyTranslator(r.toString(),u.toString(),{urls:{[r.toString()]:e}},i);return s!=null&&s.testEnvironment&&(a.allDialectsEnabled=!0),new ixe(a,o)}static parse({url:e,urlReader:r,source:i,eventStream:s,options:o}){if(i!==void 0)return E6._parse(i,e,s,o);if(r===void 0)throw new Error("Internal Error: urlReader is required.");if(e===void 0)throw new Error("Internal Error: url is required if source not present.");return NR(r,e).then(({contents:u,invalidationKey:a})=>E6._parse(u,e,s,o,a))}static async compile({url:e,source:r,parse:i,urlReader:s,connections:o,model:u,refreshSchemaCache:a,noThrowOnError:l,eventStream:c,importBaseURL:f,cacheManager:x}){var h,p,m,g,y;let E;if(a&&(E=typeof a=="number"?a:Date.now()),e===void 0&&r===void 0&&i===void 0)throw new Error("Internal Error: url, source, or parse required.");e===void 0&&(i!==void 0?e=new URL(i._translator.sourceURL):e=new URL(nxe));const A={};if(r===void 0&&x!==void 0){const C=await x.getCachedModelDef(s,e.toString());if(C)return new O2(C.modelDef,[],[e.toString(),...wR(C.modelDef.dependencies)])}f??(f=e);let _;const v=e.toString();if(i!==void 0){_=i._translator;const C=(h=i._invalidationKey)!==null&&h!==void 0?h:await nP(s,e);A[v]=C}else{if(r===void 0){const{contents:C,invalidationKey:b}=await NR(s,e);A[v]=b,r=C}else{const C=await nP(s,e);A[v]=C}_=new exe.MalloyTranslator(v,f.toString(),{urls:{[v]:r}},c)}for(;;){const C=_.translate(u==null?void 0:u._modelDef);if(C.final)if(C.modelDef){await(x==null?void 0:x.setCachedModelDef(e.toString(),{modelDef:C.modelDef,invalidationKeys:A}));for(const b of _.newlyTranslatedDependencies())await(x==null?void 0:x.setCachedModelDef(b.url,{modelDef:b.modelDef,invalidationKeys:A}));return new O2(C.modelDef,C.problems||[],[...(p=u==null?void 0:u.fromSources)!==null&&p!==void 0?p:[],...(m=C.fromSources)!==null&&m!==void 0?m:[]],b=>_.referenceAt(b),b=>_.importAt(b))}else if(l){const b={name:"modelDidNotCompile",exports:[],contents:{},dependencies:{},queryList:[]},S=(u==null?void 0:u._modelDef)||b;return new O2(S,C.problems||[],[...(g=u==null?void 0:u.fromSources)!==null&&g!==void 0?g:[],...(y=C.fromSources)!==null&&y!==void 0?y:[]],R=>_.referenceAt(R),R=>_.importAt(R))}else{const b=C.problems||[],S=_.prettyErrors();throw new rxe(`Error(s) compiling model:
1467
1467
  ${S}`,b)}else{if(C.urls)for(const S of C.urls)try{if(LR(S))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(x!==void 0){const D=await x.getCachedModelDef(s,S);if(D){for(const k in D.invalidationKeys)A[k]=D.invalidationKeys[k];_.update({translations:{[S]:D.modelDef}});continue}}const{contents:R,invalidationKey:O}=await NR(s,new URL(S)),B={[S]:R};A[S]=O,_.update({urls:B})}catch(R){_.update({errors:{urls:{[S]:R.message}}})}const{modelAnnotation:b}=_.modelAnnotation(u==null?void 0:u._modelDef);if(C.tables){const S=new Map;for(const R in C.tables){const{connectionName:O,tablePath:B}=C.tables[R],D=S.get(O);D===void 0?S.set(O,{[R]:B}):D[R]=B}for(const[R,O]of S)try{const B=await o.lookupConnection(R),{schemas:D,errors:k}=await E6.safelyFetchTableSchema(B,O,{refreshTimestamp:E,modelAnnotation:b});_.update({tables:D,errors:{tables:k}})}catch(B){const D={},k={};for(const q in O)k[q]=B.toString();_.update({tables:D,errors:{tables:k}})}}if(C.compileSQL){const S=C.compileSQL,R=S.connection,O=(0,lxt.sqlKey)(S.connection,S.selectStr);try{const D=await(await o.lookupConnection(R)).fetchSchemaForSQLStruct(S,{refreshTimestamp:E,modelAnnotation:b});D.error&&_.update({errors:{compileSQL:{[O]:D.error}}}),D.structDef&&_.update({compileSQL:{[O]:D.structDef}})}catch(B){const D={};D[O]=B.toString(),_.update({errors:{compileSQL:D}})}}}}}static async safelyFetchTableSchema(e,r,i){const s=await e.fetchSchemaForTables(r,i);for(const o of Object.keys(r))if(s.schemas[o]===void 0&&s.errors[o]===void 0)throw new Error(`Schema fetch error for ${e.name}, no response for ${o} from ${e.dialectName}`);return s}static async run({connections:e,preparedResult:r,sqlStruct:i,connection:s,options:o}){if(!s){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const u=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName);s=await e.lookupConnection(u)}if(i){const u=await s.runSQL(i.selectStr);return new AE({structs:[i],sql:i.selectStr,result:u.rows,totalRows:u.totalRows,runStats:u.runStats,lastStageName:i.name,malloy:"",connectionName:i.connection,sourceExplore:"",sourceFilters:[],profilingUrl:u.profilingUrl},{name:"empty_model",exports:[],contents:{},queryList:[],dependencies:{}})}else if(r){const u=await s.runSQL(r.sql,o);return new AE({...r._rawQuery,result:u.rows,totalRows:u.totalRows,runStats:u.runStats,profilingUrl:u.profilingUrl},r._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:e,preparedResult:r,sqlStruct:i,connection:s,options:o}){if(i===void 0&&r===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const u=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName);if(s===void 0){if(e===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");s=await e.lookupConnection(u)}if(!s.canStream())throw new Error(`Connection '${u}' cannot stream results.`);let a,l;if(i)l=new Ps(i),a=i.selectStr;else if(r!==void 0)l=r.resultExplore,a=r.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let c=0;for await(const f of s.runSQLStream(a,o))yield new fd(f,c,l,void 0,void 0),c+=1}static async estimateQueryCost({connections:e,preparedResult:r,sqlStruct:i}){if(!e)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const s=(i==null?void 0:i.connection)||(r==null?void 0:r.connectionName),o=await e.lookupConnection(s);if(i)return await o.estimateQueryCost(i.selectStr);if(r)return await o.estimateQueryCost(r.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}};we.Malloy=n0;class rxe extends Error{constructor(e,r=[]){super(e),this.problems=r}}we.MalloyError=rxe;class O2{constructor(e,r,i,s=()=>{},o=()=>{}){this.modelDef=e,this.problems=r,this.fromSources=i,this._referenceAt=s,this._importAt=o}tagParse(e){return(0,$n.annotationToTag)(this.modelDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.modelDef.annotation,e)}getReference(e){return this._referenceAt(e)}getImport(e){return this._importAt(e)}getPreparedQueryByName(e){const r=this.modelDef.contents[e];if((r==null?void 0:r.type)==="query")return new F2(r,this.modelDef,this.problems,e);throw new Error("Given query name does not refer to a named query.")}getPreparedQueryByIndex(e){if(e<0)throw new Error(`Invalid index ${e}.`);if(e>=this.modelDef.queryList.length)throw new Error(`Query index ${e} is out of bounds.`);return new F2(this.modelDef.queryList[e],this.modelDef,this.problems)}get preparedQuery(){return this.getPreparedQuery()}getPreparedQuery(){if(this.modelDef.queryList.length===0)throw new Error("Model has no queries.");return new F2(this.modelDef.queryList[this.modelDef.queryList.length-1],this.modelDef,this.problems)}getExploreByName(e){const r=this.modelDef.contents[e];if((0,li.isSourceDef)(r))return new Ps(r);throw new Error("'name' is not an explore")}get explores(){return Object.values(this.modelDef.contents).filter(li.isSourceDef).map(e=>new Ps(e))}get namedQueries(){const e=r=>r.type==="query";return Object.values(this.modelDef.contents).filter(e)}get exportedExplores(){return this.explores.filter(e=>this.modelDef.exports.includes(e.name))}get _modelDef(){return this.modelDef}}we.Model=O2;class F2{constructor(e,r,i,s){this.problems=i,this.name=s,this._query=e,this._modelDef=r}tagParse(e){const r=(0,$n.annotationToTag)(this._modelDef.annotation).tag;return e=(0,$n.addModelScope)(e,r),(0,$n.annotationToTag)(this._query.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this._query.annotation,e)}get preparedResult(){return this.getPreparedResult()}getPreparedResult(e){const i=new li.QueryModel(this._modelDef,e==null?void 0:e.eventStream).compileQuery(this._query,e);return new yE({...i,queryName:this.name||i.queryName},this._modelDef)}get dialect(){const e=this._query.structRef,r=typeof e=="string"?this._modelDef.contents[e]:e;if(!(0,li.isSourceDef)(r))throw new Error("Invalid source for query");return r.dialect}getFlattenedQuery(e){return this}}we.PreparedQuery=F2;class ixe{constructor(e,r){this.translator=e,this.invalidationKey=r}get symbols(){return(this.translator.metadata().symbols||[]).map(e=>new SR(e))}get tablePathInfo(){var e;return((e=this.translator.tablePathInfo().pathInfo)!==null&&e!==void 0?e:[]).map(i=>new sxe(i))}get _translator(){return this.translator}get _invalidationKey(){return this.invalidationKey}completions(e){return(this.translator.completions(e).completions||[]).map(r=>new oxe(r))}helpContext(e){return this.translator.helpContext(e).helpContext}}we.Parse=ixe;class sxe{constructor(e){this._range=w2.fromJSON(e.range),this._connectionId=e.connectionId,this._tablePath=e.tablePath}get range(){return this._range}get connectionId(){return this._connectionId}get tablePath(){return this._tablePath}}we.DocumentTablePath=sxe;class w2{constructor(e,r){this._start=e,this._end=r}get start(){return this._start}get end(){return this._end}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}static fromJSON(e){return new w2(new QM(e.start.line,e.start.character),new QM(e.end.line,e.end.character))}}we.DocumentRange=w2;class QM{constructor(e,r){this._line=e,this._character=r}get line(){return this._line}get character(){return this._character}toJSON(){return{line:this.line,character:this.character}}}we.DocumentPosition=QM;class SR{constructor(e){this._range=w2.fromJSON(e.range),this._lensRange=e.lensRange?w2.fromJSON(e.lensRange):void 0,this._type=e.type,this._name=e.name,this._children=e.children.map(r=>new SR(r))}get range(){return this._range}get lensRange(){var e;return(e=this._lensRange)!==null&&e!==void 0?e:this._range}get type(){return this._type}get name(){return this._name}get children(){return this._children}}we.DocumentSymbol=SR;class oxe{constructor(e){this.type=e.type,this.text=e.text}}we.DocumentCompletion=oxe;class yE{constructor(e,r){this.modelDef=r,this.inner=e}static fromJson({query:e,modelDef:r}){if(!e||!r)throw new Error("Missing required properties in JSON data");return new yE(e,r)}tagParse(e){const r=(0,$n.annotationToTag)(this.modelDef.annotation).tag;return e=(0,$n.addModelScope)(e,r),(0,$n.annotationToTag)(this.inner.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.inner.annotation,e)}get annotation(){return this.inner.annotation}get modelAnnotation(){return this.modelDef.annotation}get modelTag(){return(0,$n.annotationToTag)(this.modelDef.annotation).tag}get connectionName(){return this.inner.connectionName}get _rawQuery(){return this.inner}get _modelDef(){return this.modelDef}get sql(){return this.inner.sql}get dependenciesToMaterialize(){return this.inner.dependenciesToMaterialize}get materialization(){return this.inner.materialization}get resultExplore(){if(this.inner.structs.length===0)throw new Error("Malformed query result.");const e=this.inner.structs[this.inner.structs.length-1],r={...e,annotation:this.inner.annotation,name:this.inner.queryName||e.name};try{return new Ps(r,this.sourceExplore)}catch{return new Ps(r)}}get sourceExplore(){const e=this.inner.sourceExplore,r=this.modelDef.contents[e];if(r&&(0,li.isSourceDef)(r))return new Ps(r)}get _sourceExploreName(){return this.inner.sourceExplore}get _sourceFilters(){return this.inner.sourceFilters||[]}}we.PreparedResult=yE;class uxe{async readURL(e){throw new Error("No files.")}async getInvalidationKey(e){throw new Error("No files.")}}we.EmptyURLReader=uxe;class cxt{constructor(e){this.files=e}async readURL(e){const r=this.files.get(e.toString());if(r!==void 0)return Promise.resolve({contents:r,invalidationKey:this.invalidationKey(e,r)});throw new Error(`File not found '${e}'`)}async getInvalidationKey(e){const r=this.files.get(e.toString());if(r!==void 0)return Promise.resolve(this.invalidationKey(e,r));throw new Error(`File not found '${e}'`)}invalidationKey(e,r){return LR(e.toString())?null:vxe(r)}}we.InMemoryURLReader=cxt;class bR{constructor(e,r){this.connections=e,this.defaultConnectionName=r}async getConnection(e){if(e===void 0)if(this.defaultConnectionName!==void 0)e=this.defaultConnectionName;else throw new Error("No default connection.");const r=this.connections.get(e);if(r!==void 0)return Promise.resolve(r);throw new Error(`No connection found with name ${e}.`)}listConnections(){return Array.from(this.connections.values())}async lookupConnection(e){return this.getConnection(e)}static fromArray(e){return new bR(new Map(e.map(r=>[r.name,r])))}}we.FixedConnectionMap=bR;var axe;(function(t){t.Nested="nested",t.BaseTable="base_table",t.Cross="cross",t.One="one",t.Many="many",t.Inline="inline"})(axe||(we.SourceRelationship=axe={}));class zM{constructor(e,r,i){this._name=e,this._parent=r,this._source=i}get source(){return this.source}get name(){return this._name}get sourceClasses(){const e=[];return this.source&&e.push(this.source.name),e.push(this.name),e}get fieldPath(){const e=[this.name];let r=this._parent;for(;r;)e.unshift(r.name),r=r._parent;return e}hasParentExplore(){return this._parent!==void 0}isExplore(){return this instanceof Ps}isQuery(){return this instanceof XM}}class Ps extends zM{constructor(e,r,i){super(e.as||e.name,r,i),this._structDef=e,this._parentExplore=r,this.sourceExplore=i}get source(){return this.sourceExplore}isIntrinsic(){return(0,li.isAtomicFieldType)(this._structDef.type)?!("e"in this._structDef):!1}isExploreField(){return!1}tagParse(e){return(0,$n.annotationToTag)(this._structDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this._structDef.annotation,e)}get modelTag(){return this.parsedModelTag||(this.parsedModelTag=(0,$n.annotationToTag)(this._structDef.modelAnnotation).tag),this.parsedModelTag}get name(){return this.structDef.as||this.structDef.name}getQueryByName(e){const r=this.sourceStructDef;if(!r)throw new Error(`Cannot get query by name from a struct of type ${this.structDef.type}`);const i={type:"query",structRef:r,pipeline:[{type:"reduce",queryFields:[{type:"fieldref",path:[e]}]}]};return new F2(i,this.modelDef,[],e)}get modelDef(){if(!(0,li.isSourceDef)(this.structDef))throw new Error(`Cannot create pseudo model for struct type ${this.structDef.type}`);return{name:"generated_model",exports:[],contents:{[this.structDef.name]:this.structDef},queryList:[],dependencies:{}}}getSingleExploreModel(){return new O2(this.modelDef,[],[])}get fieldMap(){var e;if(this._fieldMap===void 0){const r=((e=this.source)===null||e===void 0?void 0:e.fieldMap)||new Map;this._fieldMap=new Map(this.structDef.fields.map(i=>{const s=i.as||i.name,o=r.get(i.name);if((0,li.isJoined)(i))return[s,new ZM(i,this,o)];if(i.type==="turtle")return[s,new XM(i,this,o)];if(i.type==="string")return[s,new JM(i,this,o)];if(i.type==="number")return[s,new TR(i,this,o)];if(i.type==="date")return i.timeframe&&["day_of_month","day_of_week","day_of_year"].includes(i.timeframe)?[s,new TR({...i,type:"number"},this,o)]:[s,new GM(i,this,o)];if(i.type==="timestamp")return[s,new WM(i,this,o)];if(i.type==="boolean")return[s,new VM(i,this,o)];if(i.type==="json")return[s,new YM(i,this,o)];if(i.type==="sql native")return[s,new KM(i,this,o)]}))}return this._fieldMap}get allFields(){return[...this.fieldMap.values()]}get allFieldsWithOrder(){var e,r,i;if(!this._allFieldsWithOrder){const s=[...((i=(r=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||r===void 0?void 0:r.orderBy)===null||i===void 0?void 0:i.map(u=>{if(typeof u.field=="string")return{field:this.fieldMap.get(u.field),dir:u.dir};throw new Error("Does not support mapping order by from number.")}))||[]],o=new Set(s.map(u=>u.field.name));this._allFieldsWithOrder=[...s,...this.allFields.filter(u=>!o.has(u.name)).map(u=>({field:u,dir:"asc"}))]}return this._allFieldsWithOrder}get intrinsicFields(){return[...this.fieldMap.values()].filter(e=>e.isIntrinsic())}get dimensions(){return[...this.allFieldsWithOrder].filter(e=>e.field.isAtomicField()&&e.field.sourceWasDimension())}getFieldByName(e){const r=this.fieldMap.get(e);if(r===void 0)throw new Error(`No such field ${e}.`);return r}getFieldByNameIfExists(e){return this.fieldMap.get(e)}get primaryKey(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.primaryKey}get parentExplore(){return this._parentExplore}hasParentExplore(){return this instanceof ZM}get filters(){var e;return(0,li.isSourceDef)(this.structDef)?((e=this.structDef.resultMetadata)===null||e===void 0?void 0:e.filterList)||[]:[]}get limit(){var e,r;return(r=(e=this.sourceStructDef)===null||e===void 0?void 0:e.resultMetadata)===null||r===void 0?void 0:r.limit}get structDef(){return this._structDef}get queryTimezone(){var e;return(e=this.sourceStructDef)===null||e===void 0?void 0:e.queryTimezone}get sourceStructDef(){if((0,li.isSourceDef)(this.structDef))return this.structDef}toJSON(){var e,r;return{_structDef:this._structDef,sourceExplore:(e=this.sourceExplore)===null||e===void 0?void 0:e.toJSON(),_parentExplore:(r=this._parentExplore)===null||r===void 0?void 0:r.toJSON()}}static fromJSON(e){const r=e._parentExplore!==void 0?Ps.fromJSON(e._parentExplore):void 0,i=e.sourceExplore!==void 0?Ps.fromJSON(e.sourceExplore):void 0;return new Ps(e._structDef,r,i)}get location(){return this.structDef.location}}we.Explore=Ps;var Ba;(function(t){t.String="string",t.Number="number",t.Boolean="boolean",t.Date="date",t.Timestamp="timestamp",t.Json="json",t.NativeUnsupported="sql native",t.Error="error"})(Ba||(we.AtomicFieldType=Ba={}));class Gc extends zM{constructor(e,r,i){super(e.as||e.name,r,i),this.fieldTypeDef=e,this.parent=r}get type(){switch(this.fieldTypeDef.type){case"string":return Ba.String;case"boolean":return Ba.Boolean;case"date":return Ba.Date;case"timestamp":return Ba.Timestamp;case"number":return Ba.Number;case"json":return Ba.Json;case"sql native":return Ba.NativeUnsupported;case"error":return Ba.Error;case"record":case"array":throw new Error(`MTOY TODO IMPLEMENT Atomic ${this.fieldTypeDef.type}`);default:{const e=this.fieldTypeDef;throw new Error(`Can't make an atomic field from ${e}`)}}}tagParse(e){return e=(0,$n.addModelScope)(e,this.parent.modelTag),(0,$n.annotationToTag)(this.fieldTypeDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.fieldTypeDef.annotation,e)}isIntrinsic(){return(0,li.fieldIsIntrinsic)(this.fieldTypeDef)}isQueryField(){return!1}isExploreField(){return!1}isAtomicField(){return!0}isCalculation(){return(0,li.expressionIsCalculation)(this.fieldTypeDef.expressionType)}get sourceField(){throw new Error}get sourceClasses(){const e=this.fieldTypeDef.name||this.fieldTypeDef.as;return e?[e]:[]}get referenceId(){var e;return(e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.referenceId}sourceWasMeasure(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"}sourceWasMeasureLike(){var e,r;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="measure"||((r=this.fieldTypeDef.resultMetadata)===null||r===void 0?void 0:r.fieldKind)==="struct"}sourceWasDimension(){var e;return((e=this.fieldTypeDef.resultMetadata)===null||e===void 0?void 0:e.fieldKind)==="dimension"}hasParentExplore(){return!0}isString(){return this instanceof JM}isNumber(){return this instanceof TR}isDate(){return this instanceof GM}isBoolean(){return this instanceof VM}isJSON(){return this instanceof YM}isTimestamp(){return this instanceof WM}isUnsupported(){return this instanceof KM}get parentExplore(){return this.parent}get expression(){const e=".",r=this.fieldTypeDef.resultMetadata;return(r==null?void 0:r.sourceExpression)||(r!=null&&r.sourceField.includes(e)?r==null?void 0:r.sourceField:this.name)}get location(){return this.fieldTypeDef.location}}we.AtomicField=Gc;var cd;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year"})(cd||(we.DateTimeframe=cd={}));var $a;(function(t){t.Day="day",t.Week="week",t.Month="month",t.Quarter="quarter",t.Year="year",t.Second="second",t.Hour="hour",t.Minute="minute"})($a||(we.TimestampTimeframe=$a={}));class GM extends Gc{constructor(e,r,i){super(e,r,i),this.fieldDateDef=e}get timeframe(){if(this.fieldDateDef.timeframe!==void 0)switch(this.fieldDateDef.timeframe){case"day":return cd.Day;case"week":return cd.Week;case"month":return cd.Month;case"quarter":return cd.Quarter;case"year":return cd.Year}}}we.DateField=GM;class WM extends Gc{constructor(e,r,i){super(e,r,i),this.fieldTimestampDef=e}get timeframe(){if(this.fieldTimestampDef.timeframe!==void 0)switch(this.fieldTimestampDef.timeframe){case"day":return $a.Day;case"week":return $a.Week;case"month":return $a.Month;case"quarter":return $a.Quarter;case"year":return $a.Year;case"second":return $a.Second;case"hour":return $a.Hour;case"minute":return $a.Minute}}}we.TimestampField=WM;class TR extends Gc{constructor(e,r,i){super(e,r,i),this.fieldNumberDef=e}}we.NumberField=TR;class VM extends Gc{constructor(e,r,i){super(e,r,i),this.fieldBooleanDef=e}}we.BooleanField=VM;class YM extends Gc{constructor(e,r,i){super(e,r,i),this.fieldJSONDef=e}}we.JSONField=YM;class KM extends Gc{constructor(e,r,i){super(e,r,i),this.fieldUnsupportedDef=e}get rawType(){return this.fieldUnsupportedDef.rawType}}we.UnsupportedField=KM;class JM extends Gc{constructor(e,r,i){super(e,r,i),this.fieldStringDef=e}}we.StringField=JM;class lxe extends zM{constructor(e,r,i){super(e.as||e.name,r,i),this.turtleDef=e}get source(){return this.sourceQuery}isIntrinsic(){return!1}get location(){return this.turtleDef.location}}we.Query=lxe;class XM extends lxe{constructor(e,r,i){super(e,r,i),this.parent=r}tagParse(e){return e=(0,$n.addModelScope)(e,this.parent.modelTag),(0,$n.annotationToTag)(this.turtleDef.annotation,e)}getTaglines(e){return(0,$n.annotationToTaglines)(this.turtleDef.annotation,e)}isQueryField(){return!0}isExploreField(){return!1}isAtomicField(){return!1}get sourceClasses(){const e=this.turtleDef.name||this.turtleDef.as;return e?[e]:[]}hasParentExplore(){return!0}get parentExplore(){return this.parent}get expression(){return this.name}}we.QueryField=XM;var N2;(function(t){t.OneToOne="one_to_one",t.OneToMany="one_to_many",t.ManyToOne="many_to_one"})(N2||(we.JoinRelationship=N2={}));class ZM extends Ps{constructor(e,r,i){super(e,r,i),this._parentExplore=r}get joinRelationship(){if((0,li.isJoined)(this.structDef))switch(this.structDef.join){case"one":return N2.OneToOne;case"many":case"cross":return N2.ManyToOne}throw new Error("A source field must have a join relationship.")}get isRecord(){return this.joinRelationship===N2.OneToOne}get isArray(){return this.joinRelationship!==N2.OneToOne}tagParse(e){return e=(0,$n.addModelScope)(e,this._parentExplore.modelTag),(0,$n.annotationToTag)(this._structDef.annotation,e)}isQueryField(){return!1}isExploreField(){return!0}isAtomicField(){return!1}get parentExplore(){return this._parentExplore}get sourceClasses(){const e=this.structDef.name||this.structDef.as;return e?[e]:[]}}we.ExploreField=ZM;class eP{constructor({urlReader:e,connections:r,connection:i,eventStream:s,cacheManager:o}){if(this.isTestRuntime=!1,r===void 0){if(i===void 0)throw new Error("A LookupConnection<Connection> or Connection is required.");r={lookupConnection:()=>Promise.resolve(i)}}e===void 0&&(e=new uxe),this._urlReader=e,this._connections=r,this._eventStream=s,this._cacheManager=o}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}loadModel(e,r){const{refreshSchemaCache:i,noThrowOnError:s}=r||{};this.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0});const o=e instanceof URL?{url:e}:{source:e};return new EE(this,async()=>n0.compile({...o,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:i,noThrowOnError:s,eventStream:this.eventStream,replaceMaterializedReferences:r==null?void 0:r.replaceMaterializedReferences,materializedTablePrefix:r==null?void 0:r.materializedTablePrefix,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,cacheManager:this.cacheManager}),r)}_loadModelFromModelDef(e,r){return new EE(this,async()=>new O2(e,[],[]),r)}loadQuery(e,r){return this.loadModel(e,r).loadFinalQuery()}loadQueryByIndex(e,r,i){return this.loadModel(e,i).loadQueryByIndex(r,i)}loadQueryByName(e,r,i){return this.loadModel(e,i).loadQueryByName(r,i)}getModel(e,r){return this.loadModel(e,r).getModel()}getQuery(e,r){return this.loadQuery(e,r).getPreparedQuery()}getQueryByIndex(e,r,i){return this.loadQueryByIndex(e,r,i).getPreparedQuery()}getQueryByName(e,r,i){return this.loadQueryByName(e,r,i).getPreparedQuery()}}we.Runtime=eP;class fxt extends eP{constructor({urlReader:e,connections:r}){super({connections:bR.fromArray(r),urlReader:e}),this.rawConnections=r}}we.ConnectionRuntime=fxt;class xxt extends eP{constructor({urlReader:e,connection:r,eventStream:i,cacheManager:s}){super({urlReader:e,eventStream:i,cacheManager:s,connection:r}),this.connection=r}get supportsNesting(){return(0,HM.getDialect)(this.connection.dialectName).supportsNesting}quote(e){return(0,HM.getDialect)(this.connection.dialectName).sqlMaybeQuoteIdentifier(e)}get dialect(){return(0,HM.getDialect)(this.connection.dialectName)}getQuoter(){return e=>this.quote(e.toString())}}we.SingleConnectionRuntime=xxt;class RR{constructor(e,r){this.runtime=e,this._materialize=r}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(e,r){return new cxe(this.runtime,e,r)}makeExploreMaterializer(e,r){return new xxe(this.runtime,e,r)}makePreparedResultMaterializer(e){return new fxe(this.runtime,e)}}class EE extends RR{constructor(e,r,i){super(e,r),this.runtime=e,this.compileQueryOptions=i}loadFinalQuery(e){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...e})}loadQueryByIndex(e,r){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(e),{...this.compileQueryOptions,...r})}loadQueryByName(e,r){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(e),{...this.compileQueryOptions,...r})}loadQuery(e,r){const{refreshSchemaCache:i,noThrowOnError:s}=r||{};return this.makeQueryMaterializer(async()=>{const o=this.runtime.urlReader,u=this.runtime.connections;this.runtime.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0});const a=e instanceof URL?{url:e}:{source:e},l=await this.getModel();return(await n0.compile({...a,urlReader:o,connections:u,model:l,refreshSchemaCache:i,noThrowOnError:s,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,...this.compileQueryOptions})).preparedQuery})}extendModel(e,r){return this.runtime.isTestRuntime&&(r===void 0?r={testEnvironment:!0}:r={...r,testEnvironment:!0}),new EE(this.runtime,async()=>{const i=this.runtime.urlReader,s=this.runtime.connections,o=e instanceof URL?{url:e}:{source:e},u=await this.getModel();return await n0.compile({...o,urlReader:i,connections:s,model:u,refreshSchemaCache:r==null?void 0:r.refreshSchemaCache,noThrowOnError:r==null?void 0:r.noThrowOnError,importBaseURL:r==null?void 0:r.importBaseURL,testEnvironment:r==null?void 0:r.testEnvironment,...this.compileQueryOptions})},r)}async search(e,r,i=1e3,s=void 0,o){const u=await this.materialize(),a=new li.QueryModel(u._modelDef,o),l=u.getExploreByName(e).structDef;if(!(0,li.isSourceDef)(l))throw new Error("Source to be searched was unexpectedly, not a source");const c=l.connection,f=await this.runtime.connections.lookupConnection(c);return await a.searchIndex(f,e,r,i,s)}async searchValueMap(e,r=10,i){const o=(await this.materialize()).getExploreByName(e);if(!(0,li.isSourceDef)(o.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let u="{index: *}";o.getFieldByNameIfExists("search_index")&&(u="search_index");const a=`
1468
1468
  run: ${e}
1469
1469
  -> ${u}
@@ -123330,10 +123330,28 @@ var mk = {}, Bp = {}, z0e = {};
123330
123330
  }
123331
123331
  }
123332
123332
  }, x = {
123333
+ extract: {
123334
+ takes: {
123335
+ input_val: "string",
123336
+ pattern: ["string", "regular expression"]
123337
+ },
123338
+ returns: "string",
123339
+ impl: { function: "regexp_extract" }
123340
+ },
123341
+ extract_group: {
123342
+ takes: {
123343
+ input_val: "string",
123344
+ pattern: ["string", "regular expression"],
123345
+ group: "number"
123346
+ },
123347
+ returns: "string",
123348
+ impl: { function: "regexp_extract" }
123349
+ }
123350
+ }, h = {
123333
123351
  takes: {},
123334
123352
  returns: { calculation: "number" },
123335
123353
  impl: { function: "PERCENT_RANK", needsWindowOrderBy: !0 }
123336
- }, h = {
123354
+ }, p = {
123337
123355
  skip_nulls: {
123338
123356
  takes: {
123339
123357
  array_v: { array: r },
@@ -123353,7 +123371,7 @@ var mk = {}, Bp = {}, z0e = {};
123353
123371
  returns: "string",
123354
123372
  impl: { function: "ARRAY_JOIN" }
123355
123373
  }
123356
- }, p = {
123374
+ }, m = {
123357
123375
  num_to_num: {
123358
123376
  takes: { start: "number", stop: "number" },
123359
123377
  returns: { array: "number" },
@@ -123369,14 +123387,14 @@ var mk = {}, Bp = {}, z0e = {};
123369
123387
  returns: { array: "date" },
123370
123388
  impl: { function: "SEQUENCE" }
123371
123389
  }
123372
- }, m = {
123390
+ }, g = {
123373
123391
  takes: { str: "string" },
123374
123392
  returns: "string",
123375
123393
  impl: { sql: "REVERSE(CAST(${str} AS VARCHAR))" }
123376
123394
  };
123377
123395
  t.TRINO_DIALECT_FUNCTIONS = {
123378
123396
  // string functions
123379
- reverse: m,
123397
+ reverse: g,
123380
123398
  // aggregate functions
123381
123399
  // TODO: Approx percentile can be called with a third argument; we probably
123382
123400
  // want to implement that at some point
@@ -123451,8 +123469,10 @@ var mk = {}, Bp = {}, z0e = {};
123451
123469
  date_parse: a,
123452
123470
  ...(0, e.def)("from_unixtime", { unixtime: "number" }, "timestamp"),
123453
123471
  json_extract_scalar: l,
123472
+ // regex fnctions
123454
123473
  regexp_like: c,
123455
123474
  regexp_replace: f,
123475
+ regexp_extract: x,
123456
123476
  ...(0, e.def)("to_unixtime", { ts_val: "timestamp" }, "number"),
123457
123477
  ...(0, e.def)("url_extract_fragment", { url: "string" }, "string"),
123458
123478
  ...(0, e.def)("url_extract_host", { url: "string" }, "string"),
@@ -123462,10 +123482,10 @@ var mk = {}, Bp = {}, z0e = {};
123462
123482
  ...(0, e.def)("url_extract_protocol", { url: "string" }, "string"),
123463
123483
  ...(0, e.def)("url_extract_query", { url: "string" }, "string"),
123464
123484
  // window functions
123465
- percent_rank: x,
123485
+ percent_rank: h,
123466
123486
  // array function
123467
- array_join: h,
123468
- sequence: p,
123487
+ array_join: p,
123488
+ sequence: m,
123469
123489
  ...(0, e.def)("array_distinct", { x: { array: r } }, { array: r }),
123470
123490
  ...(0, e.def)("array_except", { x: { array: r }, y: { array: r } }, { array: r }),
123471
123491
  ...(0, e.def)("array_intersect", { x: { array: r }, y: { array: r } }, { array: r }),
@@ -123486,6 +123506,7 @@ var mk = {}, Bp = {}, z0e = {};
123486
123506
  ...(0, e.def)("repeat", { x: r, n: "number" }, { array: r }),
123487
123507
  ...(0, e.def)("slice", { x: { array: r }, start: "number", len: "number" }, { array: r }),
123488
123508
  ...(0, e.def)("split", { to_split: "string", seperator: "string" }, { array: "string" }),
123509
+ ...(0, e.def)("split_part", { to_split: "string", seperator: "string", idx: "number" }, "string"),
123489
123510
  ...(0, e.def)("trim_array", { x: { array: r }, n: "number" }, { array: r }),
123490
123511
  ...(0, e.def)("array_split_into_chunks", { x: { array: r }, n: "number" }, { array: { array: r } })
123491
123512
  }, t.PRESTO_DIALECT_FUNCTIONS = {
@@ -123518,7 +123539,7 @@ var mk = {}, Bp = {}, z0e = {};
123518
123539
  }
123519
123540
  },
123520
123541
  reverse: {
123521
- string_reverse: m,
123542
+ string_reverse: g,
123522
123543
  ...(0, e.def)("reverse", { x: { array: r } }, { array: r })
123523
123544
  },
123524
123545
  ...(0, e.def)("array_average", { x: { array: r } }, "number"),
@@ -153178,7 +153199,7 @@ Kp.malloyToQuery = Rpt;
153178
153199
  var Ie = {}, ID = {};
153179
153200
  Object.defineProperty(ID, "__esModule", { value: !0 });
153180
153201
  ID.MALLOY_VERSION = void 0;
153181
- ID.MALLOY_VERSION = "0.0.264";
153202
+ ID.MALLOY_VERSION = "0.0.265";
153182
153203
  Object.defineProperty(Ie, "__esModule", { value: !0 });
153183
153204
  Ie.InMemoryModelCache = Ie.CacheManager = Ie.CSVWriter = Ie.JSONWriter = Ie.DataWriter = Ie.DataRecord = Ie.DataArray = Ie.Result = Ie.ExploreMaterializer = Ie.PreparedResultMaterializer = Ie.QueryMaterializer = Ie.ModelMaterializer = Ie.SingleConnectionRuntime = Ie.ConnectionRuntime = Ie.Runtime = Ie.ExploreField = Ie.JoinRelationship = Ie.QueryField = Ie.Query = Ie.StringField = Ie.UnsupportedField = Ie.JSONField = Ie.BooleanField = Ie.NumberField = Ie.TimestampField = Ie.DateField = Ie.TimestampTimeframe = Ie.DateTimeframe = Ie.AtomicField = Ie.AtomicFieldType = Ie.Explore = Ie.SourceRelationship = Ie.FixedConnectionMap = Ie.InMemoryURLReader = Ie.EmptyURLReader = Ie.PreparedResult = Ie.DocumentCompletion = Ie.DocumentSymbol = Ie.DocumentPosition = Ie.DocumentRange = Ie.DocumentTablePath = Ie.Parse = Ie.PreparedQuery = Ie.Model = Ie.MalloyError = Ie.Malloy = void 0;
153184
153205
  const wY = PT, si = Yi, NY = Wr, J7 = z2, Dpt = ID, Opt = W2, Mn = pi, Fpt = t0, LY = "internal://internal.malloy";