sqlingo 0.11.0 → 0.11.2
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.
- package/CHANGELOG.md +30 -0
- package/dist/{chunk-WOGYHEXV.js → chunk-24VN32FG.js} +2 -2
- package/dist/{chunk-PCQ3YF4L.js → chunk-35GMMRT3.js} +2 -2
- package/dist/chunk-3NY73AG6.cjs +2 -0
- package/dist/{chunk-4RVK2YCT.cjs.map → chunk-3NY73AG6.cjs.map} +1 -1
- package/dist/chunk-46ZYFFUB.cjs +2 -0
- package/dist/chunk-46ZYFFUB.cjs.map +1 -0
- package/dist/{chunk-KZC6DSTN.js → chunk-5AKAN2I7.js} +2 -2
- package/dist/{chunk-M2Y2RTS7.js → chunk-5T2NZX3J.js} +2 -2
- package/dist/{chunk-63BV5DQI.js → chunk-6VHNVAGL.js} +2 -2
- package/dist/chunk-7UY2GD7U.cjs +2 -0
- package/dist/{chunk-RYC7OPYP.cjs.map → chunk-7UY2GD7U.cjs.map} +1 -1
- package/dist/chunk-ADYA6YNL.cjs +2 -0
- package/dist/{chunk-ZNRRWFL3.cjs.map → chunk-ADYA6YNL.cjs.map} +1 -1
- package/dist/{chunk-Y7WPLMBG.js → chunk-BB2NJ5Z5.js} +2 -2
- package/dist/chunk-C27ZLT7L.cjs +2 -0
- package/dist/{chunk-F3ZS7WE7.cjs.map → chunk-C27ZLT7L.cjs.map} +1 -1
- package/dist/{chunk-BI7ADWS4.js → chunk-CNQXTBAR.js} +13 -13
- package/dist/chunk-CNQXTBAR.js.map +1 -0
- package/dist/chunk-CO6DYSIN.cjs +2 -0
- package/dist/{chunk-4A7Y3HEZ.cjs.map → chunk-CO6DYSIN.cjs.map} +1 -1
- package/dist/{chunk-7KRL33KM.js → chunk-CWTDCJNP.js} +2 -2
- package/dist/{chunk-EIKNOQKC.js → chunk-DZ36JJ2K.js} +2 -2
- package/dist/chunk-FAV7YXGM.cjs +2 -0
- package/dist/{chunk-5IXKXNGT.cjs.map → chunk-FAV7YXGM.cjs.map} +1 -1
- package/dist/chunk-HGX7B6SE.cjs +2 -0
- package/dist/{chunk-XJTXPIIZ.cjs.map → chunk-HGX7B6SE.cjs.map} +1 -1
- package/dist/chunk-HUMCE7OS.cjs +2 -0
- package/dist/{chunk-ELNLOA2E.cjs.map → chunk-HUMCE7OS.cjs.map} +1 -1
- package/dist/chunk-I346N252.cjs +2 -0
- package/dist/{chunk-HI6TEZNZ.cjs.map → chunk-I346N252.cjs.map} +1 -1
- package/dist/{chunk-JDWH2L5J.js → chunk-IOCNJOGM.js} +2 -2
- package/dist/chunk-JWY7HB5W.cjs +2 -0
- package/dist/{chunk-7HHE6BEK.cjs.map → chunk-JWY7HB5W.cjs.map} +1 -1
- package/dist/chunk-KJABXPMW.cjs +2 -0
- package/dist/{chunk-6ORIVOMP.cjs.map → chunk-KJABXPMW.cjs.map} +1 -1
- package/dist/{chunk-DWNEV32M.js → chunk-LGVPUDSN.js} +2 -2
- package/dist/{chunk-QIRPUDT3.js → chunk-LH2F5QN4.js} +2 -2
- package/dist/chunk-LMYBRBST.cjs +3 -0
- package/dist/{chunk-IUT7XJBJ.cjs.map → chunk-LMYBRBST.cjs.map} +1 -1
- package/dist/chunk-M6VUHVCA.cjs +19 -0
- package/dist/chunk-M6VUHVCA.cjs.map +1 -0
- package/dist/chunk-MYSFSGYF.cjs +2 -0
- package/dist/{chunk-7KU5NSYD.cjs.map → chunk-MYSFSGYF.cjs.map} +1 -1
- package/dist/{chunk-DSMZVZEV.js → chunk-OL2ZR42U.js} +2 -2
- package/dist/{chunk-WL5JZCQZ.js → chunk-OUVPP5P3.js} +2 -2
- package/dist/chunk-QGM3ALG2.js +2 -0
- package/dist/chunk-QGM3ALG2.js.map +1 -0
- package/dist/chunk-QMTVNC6S.cjs +2 -0
- package/dist/{chunk-GP5M56MU.cjs.map → chunk-QMTVNC6S.cjs.map} +1 -1
- package/dist/{chunk-UC5VGBMU.js → chunk-SK5E25IR.js} +2 -2
- package/dist/{chunk-EU573JLJ.js → chunk-TDHUEJMV.js} +2 -2
- package/dist/{chunk-KQXRELYR.js → chunk-XQFP2APL.js} +2 -2
- package/dist/{chunk-D4EP26GZ.js → chunk-Y2BKXUW3.js} +2 -2
- package/dist/chunk-YHYAYLA2.cjs +2 -0
- package/dist/{chunk-7ORDN56U.cjs.map → chunk-YHYAYLA2.cjs.map} +1 -1
- package/dist/chunk-YLWTJCZO.cjs +4 -0
- package/dist/{chunk-TLSWICX2.cjs.map → chunk-YLWTJCZO.cjs.map} +1 -1
- package/dist/chunk-ZP4YOUOR.cjs +2 -0
- package/dist/{chunk-273ZEZC3.cjs.map → chunk-ZP4YOUOR.cjs.map} +1 -1
- package/dist/dialects/athena.cjs +1 -1
- package/dist/dialects/athena.d.cts +1 -1
- package/dist/dialects/athena.d.ts +1 -1
- package/dist/dialects/athena.js +1 -1
- package/dist/dialects/bigquery.cjs +1 -1
- package/dist/dialects/bigquery.d.cts +1 -1
- package/dist/dialects/bigquery.d.ts +1 -1
- package/dist/dialects/bigquery.js +1 -1
- package/dist/dialects/clickhouse.cjs +1 -1
- package/dist/dialects/clickhouse.d.cts +1 -1
- package/dist/dialects/clickhouse.d.ts +1 -1
- package/dist/dialects/clickhouse.js +1 -1
- package/dist/dialects/databricks.cjs +1 -1
- package/dist/dialects/databricks.d.cts +1 -1
- package/dist/dialects/databricks.d.ts +1 -1
- package/dist/dialects/databricks.js +1 -1
- package/dist/dialects/doris.cjs +1 -1
- package/dist/dialects/doris.d.cts +1 -1
- package/dist/dialects/doris.d.ts +1 -1
- package/dist/dialects/doris.js +1 -1
- package/dist/dialects/dremio.cjs +1 -1
- package/dist/dialects/dremio.d.cts +1 -1
- package/dist/dialects/dremio.d.ts +1 -1
- package/dist/dialects/dremio.js +1 -1
- package/dist/dialects/drill.cjs +1 -1
- package/dist/dialects/drill.d.cts +1 -1
- package/dist/dialects/drill.d.ts +1 -1
- package/dist/dialects/drill.js +1 -1
- package/dist/dialects/druid.cjs +1 -1
- package/dist/dialects/druid.d.cts +1 -1
- package/dist/dialects/druid.d.ts +1 -1
- package/dist/dialects/druid.js +1 -1
- package/dist/dialects/duckdb.cjs +13 -13
- package/dist/dialects/duckdb.d.cts +1 -1
- package/dist/dialects/duckdb.d.ts +1 -1
- package/dist/dialects/duckdb.js +1 -1
- package/dist/dialects/dune.cjs +1 -1
- package/dist/dialects/dune.d.cts +1 -1
- package/dist/dialects/dune.d.ts +1 -1
- package/dist/dialects/dune.js +1 -1
- package/dist/dialects/exasol.cjs +1 -1
- package/dist/dialects/exasol.d.cts +1 -1
- package/dist/dialects/exasol.d.ts +1 -1
- package/dist/dialects/exasol.js +1 -1
- package/dist/dialects/fabric.cjs +1 -1
- package/dist/dialects/fabric.d.cts +1 -1
- package/dist/dialects/fabric.d.ts +1 -1
- package/dist/dialects/fabric.js +1 -1
- package/dist/dialects/hive.cjs +1 -1
- package/dist/dialects/hive.d.cts +1 -1
- package/dist/dialects/hive.d.ts +1 -1
- package/dist/dialects/hive.js +1 -1
- package/dist/dialects/materialize.cjs +1 -1
- package/dist/dialects/materialize.d.cts +1 -1
- package/dist/dialects/materialize.d.ts +1 -1
- package/dist/dialects/materialize.js +1 -1
- package/dist/dialects/mysql.cjs +1 -1
- package/dist/dialects/mysql.d.cts +1 -1
- package/dist/dialects/mysql.d.ts +1 -1
- package/dist/dialects/mysql.js +1 -1
- package/dist/dialects/oracle.cjs +1 -1
- package/dist/dialects/oracle.cjs.map +1 -1
- package/dist/dialects/oracle.d.cts +7 -1
- package/dist/dialects/oracle.d.ts +7 -1
- package/dist/dialects/oracle.js +1 -1
- package/dist/dialects/oracle.js.map +1 -1
- package/dist/dialects/postgres.cjs +1 -1
- package/dist/dialects/postgres.d.cts +1 -1
- package/dist/dialects/postgres.d.ts +1 -1
- package/dist/dialects/postgres.js +1 -1
- package/dist/dialects/presto.cjs +1 -1
- package/dist/dialects/presto.d.cts +1 -1
- package/dist/dialects/presto.d.ts +1 -1
- package/dist/dialects/presto.js +1 -1
- package/dist/dialects/prql.cjs +1 -1
- package/dist/dialects/prql.d.cts +1 -1
- package/dist/dialects/prql.d.ts +1 -1
- package/dist/dialects/prql.js +1 -1
- package/dist/dialects/redshift.cjs +1 -1
- package/dist/dialects/redshift.d.cts +1 -1
- package/dist/dialects/redshift.d.ts +1 -1
- package/dist/dialects/redshift.js +1 -1
- package/dist/dialects/risingwave.cjs +1 -1
- package/dist/dialects/risingwave.d.cts +1 -1
- package/dist/dialects/risingwave.d.ts +1 -1
- package/dist/dialects/risingwave.js +1 -1
- package/dist/dialects/singlestore.cjs +1 -1
- package/dist/dialects/singlestore.d.cts +1 -1
- package/dist/dialects/singlestore.d.ts +1 -1
- package/dist/dialects/singlestore.js +1 -1
- package/dist/dialects/snowflake.cjs +1 -1
- package/dist/dialects/snowflake.d.cts +1 -1
- package/dist/dialects/snowflake.d.ts +1 -1
- package/dist/dialects/snowflake.js +1 -1
- package/dist/dialects/solr.cjs +1 -1
- package/dist/dialects/solr.d.cts +1 -1
- package/dist/dialects/solr.d.ts +1 -1
- package/dist/dialects/solr.js +1 -1
- package/dist/dialects/spark.cjs +1 -1
- package/dist/dialects/spark.d.cts +1 -1
- package/dist/dialects/spark.d.ts +1 -1
- package/dist/dialects/spark.js +1 -1
- package/dist/dialects/spark2.cjs +1 -1
- package/dist/dialects/spark2.d.cts +1 -1
- package/dist/dialects/spark2.d.ts +1 -1
- package/dist/dialects/spark2.js +1 -1
- package/dist/dialects/sqlite.cjs +1 -1
- package/dist/dialects/sqlite.d.cts +1 -1
- package/dist/dialects/sqlite.d.ts +1 -1
- package/dist/dialects/sqlite.js +1 -1
- package/dist/dialects/starrocks.cjs +1 -1
- package/dist/dialects/starrocks.d.cts +1 -1
- package/dist/dialects/starrocks.d.ts +1 -1
- package/dist/dialects/starrocks.js +1 -1
- package/dist/dialects/tableau.cjs +1 -1
- package/dist/dialects/tableau.d.cts +1 -1
- package/dist/dialects/tableau.d.ts +1 -1
- package/dist/dialects/tableau.js +1 -1
- package/dist/dialects/teradata.cjs +1 -1
- package/dist/dialects/teradata.d.cts +1 -1
- package/dist/dialects/teradata.d.ts +1 -1
- package/dist/dialects/teradata.js +1 -1
- package/dist/dialects/trino.cjs +1 -1
- package/dist/dialects/trino.d.cts +1 -1
- package/dist/dialects/trino.d.ts +1 -1
- package/dist/dialects/trino.js +1 -1
- package/dist/dialects/tsql.cjs +1 -1
- package/dist/dialects/tsql.d.cts +1 -1
- package/dist/dialects/tsql.d.ts +1 -1
- package/dist/dialects/tsql.js +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{tokens-wptAdPaw.d.ts → tokens-BSc93AMH.d.cts} +3 -1
- package/dist/{tokens-wptAdPaw.d.cts → tokens-BSc93AMH.d.ts} +3 -1
- package/package.json +1 -1
- package/dist/chunk-273ZEZC3.cjs +0 -2
- package/dist/chunk-4A7Y3HEZ.cjs +0 -2
- package/dist/chunk-4RVK2YCT.cjs +0 -2
- package/dist/chunk-5IXKXNGT.cjs +0 -2
- package/dist/chunk-6ORIVOMP.cjs +0 -2
- package/dist/chunk-7HHE6BEK.cjs +0 -2
- package/dist/chunk-7KU5NSYD.cjs +0 -2
- package/dist/chunk-7ORDN56U.cjs +0 -2
- package/dist/chunk-A235SCTJ.cjs +0 -19
- package/dist/chunk-A235SCTJ.cjs.map +0 -1
- package/dist/chunk-BI7ADWS4.js.map +0 -1
- package/dist/chunk-ELNLOA2E.cjs +0 -2
- package/dist/chunk-F3ZS7WE7.cjs +0 -2
- package/dist/chunk-GP5M56MU.cjs +0 -2
- package/dist/chunk-HI6TEZNZ.cjs +0 -2
- package/dist/chunk-IUT7XJBJ.cjs +0 -3
- package/dist/chunk-QFJMFEIG.js +0 -2
- package/dist/chunk-QFJMFEIG.js.map +0 -1
- package/dist/chunk-RYC7OPYP.cjs +0 -2
- package/dist/chunk-TLSWICX2.cjs +0 -4
- package/dist/chunk-WTMSWS2W.cjs +0 -2
- package/dist/chunk-WTMSWS2W.cjs.map +0 -1
- package/dist/chunk-XJTXPIIZ.cjs +0 -2
- package/dist/chunk-ZNRRWFL3.cjs +0 -2
- /package/dist/{chunk-WOGYHEXV.js.map → chunk-24VN32FG.js.map} +0 -0
- /package/dist/{chunk-PCQ3YF4L.js.map → chunk-35GMMRT3.js.map} +0 -0
- /package/dist/{chunk-KZC6DSTN.js.map → chunk-5AKAN2I7.js.map} +0 -0
- /package/dist/{chunk-M2Y2RTS7.js.map → chunk-5T2NZX3J.js.map} +0 -0
- /package/dist/{chunk-63BV5DQI.js.map → chunk-6VHNVAGL.js.map} +0 -0
- /package/dist/{chunk-Y7WPLMBG.js.map → chunk-BB2NJ5Z5.js.map} +0 -0
- /package/dist/{chunk-7KRL33KM.js.map → chunk-CWTDCJNP.js.map} +0 -0
- /package/dist/{chunk-EIKNOQKC.js.map → chunk-DZ36JJ2K.js.map} +0 -0
- /package/dist/{chunk-JDWH2L5J.js.map → chunk-IOCNJOGM.js.map} +0 -0
- /package/dist/{chunk-DWNEV32M.js.map → chunk-LGVPUDSN.js.map} +0 -0
- /package/dist/{chunk-QIRPUDT3.js.map → chunk-LH2F5QN4.js.map} +0 -0
- /package/dist/{chunk-DSMZVZEV.js.map → chunk-OL2ZR42U.js.map} +0 -0
- /package/dist/{chunk-WL5JZCQZ.js.map → chunk-OUVPP5P3.js.map} +0 -0
- /package/dist/{chunk-UC5VGBMU.js.map → chunk-SK5E25IR.js.map} +0 -0
- /package/dist/{chunk-EU573JLJ.js.map → chunk-TDHUEJMV.js.map} +0 -0
- /package/dist/{chunk-KQXRELYR.js.map → chunk-XQFP2APL.js.map} +0 -0
- /package/dist/{chunk-D4EP26GZ.js.map → chunk-Y2BKXUW3.js.map} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var
|
|
1
|
+
var H_=Object.create;var lM=Object.defineProperty;var __=Object.getOwnPropertyDescriptor;var rG=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a),$I=a=>{throw TypeError(a)};var W_=(a,e,t)=>e in a?lM(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var n=(a,e)=>lM(a,"name",{value:e,configurable:!0});var j_=(a,e)=>{for(var t in e)lM(a,t,{get:e[t],enumerable:!0})};var Ft=a=>[,,,H_(a?.[rG("metadata")]??null)],iG=["class","method","getter","setter","accessor","field","value","get","set"],BI=a=>a!==void 0&&typeof a!="function"?$I("Function expected"):a,X_=(a,e,t,s,r)=>({kind:iG[a],name:e,metadata:s,addInitializer:i=>t._?$I("Already initialized"):r.push(BI(i||null))}),It=(a,e)=>W_(e,rG("metadata"),a[3]),yt=(a,e,t,s)=>{for(var r=0,i=a[e>>1],o=i&&i.length;r<o;r++)e&1?i[r].call(t):s=i[r].call(t,s);return s},R=(a,e,t,s,r,i)=>{var o,c,p,u,h,g=e&7,x=!!(e&8),f=!!(e&16),T=g>3?a.length+1:g?x?1:2:0,y=iG[g+5],b=g>3&&(a[T-1]=[]),m=a[T]||(a[T]=[]),C=g&&(!f&&!x&&(r=r.prototype),g<5&&(g>3||!f)&&__(g<4?r:{get[t](){return tG(this,i)},set[t](U){return sG(this,i,U)}},t));g?f&&g<4&&n(i,(g>2?"set ":g>1?"get ":"")+t):n(r,t);for(var q=s.length-1;q>=0;q--)u=X_(g,t,p={},a[3],m),g&&(u.static=x,u.private=f,h=u.access={has:f?U=>J_(r,U):U=>t in U},g^3&&(h.get=f?U=>(g^1?tG:z_)(U,r,g^4?i:C.get):U=>U[t]),g>2&&(h.set=f?(U,_)=>sG(U,r,_,g^4?i:C.set):(U,_)=>U[t]=_)),c=(0,s[q])(g?g<4?f?i:C[y]:g>4?void 0:{get:C.get,set:C.set}:r,u),p._=1,g^4||c===void 0?BI(c)&&(g>4?b.unshift(c):g?f?i=c:C[y]=c:r=c):typeof c!="object"||c===null?$I("Object expected"):(BI(o=c.get)&&(C.get=o),BI(o=c.set)&&(C.set=o),BI(o=c.init)&&b.unshift(o));return g||It(a,r),C&&lM(r,t,C),f?g^4?i:C:r};var _k=(a,e,t)=>e.has(a)||$I("Cannot "+t),J_=(a,e)=>Object(e)!==e?$I('Cannot use the "in" operator on this value'):a.has(e),tG=(a,e,t)=>(_k(a,e,"read from private field"),t?t.call(a):e.get(a));var sG=(a,e,t,s)=>(_k(a,e,"write to private field"),s?s.call(a,t):e.set(a,t),t),z_=(a,e,t)=>(_k(a,e,"access private method"),t);var Q_="\x1B[4m",Z_="\x1B[0m";var hM=(r=>(r[r.IGNORE=0]="IGNORE",r[r.WARN=1]="WARN",r[r.RAISE=2]="RAISE",r[r.IMMEDIATE=3]="IMMEDIATE",r))(hM||{}),jk=class jk extends Error{constructor(e){super(e),this.name="SqlglotError","captureStackTrace"in Error&&Error.captureStackTrace(this,this.constructor)}};n(jk,"SqlglotError");var un=jk,Xk=class Xk extends un{constructor(e){super(e),this.name="UnsupportedError","captureStackTrace"in Error&&Error.captureStackTrace(this,this.constructor)}};n(Xk,"UnsupportedError");var kr=Xk,uM=class uM extends un{constructor(e,t){super(e),this.name="ParseError",this.errors=t||[],"captureStackTrace"in Error&&Error.captureStackTrace(this,this.constructor)}static new(e,t,s,r,i,o,c,p){return new uM(e,[{description:t,line:s,col:r,startContext:i,highlight:o,endContext:c,intoExpression:p}])}};n(uM,"ParseError");var Ke=uM,Jk=class Jk extends un{constructor(e){super(e),this.name="TokenError","captureStackTrace"in Error&&Error.captureStackTrace(this,this.constructor)}};n(Jk,"TokenError");var ZE=Jk,zk=class zk extends un{constructor(e){super(e),this.name="OptimizeError","captureStackTrace"in Error&&Error.captureStackTrace(this,this.constructor)}};n(zk,"OptimizeError");var $l=zk,Qk=class Qk extends un{constructor(e){super(e),this.name="SchemaError","captureStackTrace"in Error&&Error.captureStackTrace(this,this.constructor)}};n(Qk,"SchemaError");var is=Qk,Zk=class Zk extends un{constructor(e){super(e),this.name="ExecuteError","captureStackTrace"in Error&&Error.captureStackTrace(this,this.constructor)}};n(Zk,"ExecuteError");var nG=Zk;function aG(a){let{sql:e,positions:t,contextLength:s=100}=a;if(t.length===0)throw new Error("positions must contain at least one [start, end] tuple");let r="",i="",o=0,c=[],p=0,u=[...t].sort((x,f)=>x[0]-f[0]);0<u[0][0]&&(o=u[0][0],r=e.slice(Math.max(0,o-s),o),c.push(r),p=o);for(let[x,f]of u){let T=Math.max(x,p),y=f+1;y<=T||(p<T&&c.push(e.slice(p,T)),c.push(`${Q_}${e.slice(T,y)}${Z_}`),p=y)}p<e.length&&(i=e.slice(p,p+s),c.push(i));let h=c.join(""),g=e.slice(o,p);return{formattedSql:h,startContext:r,highlight:g,endContext:i}}n(aG,"highlightSql");function gM(a,e){let t=a.slice(0,e).map(r=>String(r)),s=a.length-e;return 0<s&&t.push(`... and ${s} more`),t.join(`
|
|
2
2
|
|
|
3
|
-
`)}n(gM,"concatMessages");function Wk(a){return a.flatMap(e=>e.errors)}n(Wk,"mergeErrors");function EM(a,e){return typeof e=="string"?typeof a===e||e==="object"&&a===null:a instanceof e}n(EM,"checkOne");function Z_(a){return typeof a=="string"?`typeof === '${a}'`:a.name??String(a)}n(Z_,"checkerName");function Y(a,...e){return e.some(t=>EM(a,t))}n(Y,"isInstanceOf");function re(a,...e){if(!e.some(t=>EM(a,t))){let t=e.map(Z_).join(" | ");throw new TypeError(`Expected ${t}, got ${typeof a}`)}}n(re,"assertIsInstanceOf");function ct(a,...e){return e.some(t=>EM(a,t))?a:void 0}n(ct,"narrowInstanceOf");function Et(a,...e){let t=[];for(let s of a)e.some(r=>EM(s,r))&&t.push(s);return t}n(Et,"filterInstanceOf");function O(a,e){if(e){let r=new WeakMap;return e.addInitializer(function(){Object.defineProperty(this,e.name,{get(){return r.has(this)||r.set(this,a.call(this)),r.get(this)},set(i){r.set(this,i)},configurable:!0})}),a}let t,s=!1;return()=>(s||(t=a(),s=!0),t)}n(O,"cache");var Kk=new WeakMap;function K_(a){let e=[],t=a;for(;t&&t!==Object&&t.prototype;)e.push(t),t=Object.getPrototypeOf(t);return e}n(K_,"getPrototypeChain");function V(a,...e){let o=class o extends a{};n(o,"MultiInheritClass");let t=o,s=[a,...e],r=[],i=new Set;for(let c of s){let p=K_(c);for(let u of p)i.has(u)||(i.add(u),r.push(u))}for(let c of r){for(let u of Object.getOwnPropertyNames(c.prototype))if(u!=="constructor"&&!Object.getOwnPropertyDescriptor(t.prototype,u)){let h=Object.getOwnPropertyDescriptor(c.prototype,u);h&&Object.defineProperty(t.prototype,u,h)}for(let u of Object.getOwnPropertyNames(c))if(!["prototype","length","name"].includes(u)&&!Object.getOwnPropertyDescriptor(t,u)){let h=Object.getOwnPropertyDescriptor(c,u);h&&Object.defineProperty(t,u,h)}let p=Kk.get(c);p||(p=new Set,Kk.set(c,p),Object.defineProperty(c,Symbol.hasInstance,{value(u){if(this.prototype.isPrototypeOf(Object(u)))return!0;let h=Kk.get(this);if(!h)return!1;let g=u?.constructor;for(;g&&g!==Object;){if(h.has(g))return!0;g=Object.getPrototypeOf(g)}return!1},configurable:!0})),p.add(t)}return t}n(V,"multiInherit");var eD=class eD{constructor(){this._map=new Map}get(e,t){return this._map.get(e)?.get(t)}set(e,t,s){let r=this._map.get(e);return r||(r=new Map,this._map.set(e,r)),r.set(t,s),this}has(e,t){return this._map.get(e)?.has(t)??!1}delete(e,t){let s=this._map.get(e);if(!s)return!1;let r=s.delete(t);return s.size===0&&this._map.delete(e),r}clear(){this._map.clear()}get size(){let e=0;for(let t of this._map.values())e+=t.size;return e}*[Symbol.iterator](){for(let[e,t]of this._map)for(let[s,r]of t)yield[[e,s],r]}*keys(){for(let[e,t]of this._map)for(let s of t.keys())yield[e,s]}*values(){for(let e of this._map.values())yield*e.values()}*entries(){yield*this}};n(eD,"MapBinaryTuple");var KE=eD;function st(a,e){let t=Object.values(a),s=e?.toLowerCase();return t.find(r=>r===s)??t.find(r=>r.toLowerCase()===s)}n(st,"enumFromString");function $I(a){return a!=null&&typeof a[Symbol.iterator]=="function"}n($I,"isIterable");var eW=0n,oG=new WeakMap,cG=new Map;function pG(){return(eW++).toString()}n(pG,"nextId");function tW(a){if(a!==null&&typeof a=="object"||typeof a=="function"){let t=a,s=oG.get(t);return s===void 0&&(s=pG(),oG.set(t,s)),s}let e=cG.get(a);return e===void 0&&(e=pG(),cG.set(a,e)),e}n(tW,"id");function sW(a){return a!==null&&typeof a=="object"&&typeof a.add=="function"}n(sW,"isAddableObj");function rW(a){return a!==null&&typeof a=="object"&&typeof a.radd=="function"}n(rW,"isRaddableObj");function cX(a,e){return sW(a)?a.add(e):rW(e)?e.radd(a):Array.isArray(a)&&Array.isArray(e)?[...a,...e]:a+e}n(cX,"add");function iW(a){return a!==null&&typeof a=="object"&&typeof a.sub=="function"}n(iW,"isSubtractableObj");function nW(a){return a!==null&&typeof a=="object"&&typeof a.rsub=="function"}n(nW,"isRsubtractableObj");function pX(a,e){return iW(a)?a.sub(e):nW(e)?e.rsub(a):a instanceof Set&&e instanceof Set?new Set([...a].filter(t=>!e.has(t))):a-e}n(pX,"sub");function aW(a){return a!==null&&typeof a=="object"&&typeof a.mul=="function"}n(aW,"isMultipliableObj");function oW(a){return a!==null&&typeof a=="object"&&typeof a.rmul=="function"}n(oW,"isRmultipliableObj");function lX(a,e){return aW(a)?a.mul(e):oW(e)?e.rmul(a):a*e}n(lX,"mul");function cW(a){return a!==null&&typeof a=="object"&&typeof a.truediv=="function"}n(cW,"isTrueDivisibleObj");function pW(a){return a!==null&&typeof a=="object"&&typeof a.rtruediv=="function"}n(pW,"isRtrueDivisibleObj");function uX(a,e){return cW(a)?a.truediv(e):pW(e)?e.rtruediv(a):a/e}n(uX,"truediv");function lW(a){return a!==null&&typeof a=="object"&&typeof a.floorDiv=="function"}n(lW,"isFloorDivisibleObj");function uW(a){return a!==null&&typeof a=="object"&&typeof a.rfloorDiv=="function"}n(uW,"isRfloorDivisibleObj");function hX(a,e){return lW(a)?a.floorDiv(e):uW(e)?e.rfloorDiv(a):Math.trunc(a/e)}n(hX,"floorDiv");function hW(a){return a!==null&&typeof a=="object"&&typeof a.mod=="function"}n(hW,"isModableObj");function gW(a){return a!==null&&typeof a=="object"&&typeof a.rmod=="function"}n(gW,"isRmodableObj");function gX(a,e){return hW(a)?a.mod(e):gW(e)?e.rmod(a):a%e}n(gX,"mod");function EW(a){return a!==null&&typeof a=="object"&&typeof a.pow=="function"}n(EW,"isPowableObj");function AW(a){return a!==null&&typeof a=="object"&&typeof a.rpow=="function"}n(AW,"isRpowableObj");function EX(a,e){return EW(a)?a.pow(e):AW(e)?e.rpow(a):a**e}n(EX,"pow");function hG(a){return a!==null&&typeof a=="object"&&typeof a.lt=="function"}n(hG,"isLtComparableObj");function AX(a,e){return hG(a)?a.lt(e):EG(e)?e.gt(a):a<e}n(AX,"lt");function gG(a){return a!==null&&typeof a=="object"&&typeof a.lte=="function"}n(gG,"isLteComparableObj");function dX(a,e){return gG(a)?a.lte(e):AG(e)?e.gte(a):a<=e}n(dX,"lte");function EG(a){return a!==null&&typeof a=="object"&&typeof a.gt=="function"}n(EG,"isGtComparableObj");function fX(a,e){return EG(a)?a.gt(e):hG(e)?e.lt(a):e<a}n(fX,"gt");function AG(a){return a!==null&&typeof a=="object"&&typeof a.gte=="function"}n(AG,"isGteComparableObj");function xX(a,e){return AG(a)?a.gte(e):gG(e)?e.lte(a):e<=a}n(xX,"gte");function lG(a){return a!==null&&typeof a=="object"&&typeof a.eq=="function"}n(lG,"isEqComparableObj");function dW(a,e){return lG(a)?a.eq(e):lG(e)?e.eq(a):a===e}n(dW,"eq");function uG(a){return a!==null&&typeof a=="object"&&typeof a.neq=="function"}n(uG,"isNeqComparableObj");function TX(a,e){return uG(a)?a.neq(e):uG(e)?e.neq(a):!dW(a,e)}n(TX,"neq");function fW(a){return a!==null&&typeof a=="object"&&typeof a.or=="function"}n(fW,"isOrableObj");function xW(a){return a!==null&&typeof a=="object"&&typeof a.ror=="function"}n(xW,"isRorableObj");function SX(a,e){return fW(a)?a.or(e):xW(e)?e.ror(a):a instanceof Set&&e instanceof Set?new Set([...a,...e]):a|e}n(SX,"or");function TW(a){return a!==null&&typeof a=="object"&&typeof a.and=="function"}n(TW,"isAndableObj");function SW(a){return a!==null&&typeof a=="object"&&typeof a.rand=="function"}n(SW,"isRandableObj");function RX(a,e){return TW(a)?a.and(e):SW(e)?e.rand(a):a instanceof Set&&e instanceof Set?new Set([...a].filter(t=>e.has(t))):a&e}n(RX,"and");function RW(a){return a!==null&&typeof a=="object"&&typeof a.xor=="function"}n(RW,"isXorableObj");function OW(a){return a!==null&&typeof a=="object"&&typeof a.rxor=="function"}n(OW,"isRxorableObj");function OX(a,e){if(RW(a))return a.xor(e);if(OW(e))return e.rxor(a);if(a instanceof Set&&e instanceof Set){let t=a,s=e;return new Set([...[...t].filter(r=>!s.has(r)),...[...s].filter(r=>!t.has(r))])}return a^e}n(OX,"xor");function mW(a){return a!==null&&typeof a=="object"&&typeof a.lshift=="function"}n(mW,"isLshiftableObj");function NW(a){return a!==null&&typeof a=="object"&&typeof a.rlshift=="function"}n(NW,"isRlshiftableObj");function mX(a,e){return mW(a)?a.lshift(e):NW(e)?e.rlshift(a):a<<e}n(mX,"lshift");function IW(a){return a!==null&&typeof a=="object"&&typeof a.rshift=="function"}n(IW,"isRshiftableObj");function yW(a){return a!==null&&typeof a=="object"&&typeof a.rrshift=="function"}n(yW,"isRrshiftableObj");function NX(a,e){return IW(a)?a.rshift(e):yW(e)?e.rrshift(a):a>>e}n(NX,"rshift");var GI=(l=>(l.ABS="abs",l.ACOS="acos",l.ACOSH="acosh",l.ADD="add",l.ADD_CONSTRAINT="addConstraint",l.ADD_MONTHS="addMonths",l.ADD_PARTITION="addPartition",l.ADJACENT="adjacent",l.AGG_FUNC="aggFunc",l.AI_AGG="aiAgg",l.AI_CLASSIFY="aiClassify",l.AI_SUMMARIZE_AGG="aiSummarizeAgg",l.ALGORITHM_PROPERTY="algorithmProperty",l.ALIAS="alias",l.ALIASES="aliases",l.ALL="all",l.ALLOWED_VALUES_PROPERTY="allowedValuesProperty",l.ALTER="alter",l.ALTER_COLUMN="alterColumn",l.ALTER_DIST_STYLE="alterDistStyle",l.ALTER_INDEX="alterIndex",l.ALTER_MODIFY_SQL_SECURITY="alterModifySqlSecurity",l.ALTER_RENAME="alterRename",l.ALTER_SESSION="alterSession",l.ALTER_SET="alterSet",l.ALTER_SORT_KEY="alterSortKey",l.ANALYZE="analyze",l.ANALYZE_COLUMNS="analyzeColumns",l.ANALYZE_DELETE="analyzeDelete",l.ANALYZE_HISTOGRAM="analyzeHistogram",l.ANALYZE_LIST_CHAINED_ROWS="analyzeListChainedRows",l.ANALYZE_SAMPLE="analyzeSample",l.ANALYZE_STATISTICS="analyzeStatistics",l.ANALYZE_VALIDATE="analyzeValidate",l.ANALYZE_WITH="analyzeWith",l.AND="and",l.ANONYMOUS="anonymous",l.ANONYMOUS_AGG_FUNC="anonymousAggFunc",l.ANY="any",l.ANY_VALUE="anyValue",l.APPLY="apply",l.APPROXIMATE_SIMILARITY="approximateSimilarity",l.APPROX_DISTINCT="approxDistinct",l.APPROX_PERCENTILE_ACCUMULATE="approxPercentileAccumulate",l.APPROX_PERCENTILE_COMBINE="approxPercentileCombine",l.APPROX_PERCENTILE_ESTIMATE="approxPercentileEstimate",l.APPROX_QUANTILE="approxQuantile",l.APPROX_QUANTILES="approxQuantiles",l.APPROX_TOP_K="approxTopK",l.APPROX_TOP_K_ACCUMULATE="approxTopKAccumulate",l.APPROX_TOP_K_COMBINE="approxTopKCombine",l.APPROX_TOP_K_ESTIMATE="approxTopKEstimate",l.APPROX_TOP_SUM="approxTopSum",l.ARG_MAX="argMax",l.ARG_MIN="argMin",l.ARRAY="array",l.ARRAYS_ZIP="arraysZip",l.ARRAY_AGG="arrayAgg",l.ARRAY_ALL="arrayAll",l.ARRAY_ANY="arrayAny",l.ARRAY_APPEND="arrayAppend",l.ARRAY_COMPACT="arrayCompact",l.ARRAY_CONCAT="arrayConcat",l.ARRAY_CONCAT_AGG="arrayConcatAgg",l.ARRAY_CONSTRUCT_COMPACT="arrayConstructCompact",l.ARRAY_DISTINCT="arrayDistinct",l.ARRAY_EXCEPT="arrayExcept",l.ARRAY_MAX="arrayMax",l.ARRAY_MIN="arrayMin",l.ARRAY_CONTAINS="arrayContains",l.ARRAY_CONTAINS_ALL="arrayContainsAll",l.ARRAY_FILTER="arrayFilter",l.ARRAY_FIRST="arrayFirst",l.ARRAY_INSERT="arrayInsert",l.ARRAY_INTERSECT="arrayIntersect",l.ARRAY_LAST="arrayLast",l.ARRAY_OVERLAPS="arrayOverlaps",l.ARRAY_POSITION="arrayPosition",l.ARRAY_PREPEND="arrayPrepend",l.ARRAY_REMOVE="arrayRemove",l.ARRAY_REMOVE_AT="arrayRemoveAt",l.ARRAY_REVERSE="arrayReverse",l.ARRAY_SIZE="arraySize",l.ARRAY_SLICE="arraySlice",l.ARRAY_SORT="arraySort",l.ARRAY_SUM="arraySum",l.ARRAY_TO_STRING="arrayToString",l.ARRAY_UNION_AGG="arrayUnionAgg",l.ARRAY_UNIQUE_AGG="arrayUniqueAgg",l.ASCII="ascii",l.ASIN="asin",l.ASINH="asinh",l.ATAN="atan",l.ATAN2="atan2",l.ATANH="atanh",l.ATTACH="attach",l.ATTACH_OPTION="attachOption",l.AT_INDEX="atIndex",l.API_PROPERTY="apiProperty",l.APPLICATION_PROPERTY="applicationProperty",l.ASSUME_COLUMN_CONSTRAINT="assumeColumnConstraint",l.AT_TIME_ZONE="atTimeZone",l.AUTO_INCREMENT_COLUMN_CONSTRAINT="autoIncrementColumnConstraint",l.AUTO_INCREMENT_PROPERTY="autoIncrementProperty",l.AUTO_REFRESH_PROPERTY="autoRefreshProperty",l.AVG="avg",l.BACKUP_PROPERTY="backupProperty",l.BASE64_DECODE_BINARY="base64DecodeBinary",l.BASE64_DECODE_STRING="base64DecodeString",l.BASE64_ENCODE="base64Encode",l.BETWEEN="between",l.BINARY="binary",l.BITMAP_BIT_POSITION="bitmapBitPosition",l.BITMAP_BUCKET_NUMBER="bitmapBucketNumber",l.BITMAP_CONSTRUCT_AGG="bitmapConstructAgg",l.BITMAP_COUNT="bitmapCount",l.BITMAP_OR_AGG="bitmapOrAgg",l.BITWISE_AND="bitwiseAnd",l.BITWISE_AND_AGG="bitwiseAndAgg",l.BITWISE_COUNT="bitwiseCount",l.BITWISE_LEFT_SHIFT="bitwiseLeftShift",l.BITWISE_NOT="bitwiseNot",l.BITWISE_OR="bitwiseOr",l.BITWISE_OR_AGG="bitwiseOrAgg",l.BITWISE_RIGHT_SHIFT="bitwiseRightShift",l.BITWISE_XOR="bitwiseXor",l.BITWISE_XOR_AGG="bitwiseXorAgg",l.BIT_LENGTH="bitLength",l.BIT_STRING="bitString",l.BLOCK="block",l.BLOCK_COMPRESSION_PROPERTY="blockCompressionProperty",l.BOOLAND="booland",l.BOOLEAN="boolean",l.BOOLNOT="boolnot",l.BOOLOR="boolor",l.BOOLXOR_AGG="boolxorAgg",l.BRACKET="bracket",l.BUILD_PROPERTY="buildProperty",l.BYTE_LENGTH="byteLength",l.BYTE_STRING="byteString",l.CACHE="cache",l.CASE="case",l.CASE_SPECIFIC_COLUMN_CONSTRAINT="caseSpecificColumnConstraint",l.CAST="cast",l.CAST_TO_STR_TYPE="castToStrType",l.CATALOG_PROPERTY="catalogProperty",l.CBRT="cbrt",l.CEIL="ceil",l.CHANGES="changes",l.CHARACTER_SET="characterSet",l.CHARACTER_SET_COLUMN_CONSTRAINT="characterSetColumnConstraint",l.CHARACTER_SET_PROPERTY="characterSetProperty",l.CHECK="check",l.CHECKSUM_PROPERTY="checksumProperty",l.CHECK_COLUMN_CONSTRAINT="checkColumnConstraint",l.CHECK_JSON="checkJson",l.CHECK_XML="checkXml",l.CHR="chr",l.CITY_HASH64="cityHash64",l.CLONE="clone",l.CLUSTER="cluster",l.CLUSTERED_BY_PROPERTY="clusteredByProperty",l.CLUSTERED_COLUMN_CONSTRAINT="clusteredColumnConstraint",l.COALESCE="coalesce",l.CODE_POINTS_TO_BYTES="codePointsToBytes",l.CODE_POINTS_TO_STRING="codePointsToString",l.COLLATE="collate",l.COLLATE_COLUMN_CONSTRAINT="collateColumnConstraint",l.COLLATE_PROPERTY="collateProperty",l.COLLATION="collation",l.COLUMN="column",l.COLUMNS="columns",l.COLUMN_CONSTRAINT="columnConstraint",l.COLUMN_CONSTRAINT_KIND="columnConstraintKind",l.COLUMN_DEF="columnDef",l.COLUMN_POSITION="columnPosition",l.COLUMN_PREFIX="columnPrefix",l.COMBINED_AGG_FUNC="combinedAggFunc",l.COMBINED_PARAMETERIZED_AGG="combinedParameterizedAgg",l.COMMAND="command",l.COMMENT="comment",l.COMMENT_COLUMN_CONSTRAINT="commentColumnConstraint",l.COMMIT="commit",l.COMPUTE_PROPERTY="computeProperty",l.COMPREHENSION="comprehension",l.COMPRESS="compress",l.COMPRESS_COLUMN_CONSTRAINT="compressColumnConstraint",l.COMPUTED_COLUMN_CONSTRAINT="computedColumnConstraint",l.CONCAT="concat",l.CONCAT_WS="concatWs",l.CONDITION="condition",l.CONDITIONAL_INSERT="conditionalInsert",l.CONNECT="connect",l.CONNECTOR="connector",l.CONNECT_BY_ROOT="connectByRoot",l.CONSTRAINT="constraint",l.CONTAINS="contains",l.CONVERT="convert",l.CONVERT_TIMEZONE="convertTimezone",l.CONVERT_TO_CHARSET="convertToCharset",l.COPY="copy",l.COPY_GRANTS_PROPERTY="copyGrantsProperty",l.COPY_PARAMETER="copyParameter",l.CORR="corr",l.COS="cos",l.COSH="cosh",l.COSINE_DISTANCE="cosineDistance",l.COT="cot",l.COTH="coth",l.COUNT="count",l.COUNT_IF="countIf",l.COVAR_POP="covarPop",l.COVAR_SAMP="covarSamp",l.CREATE="create",l.CREDENTIALS="credentials",l.CREDENTIALS_PROPERTY="credentialsProperty",l.CSC="csc",l.CSCH="csch",l.CTE="cte",l.CUBE="cube",l.CUME_DIST="cumeDist",l.CURRENT_ACCOUNT="currentAccount",l.CURRENT_ACCOUNT_NAME="currentAccountName",l.CURRENT_AVAILABLE_ROLES="currentAvailableRoles",l.CURRENT_CATALOG="currentCatalog",l.CURRENT_CLIENT="currentClient",l.CURRENT_DATABASE="currentDatabase",l.CURRENT_DATE="currentDate",l.CURRENT_DATETIME="currentDatetime",l.CURRENT_IP_ADDRESS="currentIpAddress",l.CURRENT_ORGANIZATION_NAME="currentOrganizationName",l.CURRENT_ORGANIZATION_USER="currentOrganizationUser",l.CURRENT_REGION="currentRegion",l.CURRENT_ROLE="currentRole",l.CURRENT_ROLE_TYPE="currentRoleType",l.CURRENT_SCHEMA="currentSchema",l.CURRENT_SCHEMAS="currentSchemas",l.CURRENT_SECONDARY_ROLES="currentSecondaryRoles",l.CURRENT_SESSION="currentSession",l.CURRENT_STATEMENT="currentStatement",l.CURRENT_TIME="currentTime",l.CURRENT_TIMESTAMP="currentTimestamp",l.CURRENT_TIMESTAMP_LTZ="currentTimestampLtz",l.CURRENT_TIMEZONE="currentTimezone",l.CURRENT_TRANSACTION="currentTransaction",l.CURRENT_USER="currentUser",l.CURRENT_VERSION="currentVersion",l.CURRENT_WAREHOUSE="currentWarehouse",l.DATA_BLOCKSIZE_PROPERTY="dataBlocksizeProperty",l.DATABASE_PROPERTY="databaseProperty",l.DATA_DELETION_PROPERTY="dataDeletionProperty",l.DATA_TYPE="dataType",l.DATA_TYPE_PARAM="dataTypeParam",l.DATE="date",l.DATETIME="datetime",l.DATETIME_ADD="datetimeAdd",l.DATETIME_DIFF="datetimeDiff",l.DATETIME_SUB="datetimeSub",l.DATETIME_TRUNC="datetimeTrunc",l.DATE_ADD="dateAdd",l.DATE_BIN="dateBin",l.DATE_DIFF="dateDiff",l.DATE_FORMAT_COLUMN_CONSTRAINT="dateFormatColumnConstraint",l.DATE_FROM_PARTS="dateFromParts",l.DATE_FROM_UNIX_DATE="dateFromUnixDate",l.DATE_STR_TO_DATE="dateStrToDate",l.DATE_SUB="dateSub",l.DATE_TO_DATE_STR="dateToDateStr",l.DATE_TO_DI="dateToDi",l.DATE_TRUNC="dateTrunc",l.DAY="day",l.DAYNAME="dayname",l.DAY_OF_MONTH="dayOfMonth",l.DAY_OF_WEEK="dayOfWeek",l.DAY_OF_WEEK_ISO="dayOfWeekIso",l.DAY_OF_YEAR="dayOfYear",l.DDL="ddl",l.DECLARE="declare",l.DECLARE_ITEM="declareItem",l.DECODE="decode",l.DECODE_CASE="decodeCase",l.DECOMPRESS_BINARY="decompressBinary",l.DECOMPRESS_STRING="decompressString",l.DECRYPT="decrypt",l.DECRYPT_RAW="decryptRaw",l.DEFAULT_COLUMN_CONSTRAINT="defaultColumnConstraint",l.DEFINER_PROPERTY="definerProperty",l.DEGREES="degrees",l.DELETE="delete",l.DENSE_RANK="denseRank",l.DERIVED_TABLE="derivedTable",l.DESCRIBE="describe",l.DETACH="detach",l.DICT_PROPERTY="dictProperty",l.DICT_RANGE="dictRange",l.DICT_SUB_PROPERTY="dictSubProperty",l.DIRECTORY="directory",l.DIRECTORY_STAGE="directoryStage",l.DISTANCE="distance",l.DISTINCT="distinct",l.DISTRIBUTE="distribute",l.DISTRIBUTED_BY_PROPERTY="distributedByProperty",l.DIST_KEY_PROPERTY="distKeyProperty",l.DIST_STYLE_PROPERTY="distStyleProperty",l.DIV="div",l.DI_TO_DATE="diToDate",l.DML="dml",l.DOT="dot",l.DOT_PRODUCT="dotProduct",l.DROP="drop",l.DROP_PARTITION="dropPartition",l.DUPLICATE_KEY_PROPERTY="duplicateKeyProperty",l.DYNAMIC_PROPERTY="dynamicProperty",l.D_PIPE="dPipe",l.ELT="elt",l.EMPTY_PROPERTY="emptyProperty",l.ENCODE="encode",l.ENCODE_COLUMN_CONSTRAINT="encodeColumnConstraint",l.ENCODE_PROPERTY="encodeProperty",l.ENCRYPT="encrypt",l.ENCRYPT_RAW="encryptRaw",l.END_STATEMENT="endStatement",l.ENDS_WITH="endsWith",l.ENGINE_PROPERTY="engineProperty",l.ENVIROMENT_PROPERTY="enviromentProperty",l.EPHEMERAL_COLUMN_CONSTRAINT="ephemeralColumnConstraint",l.EQ="eq",l.EqUAL_NULL="equalNull",l.ESCAPE="escape",l.EUCLIDEAN_DISTANCE="euclideanDistance",l.EXCEPT="except",l.EXCLUDE_COLUMN_CONSTRAINT="excludeColumnConstraint",l.EXECUTE="execute",l.EXECUTE_AS_PROPERTY="executeAsProperty",l.EXECUTE_SQL="executeSql",l.EXISTS="exists",l.EXP="exp",l.EXPLODE="explode",l.EXPLODE_OUTER="explodeOuter",l.EXPLODING_GENERATE_SERIES="explodingGenerateSeries",l.EXPORT="export",l.EXPRESSION="expression",l.EXTENDS_LEFT="extendsLeft",l.EXTENDS_RIGHT="extendsRight",l.EXTERNAL_PROPERTY="externalProperty",l.EXTRACT="extract",l.FACTORIAL="factorial",l.FALLBACK_PROPERTY="fallbackProperty",l.FARM_FINGERPRINT="farmFingerprint",l.FEATURES_AT_TIME="featuresAtTime",l.FETCH="fetch",l.FILE_FORMAT_PROPERTY="fileFormatProperty",l.FILTER="filter",l.FINAL="final",l.FIRST="first",l.FIRST_VALUE="firstValue",l.FLATTEN="flatten",l.FLOAT64="float64",l.FLOOR="floor",l.FORCE_PROPERTY="forceProperty",l.FOREIGN_KEY="foreignKey",l.FORMAT="format",l.FORMAT_JSON="formatJson",l.FORMAT_PHRASE="formatPhrase",l.FOR_IN="forIn",l.FREESPACE_PROPERTY="freespaceProperty",l.FROM="from",l.FROM_BASE="fromBase",l.FROM_BASE32="fromBase32",l.FROM_BASE64="fromBase64",l.FROM_ISO8601_TIMESTAMP="fromIso8601Timestamp",l.FROM_TIME_ZONE="fromTimeZone",l.FUNC="func",l.GAP_FILL="gapFill",l.GENERATED_AS_IDENTITY_COLUMN_CONSTRAINT="generatedAsIdentityColumnConstraint",l.GENERATED_AS_ROW_COLUMN_CONSTRAINT="generatedAsRowColumnConstraint",l.GENERATE_DATE_ARRAY="generateDateArray",l.GENERATE_EMBEDDING="generateEmbedding",l.GENERATE_SERIES="generateSeries",l.GENERATE_TIMESTAMP_ARRAY="generateTimestampArray",l.GENERATOR="generator",l.GET="get",l.GETBIT="getbit",l.GET_EXTRACT="getExtract",l.GLOB="glob",l.GLOBAL_PROPERTY="globalProperty",l.GRANT="grant",l.GRANT_PRINCIPAL="grantPrincipal",l.GRANT_PRIVILEGE="grantPrivilege",l.GREATEST="greatest",l.GROUP="group",l.GROUPING="grouping",l.GROUPING_ID="groupingId",l.GROUPING_SETS="groupingSets",l.GROUP_CONCAT="groupConcat",l.GT="gt",l.GTE="gte",l.HASH_AGG="hashAgg",l.HAVING="having",l.HAVING_MAX="havingMax",l.HANDLER_PROPERTY="handlerProperty",l.HEAP_PROPERTY="heapProperty",l.HYBRID_PROPERTY="hybridProperty",l.HEREDOC="heredoc",l.HEX="hex",l.HEX_DECODE_STRING="hexDecodeString",l.HEX_ENCODE="hexEncode",l.HEX_STRING="hexString",l.HINT="hint",l.HISTORICAL_DATA="historicalData",l.HLL="hll",l.HOST="host",l.HOUR="hour",l.ICEBERG_PROPERTY="icebergProperty",l.IDENTIFIER="identifier",l.IF="if",l.IF_BLOCK="ifBlock",l.IGNORE_NULLS="ignoreNulls",l.IN="in",l.INCLUDE_PROPERTY="includeProperty",l.INDEX="index",l.INDEX_COLUMN_CONSTRAINT="indexColumnConstraint",l.INDEX_CONSTRAINT_OPTION="indexConstraintOption",l.INDEX_PARAMETERS="indexParameters",l.INDEX_TABLE_HINT="indexTableHint",l.INHERITS_PROPERTY="inheritsProperty",l.INITCAP="initcap",l.INLINE="inline",l.INLINE_LENGTH_COLUMN_CONSTRAINT="inlineLengthColumnConstraint",l.INPUT_MODEL_PROPERTY="inputModelProperty",l.INPUT_OUTPUT_FORMAT="inputOutputFormat",l.INSERT="insert",l.INSTALL="install",l.INT64="int64",l.INTERSECT="intersect",l.INTERVAL="interval",l.INTERVAL_OP="intervalOp",l.INTERVAL_SPAN="intervalSpan",l.INTO="into",l.INTRODUCER="introducer",l.INT_DIV="intDiv",l.IN_OUT_COLUMN_CONSTRAINT="inOutColumnConstraint",l.IS="is",l.ISOLATED_LOADING_PROPERTY="isolatedLoadingProperty",l.IS_ARRAY="isArray",l.IS_ASCII="isAscii",l.IS_INF="isInf",l.IS_NAN="isNan",l.IS_NULL_VALUE="isNullValue",l.ILIKE="iLike",l.JAROWINKLER_SIMILARITY="jarowinklerSimilarity",l.JOIN="join",l.JOIN_HINT="joinHint",l.JOURNAL_PROPERTY="journalProperty",l.JSON="json",l.JSON_ARRAY="jsonArray",l.JSON_ARRAY_AGG="jsonArrayAgg",l.JSON_ARRAY_APPEND="jsonArrayAppend",l.JSON_ARRAY_CONTAINS="jsonArrayContains",l.JSON_ARRAY_INSERT="jsonArrayInsert",l.JSON_BOOL="jsonBool",l.JSONB_CONTAINS="jsonbContains",l.JSONB_CONTAINS_ALL_TOP_KEYS="jsonbContainsAllTopKeys",l.JSONB_CONTAINS_ANY_TOP_KEYS="jsonbContainsAnyTopKeys",l.JSONB_DELETE_AT_PATH="jsonbDeleteAtPath",l.JSONB_EXISTS="jsonbExists",l.JSONB_EXTRACT="jsonbExtract",l.JSONB_EXTRACT_SCALAR="jsonbExtractScalar",l.JSONB_OBJECT_AGG="jsonbObjectAgg",l.JSON_CAST="jsonCast",l.JSON_COLUMN_DEF="jsonColumnDef",l.JSON_EXISTS="jsonExists",l.JSON_EXTRACT="jsonExtract",l.JSON_EXTRACT_ARRAY="jsonExtractArray",l.JSON_EXTRACT_QUOTE="jsonExtractQuote",l.JSON_EXTRACT_SCALAR="jsonExtractScalar",l.JSON_FORMAT="jsonFormat",l.JSON_KEYS="jsonKeys",l.JSON_KEYS_AT_DEPTH="jsonKeysAtDepth",l.JSON_KEY_VALUE="jsonKeyValue",l.JSON_OBJECT="jsonObject",l.JSON_OBJECT_AGG="jsonObjectAgg",l.JSON_PATH="jsonPath",l.JSON_PATH_FILTER="jsonPathFilter",l.JSON_PATH_KEY="jsonPathKey",l.JSON_PATH_PART="jsonPathPart",l.JSON_PATH_RECURSIVE="jsonPathRecursive",l.JSON_PATH_ROOT="jsonPathRoot",l.JSON_PATH_SCRIPT="jsonPathScript",l.JSON_PATH_SELECTOR="jsonPathSelector",l.JSON_PATH_SLICE="jsonPathSlice",l.JSON_PATH_SUBSCRIPT="jsonPathSubscript",l.JSON_PATH_UNION="jsonPathUnion",l.JSON_PATH_WILDCARD="jsonPathWildcard",l.JSON_REMOVE="jsonRemove",l.JSON_SCHEMA="jsonSchema",l.JSON_SET="jsonSet",l.JSON_STRIP_NULLS="jsonStripNulls",l.JSON_TABLE="jsonTable",l.JSON_TYPE="jsontype",l.JSON_VALUE="jsonValue",l.JSON_VALUE_ARRAY="jsonValueArray",l.JUSTIFY_DAYS="justifyDays",l.JUSTIFY_HOURS="justifyHours",l.JUSTIFY_INTERVAL="justifyInterval",l.KILL="kill",l.KURTOSIS="kurtosis",l.KWARG="kwarg",l.LAG="lag",l.LAMBDA="lambda",l.LANGUAGE_PROPERTY="languageProperty",l.LAST="last",l.LAST_DAY="lastDay",l.LAST_VALUE="lastValue",l.LATERAL="lateral",l.LAX_BOOL="laxBool",l.LAX_FLOAT64="laxFloat64",l.LAX_INT64="laxInt64",l.LAX_STRING="laxString",l.LEAD="lead",l.LEAST="least",l.LEFT="left",l.LENGTH="length",l.LEVENSHTEIN="levenshtein",l.LIKE="like",l.LIKE_PROPERTY="likeProperty",l.LIMIT="limit",l.LIMIT_OPTIONS="limitOptions",l.LIST="list",l.LITERAL="literal",l.LN="ln",l.LOAD_DATA="loadData",l.LOCALTIME="localtime",l.LOCALTIMESTAMP="localtimestamp",l.LOCATION="location",l.LOCATION_PROPERTY="locationProperty",l.LOCK="lock",l.LOCKING_PROPERTY="lockingProperty",l.LOCKING_STATEMENT="lockingStatement",l.LOCK_PROPERTY="lockProperty",l.LOG="log",l.LOGICAL_AND="logicalAnd",l.LOGICAL_OR="logicalOr",l.LOG_PROPERTY="logProperty",l.LOWER="lower",l.LOWER_HEX="lowerHex",l.LT="lt",l.LTE="lte",l.MAKE_INTERVAL="makeInterval",l.MANHATTAN_DISTANCE="manhattanDistance",l.MAP="map",l.MAP_CAT="mapCat",l.MAP_CONTAINS_KEY="mapContainsKey",l.MAP_DELETE="mapDelete",l.MAP_FROM_ENTRIES="mapFromEntries",l.MAP_INSERT="mapInsert",l.MAP_KEYS="mapkeys",l.MAP_PICK="mapPick",l.MAP_SIZE="mapSize",l.MASKING_POLICY_COLUMN_CONSTRAINT="maskingPolicyColumnConstraint",l.MATCH="match",l.MATCH_AGAINST="matchAgainst",l.MATCH_RECOGNIZE="matchRecognize",l.MATCH_RECOGNIZE_MEASURE="matchRecognizeMeasure",l.MASKING_PROPERTY="maskingProperty",l.MATERIALIZED_PROPERTY="materializedProperty",l.MAX="max",l.MD5="md5",l.MD5_DIGEST="md5Digest",l.MD5_NUMBER_LOWER64="md5NumberLower64",l.MD5_NUMBER_UPPER64="md5NumberUpper64",l.MEDIAN="median",l.MERGE="merge",l.MERGE_BLOCK_RATIO_PROPERTY="mergeBlockRatioProperty",l.MERGE_TREE_TTL="mergeTreeTtl",l.MERGE_TREE_TTL_ACTION="mergeTreeTtlAction",l.MIN="min",l.MINHASH="minhash",l.MINHASH_COMBINE="minhashCombine",l.MINUTE="minute",l.ML_FORECAST="mlForecast",l.ML_TRANSLATE="mlTranslate",l.MOD="mod",l.MODE="mode",l.MODEL_ATTRIBUTE="modelAttribute",l.MODIFY_COLUMN="modifyColumn",l.MONTH="month",l.MONTHNAME="monthname",l.MONTHS_BETWEEN="monthsBetween",l.MUL="mul",l.MULTITABLE_INSERTS="multitableInserts",l.NATIONAL="national",l.NEG="neg",l.NEQ="neq",l.NESTED_JSON_SELECT="nestedJsonSelect",l.NET_FUNC="netFunc",l.NEXT_DAY="nextDay",l.NEXT_VALUE_FOR="nextValueFor",l.NON_CLUSTERED_COLUMN_CONSTRAINT="nonClusteredColumnConstraint",l.NORMAL="normal",l.NORMALIZE="normalize",l.NOT="not",l.NOT_FOR_REPLICATION_COLUMN_CONSTRAINT="notForReplicationColumnConstraint",l.NOT_NULL_COLUMN_CONSTRAINT="notNullColumnConstraint",l.NETWORK_PROPERTY="networkProperty",l.NO_PRIMARY_INDEX_PROPERTY="noPrimaryIndexProperty",l.NTH_VALUE="nthValue",l.NTILE="ntile",l.NULL="null",l.NULLIF="nullif",l.NULL_SAFE_EQ="nullSafeEq",l.NULL_SAFE_NEQ="nullSafeNeq",l.NUMBER_TO_STR="numberToStr",l.NVL2="nvl2",l.OBJECT_AGG="objectAgg",l.OBJECT_ID="objectId",l.OBJECT_IDENTIFIER="objectIdentifier",l.OBJECT_INSERT="objectInsert",l.OFFSET="offset",l.ON_CLUSTER="onCluster",l.ON_COMMIT_PROPERTY="onCommitProperty",l.ON_CONDITION="onCondition",l.ON_CONFLICT="onConflict",l.ON_PROPERTY="onProperty",l.ON_UPDATE_COLUMN_CONSTRAINT="onUpdateColumnConstraint",l.OPCLASS="opclass",l.OPEN_JSON="openJson",l.OPEN_JSON_COLUMN_DEF="openJsonColumnDef",l.OPERATOR="operator",l.OR="or",l.ORDER="order",l.ORDERED="ordered",l.OUTPUT_MODEL_PROPERTY="outputModelProperty",l.OVERFLOW_TRUNCATE_BEHAVIOR="overflowTruncateBehavior",l.OVERLAPS="overlaps",l.OVERLAY="overlay",l.PAD="pad",l.PARAMETER="parameter",l.PARAMETERIZED_AGG="parameterizedAgg",l.PAREN="paren",l.PARSE_BIGNUMERIC="parseBignumeric",l.PARSE_DATETIME="parseDatetime",l.PARSE_IP="parseIp",l.PARSE_JSON="parseJson",l.PARSE_NUMERIC="parseNumeric",l.PARSE_TIME="parseTime",l.PARSE_URL="parseUrl",l.PARTITION="partition",l.PARTITIONED_BY_BUCKET="partitionedByBucket",l.PARTITIONED_BY_PROPERTY="partitionedByProperty",l.PARTITIONED_OF_PROPERTY="partitionedOfProperty",l.PARTITION_BOUND_SPEC="partitionBoundSpec",l.PARTITION_BY_LIST_PROPERTY="partitionByListProperty",l.PARAMETER_STYLE_PROPERTY="parameterStyleProperty",l.PARTITION_BY_RANGE_PROPERTY="partitionByRangeProperty",l.PARTITION_BY_RANGE_PROPERTY_DYNAMIC="partitionByRangePropertyDynamic",l.PARTITION_BY_TRUNCATE="partitionByTruncate",l.PARTITION_ID="partitionId",l.PARTITION_LIST="partitionList",l.PARTITION_RANGE="partitionRange",l.PATH_COLUMN_CONSTRAINT="pathColumnConstraint",l.PERCENTILE_CONT="percentileCont",l.PERCENTILE_DISC="percentileDisc",l.PERCENT_RANK="percentRank",l.PERIOD_FOR_SYSTEM_TIME_CONSTRAINT="periodForSystemTimeConstraint",l.PI="pi",l.PIVOT="pivot",l.PIVOT_ALIAS="pivotAlias",l.PIVOT_ANY="pivotAny",l.PLACEHOLDER="placeholder",l.POSEXPLODE="posexplode",l.POSEXPLODE_OUTER="posexplodeOuter",l.POSITIONAL_COLUMN="positionalColumn",l.POW="pow",l.PRAGMA="pragma",l.PREDICATE="predicate",l.PREDICT="predict",l.PREVIOUS_DAY="previousDay",l.PRE_WHERE="preWhere",l.PRIMARY_KEY="primaryKey",l.PRIMARY_KEY_COLUMN_CONSTRAINT="primaryKeyColumnConstraint",l.PRIOR="prior",l.PROJECTION_DEF="projectionDef",l.PROJECTION_POLICY_COLUMN_CONSTRAINT="projectionPolicyColumnConstraint",l.PROPERTIES="properties",l.PROPERTY="property",l.PROPERTY_EQ="propertyEq",l.PSEUDOCOLUMN="pseudocolumn",l.PSEUDO_TYPE="pseudoType",l.PUT="put",l.QUALIFY="qualify",l.QUANTILE="quantile",l.QUARTER="quarter",l.QUERY="query",l.QUERY_BAND="queryBand",l.QUERY_OPTION="queryOption",l.QUERY_TRANSFORM="queryTransform",l.RADIANS="radians",l.RAND="rand",l.RANDN="randn",l.RANDSTR="randstr",l.RANGE_BUCKET="rangeBucket",l.RANGE_N="rangeN",l.RANK="rank",l.RAW_STRING="rawString",l.READ_CSV="readCsv",l.READ_PARQUET="readParquet",l.RECURSIVE_WITH_SEARCH="recursiveWithSearch",l.REDUCE="reduce",l.REFERENCE="reference",l.REFRESH="refresh",l.REFRESH_TRIGGER_PROPERTY="refreshTriggerProperty",l.REGEXP_COUNT="regexpCount",l.REGEXP_EXTRACT="regexpExtract",l.REGEXP_EXTRACT_ALL="regexpExtractAll",l.REGEXP_FULL_MATCH="regexpFullMatch",l.REGEXP_INSTR="regexpInstr",l.REGEXP_ILIKE="regexpIlike",l.REGEXP_LIKE="regexpLike",l.REGEXP_REPLACE="regexpReplace",l.REGEXP_SPLIT="regexpSplit",l.REGR_AVGX="regrAvgx",l.REGR_AVGY="regrAvgy",l.REGR_COUNT="regrCount",l.REGR_INTERCEPT="regrIntercept",l.REGR_R2="regrR2",l.REGR_SLOPE="regrSlope",l.REGR_SXX="regrSxx",l.REGR_SXY="regrSxy",l.REGR_SYY="regrSyy",l.REGR_VALX="regrValx",l.REGR_VALY="regrValy",l.REG_DOMAIN="regDomain",l.REMOTE_WITH_CONNECTION_MODEL_PROPERTY="remoteWithConnectionModelProperty",l.RENAME_COLUMN="renameColumn",l.REPEAT="repeat",l.REPLACE="replace",l.REPLACE_PARTITION="replacePartition",l.RESPECT_NULLS="respectNulls",l.RETURN="return",l.RETURNING="returning",l.RETURNS_PROPERTY="returnsProperty",l.REVERSE="reverse",l.REVOKE="revoke",l.RIGHT="right",l.ROLLBACK="rollback",l.ROLLUP="rollup",l.ROLLUP_INDEX="rollupIndex",l.ROLLUP_PROPERTY="rollupProperty",l.ROUND="round",l.ROW_ACCESS_PROPERTY="rowAccessProperty",l.ROW_FORMAT_DELIMITED_PROPERTY="rowFormatDelimitedProperty",l.ROW_FORMAT_PROPERTY="rowFormatProperty",l.ROW_FORMAT_SERDE_PROPERTY="rowFormatSerdeProperty",l.ROW_NUMBER="rowNumber",l.RTRIMMED_LENGTH="rtrimmedLength",l.SAFE_ADD="safeAdd",l.SAFE_CONVERT_BYTES_TO_STRING="safeConvertBytesToString",l.SAFE_DIVIDE="safeDivide",l.SAFE_FUNC="safeFunc",l.SAFE_MULTIPLY="safeMultiply",l.SAFE_NEGATE="safeNegate",l.SAFE_SUBTRACT="safeSubtract",l.SAMPLE_PROPERTY="sampleProperty",l.SCHEMA="schema",l.SCHEMA_COMMENT_PROPERTY="schemaCommentProperty",l.SCOPE_RESOLUTION="scopeResolution",l.SEARCH="search",l.SEARCH_IP="searchIp",l.SEC="sec",l.SECH="sech",l.SECOND="second",l.SECURE_PROPERTY="secureProperty",l.SECURITY_INTEGRATION_PROPERTY="securityIntegrationProperty",l.SELECT="select",l.SEMANTIC_VIEW="semanticView",l.SEMICOLON="semicolon",l.SEQ1="seq1",l.SEQ2="seq2",l.SEQ4="seq4",l.SEQ8="seq8",l.SEQUENCE_PROPERTIES="sequenceProperties",l.SERDE_PROPERTIES="serdeProperties",l.SESSION_PARAMETER="sessionParameter",l.SESSION_USER="sessionUser",l.SET="set",l.SETTINGS_PROPERTY="settingsProperty",l.SET_CONFIG_PROPERTY="setConfigProperty",l.SET_ITEM="setItem",l.SET_OPERATION="setOperation",l.SET_PROPERTY="setProperty",l.SHA="sha",l.Sha1_DIGEST="sha1Digest",l.Sha2="sha2",l.Sha2_DIGEST="sha2Digest",l.SHARING_PROPERTY="sharingProperty",l.SHOW="show",l.SIGN="sign",l.SIMILAR_TO="similarTo",l.SIN="sin",l.SINH="sinh",l.SKEWNESS="skewness",l.SKIP_JSON_COLUMN="skipJsonColumn",l.SLICE="slice",l.SORT="sort",l.SORT_ARRAY="sortArray",l.SORT_KEY_PROPERTY="sortKeyProperty",l.SOUNDEX="soundex",l.SOUNDEX_P123="soundexP123",l.SPACE="space",l.SPLIT="split",l.SPLIT_PART="splitPart",l.SQL_READ_WRITE_PROPERTY="sqlReadWriteProperty",l.SQL_SECURITY_PROPERTY="sqlSecurityProperty",l.SQRT="sqrt",l.STABILITY_PROPERTY="stabilityProperty",l.STANDARD_HASH="standardHash",l.STAR="star",l.STARTS_WITH="startsWith",l.STAR_MAP="starMap",l.STRTOK="strtok",l.STDDEV="stddev",l.STDDEV_POP="stddevPop",l.STDDEV_SAMP="stddevSamp",l.STORED_PROCEDURE="storedProcedure",l.STORAGE_HANDLER_PROPERTY="storageHandlerProperty",l.STREAM="stream",l.STREAMING_TABLE_PROPERTY="streamingTableProperty",l.STRICT_PROPERTY="strictProperty",l.STRING="string",l.STRING_TO_ARRAY="stringToArray",l.STRUCT="struct",l.STRUCT_EXTRACT="structExtract",l.STR_POSITION="strPosition",l.STR_TO_DATE="strToDate",l.STR_TO_MAP="strToMap",l.STR_TO_TIME="strToTime",l.STR_TO_UNIX="strToUnix",l.STUFF="stuff",l.ST_DISTANCE="stDistance",l.ST_POINT="stPoint",l.SUB="sub",l.SUBQUERY="subquery",l.SUBQUERY_PREDICATE="subqueryPredicate",l.SUBSTRING="substring",l.SUBSTRING_INDEX="substringIndex",l.SUM="sum",l.SUMMARIZE="summarize",l.SWAP_TABLE="swapTable",l.SYSTIMESTAMP="systimestamp",l.TABLE="table",l.TABLE_ALIAS="tableAlias",l.TABLE_COLUMN="tableColumn",l.TABLE_FROM_ROWS="tableFromRows",l.TABLE_SAMPLE="tableSample",l.TAG="tag",l.TAGS="tags",l.TAN="tan",l.TANH="tanh",l.TEMPORARY_PROPERTY="temporaryProperty",l.TIME="time",l.TIMESTAMP="timestamp",l.TIMESTAMP_ADD="timestampAdd",l.TIMESTAMP_DIFF="timestampDiff",l.TIMESTAMP_FROM_PARTS="timestampFromParts",l.TIMESTAMP_LTZ_FROM_PARTS="timestampLtzFromParts",l.TIMESTAMP_SUB="timestampSub",l.TIMESTAMP_TRUNC="timestampTrunc",l.TIMESTAMP_TZ_FROM_PARTS="timestampTzFromParts",l.TIME_ADD="timeAdd",l.TIME_DIFF="timeDiff",l.TIME_FROM_PARTS="timeFromParts",l.TIME_SLICE="timeSlice",l.TIME_STR_TO_DATE="timeStrToDate",l.TIME_STR_TO_TIME="timeStrToTime",l.TIME_STR_TO_UNIX="timeStrToUnix",l.TIME_SUB="timeSub",l.TIME_TO_STR="timeToStr",l.TIME_TO_TIME_STR="timeToTimeStr",l.TIME_TO_UNIX="timeToUnix",l.TIME_TRUNC="timeTrunc",l.TIME_UNIT="timeUnit",l.TITLE_COLUMN_CONSTRAINT="titleColumnConstraint",l.TO_ARRAY="toArray",l.TO_BASE32="toBase32",l.TO_BASE64="toBase64",l.TO_BINARY="toBinary",l.TO_BOOLEAN="toBoolean",l.TO_CHAR="toChar",l.TO_CODE_POINTS="toCodePoints",l.TO_DAYS="toDays",l.TO_DECFLOAT="toDecfloat",l.TO_DOUBLE="toDouble",l.TO_FILE="toFile",l.TO_MAP="toMap",l.TO_NUMBER="toNumber",l.TO_TABLE_PROPERTY="toTableProperty",l.TO_VARIANT="toVariant",l.TRANSACTION="transaction",l.TRANSFORM="transform",l.TRANSFORM_MODEL_PROPERTY="transformModelProperty",l.TRANSIENT_PROPERTY="transientProperty",l.TRANSLATE="translate",l.TRANSLATE_CHARACTERS="translateCharacters",l.TRIGGER_EVENT="triggerEvent",l.TRIGGER_EXECUTE="triggerExecute",l.TRIGGER_PROPERTIES="triggerProperties",l.TRIGGER_REFERENCING="triggerReferencing",l.TRIM="trim",l.TRUNC="trunc",l.TRUNCATE_TABLE="truncateTable",l.TRY="try",l.TRY_BASE64_DECODE_BINARY="tryBase64DecodeBinary",l.TRY_BASE64_DECODE_STRING="tryBase64DecodeString",l.TRY_CAST="tryCast",l.TRY_HEX_DECODE_BINARY="tryHexDecodeBinary",l.TRY_HEX_DECODE_STRING="tryHexDecodeString",l.TRY_TO_DECFLOAT="tryToDecfloat",l.TS_OR_DI_TO_DI="tsOrDiToDi",l.TS_OR_DS_ADD="tsOrDsAdd",l.TS_OR_DS_DIFF="tsOrDsDiff",l.TS_OR_DS_TO_DATE="tsOrDsToDate",l.TS_OR_DS_TO_DATETIME="tsOrDsToDatetime",l.TS_OR_DS_TO_DATE_STR="tsOrDsToDateStr",l.TS_OR_DS_TO_TIME="tsOrDsToTime",l.TS_OR_DS_TO_TIMESTAMP="tsOrDsToTimestamp",l.TUPLE="tuple",l.TYPE="type",l.TYPEOF="typeof",l.UDTF="udtf",l.UNARY="unary",l.UNCACHE="uncache",l.UNHEX="unhex",l.UNICODE="unicode",l.UNICODE_STRING="unicodeString",l.UNIFORM="uniform",l.UNION="union",l.UNIQUE_COLUMN_CONSTRAINT="uniqueColumnConstraint",l.UNIQUE_KEY_PROPERTY="uniqueKeyProperty",l.UNIX_DATE="unixDate",l.UNIX_MICROS="unixMicros",l.UNIX_MILLIS="unixMillis",l.UNIX_SECONDS="unixSeconds",l.UNIX_TO_STR="unixToStr",l.UNIX_TO_TIME="unixToTime",l.UNIX_TO_TIME_STR="unixToTimeStr",l.UNLOGGED_PROPERTY="unloggedProperty",l.UNNEST="unnest",l.UNPIVOT_COLUMNS="unpivotColumns",l.UPDATE="update",l.UPPER="upper",l.UPPERCASE_COLUMN_CONSTRAINT="uppercaseColumnConstraint",l.USE="use",l.USER_DEFINED_FUNCTION="userDefinedFunction",l.USING_DATA="usingData",l.USING_TEMPLATE_PROPERTY="usingTemplateProperty",l.UTC_DATE="utcDate",l.UTC_TIME="utcTime",l.UTC_TIMESTAMP="utcTimestamp",l.UUID="uuid",l.VALUES="values",l.VAR="var",l.VARIADIC="variadic",l.VARIANCE="variance",l.VARIANCE_POP="variancePop",l.VAR_MAP="varMap",l.VECTOR_SEARCH="vectorSearch",l.UUID_PROPERTY="uuidProperty",l.VERSION="version",l.VIEW_ATTRIBUTE_PROPERTY="viewAttributeProperty",l.VOLATILE_PROPERTY="volatileProperty",l.WATERMARK_COLUMN_CONSTRAINT="watermarkColumnConstraint",l.WEEK="week",l.WEEK_OF_YEAR="weekOfYear",l.WEEK_START="weekStart",l.WHEN="when",l.WHENS="whens",l.WHERE="where",l.WIDTH_BUCKET="widthBucket",l.WINDOW="window",l.WINDOW_SPEC="windowSpec",l.WITH="with",l.WITHIN_GROUP="withinGroup",l.WITH_DATA_PROPERTY="withDataProperty",l.WITH_FILL="withFill",l.WITH_JOURNAL_TABLE_PROPERTY="withJournalTableProperty",l.WITH_OPERATOR="withOperator",l.WITH_PROCEDURE_OPTIONS="withProcedureOptions",l.WITH_SCHEMA_BINDING_PROPERTY="withSchemaBindingProperty",l.WHILE_BLOCK="whileBlock",l.WITH_SYSTEM_VERSIONING_PROPERTY="withSystemVersioningProperty",l.WITH_TABLE_HINT="withTableHint",l.XML_ELEMENT="xmlElement",l.XML_GET="xmlGet",l.XML_KEY_VALUE_OPTION="xmlKeyValueOption",l.XML_NAMESPACE="xmlNamespace",l.XML_TABLE="xmlTable",l.XOR="xor",l.YEAR="year",l.YEAR_OF_WEEK="yearOfWeek",l.YEAR_OF_WEEK_ISO="yearOfWeekIso",l.ZERO_FILL_COLUMN_CONSTRAINT="zeroFillColumnConstraint",l.ZIPF="zipf",l))(GI||{}),dG=(t=>(t.INCREMENTAL="incremental",t.FULL="full",t))(dG||{}),eA=(h=>(h.TABLE="table",h.VIEW="view",h.INDEX="index",h.SCHEMA="schema",h.DATABASE="database",h.FUNCTION="function",h.PROCEDURE="procedure",h.TRIGGER="trigger",h.SEQUENCE="sequence",h.TEMPORARY_VIEW="temporary view",h))(eA||{}),fG=(i=>(i.TABLE="table",i.VIEW="view",i.SCHEMA="schema",i.FUNCTION="function",i.PROCEDURE="procedure",i))(fG||{}),xG=(t=>(t.CONNECTION="connection",t.QUERY="query",t))(xG||{}),TG=(r=>(r.CURSOR="cursor",r.VARIABLE="variable",r.TABLE="table",r.CONSTANT="constant",r))(TG||{}),SG=(i=>(i.SESSION="session",i.GLOBAL="global",i.LOCAL="local",i.PERSIST="persist",i.PERSIST_ONLY="persistOnly",i))(SG||{}),RG=(t=>(t.BREADTH="breadth",t.DEPTH="depth",t))(RG||{}),OG=(r=>(r.GENERATED="generated",r.STORED="stored",r.VIRTUAL="virtual",r.DEFAULT="default",r))(OG||{}),mG=(s=>(s.TABLE="table",s.COLUMN="column",s.VIEW="view",s))(mG||{}),NG=(o=>(o.PRIMARY_KEY="primaryKey",o.UNIQUE="unique",o.NOT_NULL="notNull",o.CHECK="check",o.DEFAULT="default",o.FOREIGN_KEY="foreignKey",o))(NG||{}),AM=(g=>(g.TABLE="table",g.VIEW="view",g.INDEX="index",g.SCHEMA="schema",g.DATABASE="database",g.FUNCTION="function",g.PROCEDURE="procedure",g.TRIGGER="trigger",g.SEQUENCE="sequence",g.CONSTRAINT="constraint",g.COLUMN="column",g))(AM||{}),IG=(t=>(t.CONDITIONAL="conditional",t.UNCONDITIONAL="unconditional",t))(IG||{}),yG=(t=>(t.GRANT="grant",t.REVOKE="revoke",t))(yG||{}),Yt=(f=>(f.INNER="inner",f.OUTER="outer",f.LEFT="left",f.RIGHT="right",f.FULL="full",f.CROSS="cross",f.SEMI="semi",f.ANTI="anti",f.ANY="any",f.ASOF="asof",f.STRAIGHT_JOIN="straightJoin",f.ARRAY="array",f))(Yt||{}),CG=(r=>(r.USER="user",r.ROLE="role",r.GROUP="group",r.PUBLIC="public",r))(CG||{}),bG=(t=>(t.SYSTEM_TIME="systemTime",t.TRANSACTION_TIME="transactionTime",t))(bG||{}),PG=(s=>(s.ROWS="rows",s.RANGE="range",s.GROUPS="groups",s))(PG||{}),At=(P=>(P.ARRAY="array",P.AGGREGATEFUNCTION="aggregatefunction",P.SIMPLEAGGREGATEFUNCTION="simpleaggregatefunction",P.BIGDECIMAL="bigdecimal",P.BIGINT="bigint",P.BIGNUM="bignum",P.BIGSERIAL="bigserial",P.BINARY="binary",P.BIT="bit",P.BLOB="blob",P.BOOLEAN="boolean",P.BPCHAR="bpchar",P.CHAR="char",P.DATE="date",P.DATE32="date32",P.DATEMULTIRANGE="datemultirange",P.DATERANGE="daterange",P.DATETIME="datetime",P.DATETIME2="datetime2",P.DATETIME64="datetime64",P.DECIMAL="decimal",P.DECIMAL32="decimal32",P.DECIMAL64="decimal64",P.DECIMAL128="decimal128",P.DECIMAL256="decimal256",P.DECFLOAT="decfloat",P.DOUBLE="double",P.DYNAMIC="dynamic",P.ENUM="enum",P.ENUM8="enum8",P.ENUM16="enum16",P.FILE="file",P.FIXEDSTRING="fixedstring",P.FLOAT="float",P.GEOGRAPHY="geography",P.GEOGRAPHYPOINT="geographypoint",P.GEOMETRY="geometry",P.POINT="point",P.RING="ring",P.LINESTRING="linestring",P.MULTILINESTRING="multilinestring",P.POLYGON="polygon",P.MULTIPOLYGON="multipolygon",P.HLLSKETCH="hllsketch",P.HSTORE="hstore",P.IMAGE="image",P.INET="inet",P.INT="int",P.INT128="int128",P.INT256="int256",P.INT4MULTIRANGE="int4multirange",P.INT4RANGE="int4range",P.INT8MULTIRANGE="int8multirange",P.INT8RANGE="int8range",P.INTERVAL="interval",P.IPADDRESS="ipaddress",P.IPPREFIX="ipprefix",P.IPV4="ipv4",P.IPV6="ipv6",P.JSON="json",P.JSONB="jsonb",P.LIST="list",P.LONGBLOB="longblob",P.LONGTEXT="longtext",P.LOWCARDINALITY="lowcardinality",P.MAP="map",P.MEDIUMBLOB="mediumblob",P.MEDIUMINT="mediumint",P.MEDIUMTEXT="mediumtext",P.MONEY="money",P.NAME="name",P.NCHAR="nchar",P.NESTED="nested",P.NOTHING="nothing",P.NULL="null",P.NUMMULTIRANGE="nummultirange",P.NUMRANGE="numrange",P.NVARCHAR="nvarchar",P.OBJECT="object",P.RANGE="range",P.ROWVERSION="rowversion",P.SERIAL="serial",P.SET="set",P.SMALLDATETIME="smalldatetime",P.SMALLINT="smallint",P.SMALLMONEY="smallmoney",P.SMALLSERIAL="smallserial",P.STRUCT="struct",P.SUPER="super",P.TEXT="text",P.TINYBLOB="tinyblob",P.TINYTEXT="tinytext",P.TIME="time",P.TIMETZ="timetz",P.TIME_NS="timeNs",P.TIMESTAMP="timestamp",P.TIMESTAMPNTZ="timestampntz",P.TIMESTAMPLTZ="timestampltz",P.TIMESTAMPTZ="timestamptz",P.TIMESTAMP_S="timestampS",P.TIMESTAMP_MS="timestampMs",P.TIMESTAMP_NS="timestampNs",P.TINYINT="tinyint",P.TSMULTIRANGE="tsmultirange",P.TSRANGE="tsrange",P.TSTZMULTIRANGE="tstzmultirange",P.TSTZRANGE="tstzrange",P.UBIGINT="ubigint",P.UINT="uint",P.UINT128="uint128",P.UINT256="uint256",P.UMEDIUMINT="umediumint",P.UDECIMAL="udecimal",P.UDOUBLE="udouble",P.UNION="union",P.UNKNOWN="unknown",P.USERDEFINED="user-defined",P.USMALLINT="usmallint",P.UTINYINT="utinyint",P.UUID="uuid",P.VARBINARY="varbinary",P.VARCHAR="varchar",P.VARIANT="variant",P.VECTOR="vector",P.XML="xml",P.YEAR="year",P.TDIGEST="tdigest",P))(At||{}),YI=(o=>(o.TABLE="table",o.VIEW="view",o.SCHEMA="schema",o.DATABASE="database",o.INDEX="index",o.COLUMN="column",o))(YI||{}),LG=(s=>(s.STATISTICS="statistics",s.COMPUTE="compute",s.TABLE="table",s))(LG||{}),wG=(s=>(s.ALL="all",s.DEFAULT="default",s.COLUMNS="columns",s))(wG||{}),MG=(t=>(t.PERCENT="percent",t.ROWS="rows",t))(MG||{}),kG=(e=>(e.STATISTICS="statistics",e))(kG||{}),DG=(t=>(t.REF_UPDATE="refUpdate",t.STRUCTURE="structure",t))(DG||{}),qG=(r=>(r.PATH="path",r.EXISTS="exists",r.VALUE="value",r.QUERY="query",r))(qG||{}),UG=(r=>(r.PATH="path",r.EXISTS="exists",r.VALUE="value",r.QUERY="query",r))(UG||{}),vG=(i=>(i.DATABASE="database",i.SCHEMA="schema",i.WAREHOUSE="warehouse",i.ROLE="role",i.CATALOG="catalog",i))(vG||{}),FG=(r=>(r.PRIMARY="primary",r.UNIQUE="unique",r.FULLTEXT="fulltext",r.SPATIAL="spatial",r))(FG||{}),BG=(t=>(t.LOCAL="local",t.REMOTE="remote",t))(BG||{}),$G=(r=>(r.HASH="hash",r.RANGE="range",r.LIST="list",r.REPLICATE="replicate",r))($G||{}),GG=(c=>(c.FLAT="flat",c.HASHED="hashed",c.RANGE_HASHED="rangeHashed",c.CACHE="cache",c.DIRECT="direct",c.IP_TRIE="ipTrie",c.POLYGON="polygon",c))(GG||{}),YG=(r=>(r.DEFAULT="default",r.ALL="all",r.FALLBACK="fallback",r.LOCKING="locking",r))(YG||{}),VG=(r=>(r.ON_COMMIT="onCommit",r.ON_DEMAND="onDemand",r.START_WITH="startWith",r.NEXT="next",r))(VG||{}),tD=(p=>(p.POST_CREATE="postCreate",p.POST_NAME="postName",p.POST_SCHEMA="postSchema",p.POST_WITH="postWith",p.POST_ALIAS="postAlias",p.POST_EXPRESSION="postExpression",p.POST_INDEX="postIndex",p.UNSUPPORTED="unsupported",p))(tD||{}),dM=(i=>(i.UNION="union",i.INTERSECT="intersect",i.EXCEPT="except",i.INNER="inner",i.OUTER="outer",i))(dM||{}),HG=(i=>(i.STRUCT="struct",i.VALUE="value",i.OBJECT="object",i.ALL="all",i.DISTINCT="distinct",i))(HG||{}),_G=(r=>(r.SESSION="session",r.GLOBAL="global",r.LOCAL="local",r.VARIABLE="variable",r))(_G||{}),WG=(i=>(i.POSITIONAL="positional",i.NAMED="named",i.QUESTION="question",i.NUMERIC="numeric",i.DOLLAR="dollar",i))(WG||{}),jG=(t=>(t.START="start",t.END="end",t))(jG||{}),sD=(s=>(s.LEADING="leading",s.TRAILING="trailing",s.BOTH="both",s))(sD||{});var VD={};W_(VD,{ALL_FUNCTIONS:()=>sy,AbsExpr:()=>aP,AcosExpr:()=>Wb,AcoshExpr:()=>jb,AddConstraintExpr:()=>EC,AddExpr:()=>we,AddMonthsExpr:()=>vF,AddPartitionExpr:()=>AC,AdjacentExpr:()=>ph,AggFuncExpr:()=>q,AiAggExpr:()=>u$,AiClassifyExpr:()=>yU,AiSummarizeAggExpr:()=>h$,AlgorithmPropertyExpr:()=>Wn,AliasExpr:()=>Re,AliasesExpr:()=>Hn,AllExpr:()=>cs,AllowedValuesPropertyExpr:()=>Vn,AlterColumnExpr:()=>Os,AlterDistStyleExpr:()=>SA,AlterExpr:()=>lu,AlterExprKind:()=>YI,AlterIndexExpr:()=>KD,AlterModifySqlSecurityExpr:()=>eq,AlterRenameExpr:()=>Yn,AlterSessionExpr:()=>mA,AlterSetExpr:()=>Sy,AlterSortKeyExpr:()=>RA,AnalyzeColumnsExpr:()=>hu,AnalyzeDeleteExpr:()=>hC,AnalyzeDeleteExprKind:()=>kG,AnalyzeExpr:()=>NA,AnalyzeExprKind:()=>LG,AnalyzeHistogramExpr:()=>pC,AnalyzeListChainedRowsExpr:()=>uC,AnalyzeSampleExpr:()=>lC,AnalyzeSampleExprKind:()=>MG,AnalyzeStatisticsExpr:()=>cC,AnalyzeStatisticsExprKind:()=>wG,AnalyzeValidateExpr:()=>gC,AnalyzeValidateExprKind:()=>DG,AnalyzeWithExpr:()=>uu,AndExpr:()=>Te,AnonymousAggFuncExpr:()=>GM,AnonymousExpr:()=>Qe,AnyExpr:()=>Tt,AnyValueExpr:()=>qL,ApiPropertyExpr:()=>JA,ApplicationPropertyExpr:()=>zA,ApplyExpr:()=>gU,ApproxDistinctExpr:()=>ML,ApproxPercentileAccumulateExpr:()=>b$,ApproxPercentileCombineExpr:()=>t$,ApproxPercentileEstimateExpr:()=>XF,ApproxQuantileExpr:()=>wh,ApproxQuantilesExpr:()=>e$,ApproxTopKAccumulateExpr:()=>QB,ApproxTopKCombineExpr:()=>ZB,ApproxTopKEstimateExpr:()=>oU,ApproxTopKExpr:()=>zB,ApproxTopSumExpr:()=>KB,ApproximateSimilarityExpr:()=>i$,ArgMaxExpr:()=>DA,ArgMinExpr:()=>qA,ArrayAggExpr:()=>Bn,ArrayAllExpr:()=>CU,ArrayAnyExpr:()=>bU,ArrayAppendExpr:()=>sb,ArrayCompactExpr:()=>PU,ArrayConcatAggExpr:()=>kL,ArrayConcatExpr:()=>hh,ArrayConstructCompactExpr:()=>UU,ArrayContainsAllExpr:()=>Fn,ArrayContainsExpr:()=>lP,ArrayDistinctExpr:()=>LU,ArrayExceptExpr:()=>wU,ArrayExpr:()=>ue,ArrayFilterExpr:()=>Va,ArrayFirstExpr:()=>uP,ArrayInsertExpr:()=>DU,ArrayIntersectExpr:()=>wA,ArrayLastExpr:()=>hP,ArrayMaxExpr:()=>MU,ArrayMinExpr:()=>kU,ArrayOverlapsExpr:()=>Fb,ArrayPositionExpr:()=>vU,ArrayPrependExpr:()=>rb,ArrayRemoveAtExpr:()=>qU,ArrayRemoveExpr:()=>uh,ArrayReverseExpr:()=>gP,ArraySizeExpr:()=>Rr,ArraySliceExpr:()=>EP,ArraySortExpr:()=>GU,ArraySumExpr:()=>YU,ArrayToStringExpr:()=>AP,ArrayUnionAggExpr:()=>g$,ArrayUniqueAggExpr:()=>l$,ArraysZipExpr:()=>VU,AsciiExpr:()=>cP,AsinExpr:()=>Xb,AsinhExpr:()=>Jb,AssumeColumnConstraintExpr:()=>Mb,AtIndexExpr:()=>fC,AtTimeZoneExpr:()=>gs,Atan2Expr:()=>Gq,AtanExpr:()=>zb,AtanhExpr:()=>Qb,AttachExpr:()=>WD,AttachOptionExpr:()=>xq,AutoIncrementColumnConstraintExpr:()=>kC,AutoIncrementPropertyExpr:()=>jn,AutoRefreshPropertyExpr:()=>Xn,AvgExpr:()=>DL,BackupPropertyExpr:()=>Jn,Base64DecodeBinaryExpr:()=>Dv,Base64DecodeStringExpr:()=>qv,Base64EncodeExpr:()=>Uv,BetweenExpr:()=>Ts,BinaryExpr:()=>U,BitLengthExpr:()=>eL,BitStringExpr:()=>LC,BitmapBitPositionExpr:()=>tU,BitmapBucketNumberExpr:()=>Kq,BitmapConstructAggExpr:()=>XB,BitmapCountExpr:()=>eU,BitmapOrAggExpr:()=>JB,BitwiseAndAggExpr:()=>HB,BitwiseAndExpr:()=>rh,BitwiseCountExpr:()=>Zq,BitwiseLeftShiftExpr:()=>jC,BitwiseNotExpr:()=>lh,BitwiseOrAggExpr:()=>_B,BitwiseOrExpr:()=>XC,BitwiseRightShiftExpr:()=>ih,BitwiseXorAggExpr:()=>WB,BitwiseXorExpr:()=>JC,BlockCompressionPropertyExpr:()=>qu,BlockExpr:()=>$A,BoolandExpr:()=>iU,BooleanExpr:()=>at,BoolnotExpr:()=>rU,BoolorExpr:()=>nU,BoolxorAggExpr:()=>jB,BracketExpr:()=>Lt,BuildPropertyExpr:()=>Mq,ByteLengthExpr:()=>sU,ByteStringExpr:()=>wC,COLUMN_PARTS:()=>U_,CONSTANTS:()=>dD,CacheExpr:()=>iy,CaseExpr:()=>ut,CaseSpecificColumnConstraintExpr:()=>kn,CastExpr:()=>z,CastToStrTypeExpr:()=>ib,CatalogPropertyExpr:()=>QA,CbrtExpr:()=>Ah,CeilExpr:()=>ti,ChangesExpr:()=>Ny,CharacterSetColumnConstraintExpr:()=>xu,CharacterSetExpr:()=>TA,CharacterSetPropertyExpr:()=>zr,CheckColumnConstraintExpr:()=>qC,CheckExpr:()=>iq,CheckJsonExpr:()=>_U,CheckXmlExpr:()=>WU,ChecksumPropertyExpr:()=>Uu,ChrExpr:()=>gh,CityHash64Expr:()=>cU,CloneExpr:()=>uy,ClusterExpr:()=>rr,ClusteredByPropertyExpr:()=>Ea,ClusteredColumnConstraintExpr:()=>Tu,CoalesceExpr:()=>tt,CodePointsToBytesExpr:()=>OU,CodePointsToStringExpr:()=>NU,CollateColumnConstraintExpr:()=>Su,CollateExpr:()=>MA,CollatePropertyExpr:()=>zn,CollationExpr:()=>jU,ColumnConstraintExpr:()=>yn,ColumnConstraintExprKind:()=>NG,ColumnConstraintKindExpr:()=>oe,ColumnDefExpr:()=>be,ColumnDefExprKind:()=>OG,ColumnExpr:()=>$,ColumnPositionExpr:()=>Ty,ColumnPrefixExpr:()=>aq,ColumnsExpr:()=>tb,CombinedAggFuncExpr:()=>H$,CombinedParameterizedAggExpr:()=>_$,CommandExpr:()=>$r,CommentColumnConstraintExpr:()=>Ru,CommentExpr:()=>Ry,CommentExprKind:()=>mG,CommitExpr:()=>aC,ComprehensionExpr:()=>Oy,CompressColumnConstraintExpr:()=>bA,CompressExpr:()=>jv,ComputePropertyExpr:()=>ZA,ComputedColumnConstraintExpr:()=>Dn,ConcatExpr:()=>Bt,ConcatWsExpr:()=>_t,ConditionExpr:()=>Ce,ConditionalInsertExpr:()=>ky,ConnectByRootExpr:()=>Eh,ConnectExpr:()=>Iy,ConnectorExpr:()=>Ae,ConstraintExpr:()=>my,ContainsExpr:()=>SP,ConvertExpr:()=>mU,ConvertTimezoneExpr:()=>vn,ConvertToCharsetExpr:()=>vb,CopyExpr:()=>BC,CopyExprKind:()=>BG,CopyGrantsPropertyExpr:()=>Qn,CopyParameterExpr:()=>yy,CorrExpr:()=>BB,CosExpr:()=>Kb,CoshExpr:()=>nP,CosineDistanceExpr:()=>jq,CotExpr:()=>Zb,CothExpr:()=>Yq,CountExpr:()=>bh,CountIfExpr:()=>vL,CovarPopExpr:()=>V$,CovarSampExpr:()=>Y$,CreateExpr:()=>ss,CreateExprKind:()=>eA,CredentialsExpr:()=>Cy,CredentialsPropertyExpr:()=>pd,CscExpr:()=>Vq,CschExpr:()=>Hq,CteExpr:()=>Ft,CubeExpr:()=>Yy,CumeDistExpr:()=>G$,CurrentAccountExpr:()=>XU,CurrentAccountNameExpr:()=>JU,CurrentAvailableRolesExpr:()=>zU,CurrentCatalogExpr:()=>Mh,CurrentClientExpr:()=>QU,CurrentDatabaseExpr:()=>KU,CurrentDateExpr:()=>pr,CurrentDatetimeExpr:()=>OP,CurrentIpAddressExpr:()=>ZU,CurrentOrganizationNameExpr:()=>cv,CurrentOrganizationUserExpr:()=>uv,CurrentRegionExpr:()=>pv,CurrentRoleExpr:()=>ab,CurrentRoleTypeExpr:()=>lv,CurrentSchemaExpr:()=>NP,CurrentSchemasExpr:()=>ev,CurrentSecondaryRolesExpr:()=>tv,CurrentSessionExpr:()=>sv,CurrentStatementExpr:()=>rv,CurrentTimeExpr:()=>si,CurrentTimestampExpr:()=>ri,CurrentTimestampLtzExpr:()=>mP,CurrentTimezoneExpr:()=>ov,CurrentTransactionExpr:()=>iv,CurrentUserExpr:()=>fh,CurrentVersionExpr:()=>RP,CurrentWarehouseExpr:()=>nv,DPipeExpr:()=>Wt,DataBlocksizePropertyExpr:()=>vu,DataDeletionPropertyExpr:()=>Fu,DataTypeExpr:()=>m,DataTypeExprKind:()=>At,DataTypeParamExpr:()=>Jr,DatabasePropertyExpr:()=>KA,DateAddExpr:()=>xt,DateBinExpr:()=>hv,DateDiffExpr:()=>_s,DateExpr:()=>pi,DateFormatColumnConstraintExpr:()=>Ou,DateFromPartsExpr:()=>BP,DateFromUnixDateExpr:()=>Ev,DateStrToDateExpr:()=>$P,DateSubExpr:()=>jt,DateToDateStrExpr:()=>GP,DateToDiExpr:()=>YP,DateTruncExpr:()=>ls,DatetimeAddExpr:()=>Ds,DatetimeDiffExpr:()=>yP,DatetimeExpr:()=>IP,DatetimeSubExpr:()=>Qs,DatetimeTruncExpr:()=>gv,DayExpr:()=>Nr,DayOfMonthExpr:()=>PP,DayOfWeekExpr:()=>CP,DayOfWeekIsoExpr:()=>bP,DayOfYearExpr:()=>LP,DaynameExpr:()=>wP,DdlExpr:()=>dn,DeclareExpr:()=>Ay,DeclareItemExpr:()=>dy,DeclareItemExprKind:()=>TG,DecodeCaseExpr:()=>cb,DecodeExpr:()=>ob,DecompressBinaryExpr:()=>Xv,DecompressStringExpr:()=>Jv,DecryptExpr:()=>yv,DecryptRawExpr:()=>Cv,DefaultColumnConstraintExpr:()=>mu,DefinerPropertyExpr:()=>Zn,DegreesExpr:()=>iP,DeleteExpr:()=>Gr,DenseRankExpr:()=>R$,DerivedTableExpr:()=>An,DescribeExpr:()=>Ql,DescribeExprKind:()=>fG,DetachExpr:()=>jD,DiToDateExpr:()=>VP,DictPropertyExpr:()=>Hu,DictPropertyExprKind:()=>GG,DictRangeExpr:()=>_u,DictSubPropertyExpr:()=>GC,DirectoryExpr:()=>su,DirectoryStageExpr:()=>nq,DistKeyPropertyExpr:()=>Kn,DistStylePropertyExpr:()=>ta,DistanceExpr:()=>QC,DistinctExpr:()=>et,DistributeExpr:()=>$C,DistributedByPropertyExpr:()=>ea,DistributedByPropertyExprKind:()=>$G,DivExpr:()=>wt,DmlExpr:()=>bs,DotExpr:()=>ge,DotProductExpr:()=>Xq,DropExpr:()=>tu,DropExprKind:()=>AM,DropPartitionExpr:()=>dC,DuplicateKeyPropertyExpr:()=>Bu,DynamicPropertyExpr:()=>Aa,EltExpr:()=>Ov,EmptyPropertyExpr:()=>da,EncodeColumnConstraintExpr:()=>Nu,EncodeExpr:()=>bv,EncodePropertyExpr:()=>ud,EncryptExpr:()=>Pv,EncryptRawExpr:()=>Lv,EndStatementExpr:()=>du,EndsWithExpr:()=>EL,EnginePropertyExpr:()=>sa,EnviromentPropertyExpr:()=>ga,EphemeralColumnConstraintExpr:()=>yu,EqExpr:()=>Me,EqualNullExpr:()=>wv,EscapeExpr:()=>Ba,EuclideanDistanceExpr:()=>Jq,ExceptExpr:()=>cr,ExcludeColumnConstraintExpr:()=>Iu,ExecuteAsPropertyExpr:()=>nr,ExecuteExpr:()=>BM,ExecuteSqlExpr:()=>Pq,ExistsExpr:()=>Ys,ExpExpr:()=>HP,ExplodeExpr:()=>Xt,ExplodeOuterExpr:()=>_A,ExplodingGenerateSeriesExpr:()=>p$,ExportExpr:()=>rq,Expression:()=>d,ExpressionKey:()=>GI,ExtendsLeftExpr:()=>nh,ExtendsRightExpr:()=>ah,ExternalPropertyExpr:()=>oa,ExtractExpr:()=>lr,FUNCTION_BY_NAME:()=>jl,FactorialExpr:()=>Mv,FallbackPropertyExpr:()=>$u,FarmFingerprintExpr:()=>pU,FeaturesAtTimeExpr:()=>HF,FetchExpr:()=>hr,FileFormatPropertyExpr:()=>ir,FilterExpr:()=>Xr,FinalExpr:()=>HI,FirstExpr:()=>d$,FirstValueExpr:()=>x$,FlattenExpr:()=>lU,Float64Expr:()=>uU,FloorExpr:()=>xh,ForInExpr:()=>Oq,ForcePropertyExpr:()=>od,ForeignKeyExpr:()=>Py,FormatExpr:()=>Kv,FormatJsonExpr:()=>SC,FormatPhraseExpr:()=>Rq,FreespacePropertyExpr:()=>Gu,FromBase32Expr:()=>_P,FromBase64Expr:()=>WP,FromBaseExpr:()=>wB,FromExpr:()=>rt,FromIso8601TimestampExpr:()=>Gv,FromTimeZoneExpr:()=>Sq,FuncExpr:()=>E,GapFillExpr:()=>pb,GenerateDateArrayExpr:()=>ii,GenerateEmbeddingExpr:()=>_F,GenerateSeriesExpr:()=>As,GenerateTimestampArrayExpr:()=>JP,GeneratedAsIdentityColumnConstraintExpr:()=>Jl,GeneratedAsRowColumnConstraintExpr:()=>UC,GeneratorExpr:()=>IU,GetExpr:()=>bb,GetExtractExpr:()=>Yv,GetbitExpr:()=>zP,GlobExpr:()=>LA,GlobalPropertyExpr:()=>ca,GrantExpr:()=>$y,GrantExprKind:()=>yG,GrantPrincipalExpr:()=>zy,GrantPrincipalExprKind:()=>CG,GrantPrivilegeExpr:()=>Jy,GreatestExpr:()=>ni,GroupConcatExpr:()=>sr,GroupExpr:()=>Yr,GroupingExpr:()=>n$,GroupingIdExpr:()=>a$,GroupingSetsExpr:()=>Vy,GtExpr:()=>je,GteExpr:()=>Je,HandlerPropertyExpr:()=>ra,HashAggExpr:()=>o$,HavingExpr:()=>ds,HavingMaxExpr:()=>gr,HeapPropertyExpr:()=>na,HeredocExpr:()=>xA,HexDecodeStringExpr:()=>Vv,HexEncodeExpr:()=>Hv,HexExpr:()=>$a,HexStringExpr:()=>fu,HintExpr:()=>Ps,HistoricalDataExpr:()=>eC,HistoricalDataExprKind:()=>bG,HllExpr:()=>c$,HostExpr:()=>$F,HourExpr:()=>QP,HybridPropertyExpr:()=>ed,ILikeExpr:()=>Gs,INTERVAL_DAY_TIME_RE:()=>yD,INTERVAL_STRING_RE:()=>ID,IcebergPropertyExpr:()=>pa,IdentifierExpr:()=>v,IfBlockExpr:()=>bq,IfExpr:()=>fe,IgnoreNullsExpr:()=>IA,InExpr:()=>lt,InOutColumnConstraintExpr:()=>FC,IncludePropertyExpr:()=>hd,IndexColumnConstraintExpr:()=>Lq,IndexColumnConstraintExprKind:()=>FG,IndexConstraintOptionExpr:()=>tq,IndexExpr:()=>wy,IndexParametersExpr:()=>My,IndexTableHintExpr:()=>Ky,InheritsPropertyExpr:()=>la,InitcapExpr:()=>Th,InlineExpr:()=>Ib,InlineLengthColumnConstraintExpr:()=>Cu,InputModelPropertyExpr:()=>ua,InputOutputFormatExpr:()=>Qy,InsertExpr:()=>es,InstallExpr:()=>XD,Int64Expr:()=>Uh,IntDivExpr:()=>Un,IntersectExpr:()=>ei,IntervalExpr:()=>qe,IntervalOpExpr:()=>Zs,IntervalSpanExpr:()=>Wr,IntoExpr:()=>iu,IntroducerExpr:()=>Uy,IsArrayExpr:()=>Zv,IsAsciiExpr:()=>zv,IsExpr:()=>ze,IsInfExpr:()=>KP,IsNanExpr:()=>ZP,IsNullValueExpr:()=>Qv,IsolatedLoadingPropertyExpr:()=>Yu,JSON_PATH_PARTS:()=>Vj,JarowinklerSimilarityExpr:()=>Qq,JoinExpr:()=>xe,JoinExprKind:()=>Yt,JoinHintExpr:()=>gn,JournalPropertyExpr:()=>Vu,JsonArrayAggExpr:()=>m$,JsonArrayAppendExpr:()=>gF,JsonArrayContainsExpr:()=>EF,JsonArrayExpr:()=>tF,JsonArrayInsertExpr:()=>AF,JsonBoolExpr:()=>aU,JsonCastExpr:()=>mb,JsonColumnDefExpr:()=>OC,JsonColumnDefExprKind:()=>qG,JsonExistsExpr:()=>sF,JsonExpr:()=>TC,JsonExtractArrayExpr:()=>uF,JsonExtractExpr:()=>ms,JsonExtractQuoteExpr:()=>Nq,JsonExtractScalarExpr:()=>bn,JsonFormatExpr:()=>hF,JsonKeyValueExpr:()=>RC,JsonKeysAtDepthExpr:()=>eF,JsonKeysExpr:()=>lb,JsonObjectAggExpr:()=>Nb,JsonObjectExpr:()=>Sh,JsonPathExpr:()=>Er,JsonPathFilterExpr:()=>Vs,JsonPathKeyExpr:()=>Mt,JsonPathPartExpr:()=>qt,JsonPathRecursiveExpr:()=>xr,JsonPathRootExpr:()=>zt,JsonPathScriptExpr:()=>Hs,JsonPathSelectorExpr:()=>ci,JsonPathSliceExpr:()=>Tr,JsonPathSubscriptExpr:()=>ts,JsonPathUnionExpr:()=>Sr,JsonPathWildcardExpr:()=>Dt,JsonRemoveExpr:()=>aF,JsonSchemaExpr:()=>mC,JsonSetExpr:()=>rF,JsonStripNullsExpr:()=>iF,JsonTableExpr:()=>ub,JsonTypeExpr:()=>oF,JsonValueArrayExpr:()=>nF,JsonValueExpr:()=>NC,JsonbContainsAllTopKeysExpr:()=>Oh,JsonbContainsAnyTopKeysExpr:()=>Rh,JsonbContainsExpr:()=>gb,JsonbDeleteAtPathExpr:()=>mh,JsonbExistsExpr:()=>lF,JsonbExtractExpr:()=>Nh,JsonbExtractScalarExpr:()=>Eb,JsonbObjectAggExpr:()=>O$,JustifyDaysExpr:()=>fP,JustifyHoursExpr:()=>xP,JustifyIntervalExpr:()=>TP,KillExpr:()=>gy,KillExprKind:()=>xG,KurtosisExpr:()=>XL,KwargExpr:()=>oh,LagExpr:()=>E$,LambdaExpr:()=>ps,LanguagePropertyExpr:()=>Qr,LastDayExpr:()=>_a,LastExpr:()=>f$,LastValueExpr:()=>UL,LateralExpr:()=>Ct,LaxBoolExpr:()=>xv,LaxFloat64Expr:()=>Tv,LaxInt64Expr:()=>Sv,LaxStringExpr:()=>Rv,LeadExpr:()=>A$,LeastExpr:()=>Ih,LeftExpr:()=>OF,LengthExpr:()=>$h,LevenshteinExpr:()=>tL,LikeExpr:()=>Qt,LikePropertyExpr:()=>Wu,LimitExpr:()=>kt,LimitOptionsExpr:()=>Hy,ListExpr:()=>KC,LiteralExpr:()=>N,LnExpr:()=>yh,LoadDataExpr:()=>Fy,LocaltimeExpr:()=>dh,LocaltimestampExpr:()=>nb,LocationExpr:()=>Eq,LocationPropertyExpr:()=>Zr,LockExpr:()=>BA,LockPropertyExpr:()=>ld,LockingPropertyExpr:()=>ju,LockingPropertyExprKind:()=>YG,LockingStatementExpr:()=>_D,LogExpr:()=>ur,LogPropertyExpr:()=>fa,LogicalAndExpr:()=>BL,LogicalOrExpr:()=>FL,LowerExpr:()=>Ar,LowerHexExpr:()=>Ph,LtExpr:()=>Fe,LteExpr:()=>nt,MakeIntervalExpr:()=>qP,ManhattanDistanceExpr:()=>zq,MapCatExpr:()=>CF,MapContainsKeyExpr:()=>bF,MapDeleteExpr:()=>PF,MapExpr:()=>mn,MapFromEntriesExpr:()=>yF,MapInsertExpr:()=>LF,MapKeysExpr:()=>wF,MapPickExpr:()=>MF,MapSizeExpr:()=>kF,MaskingPolicyColumnConstraintExpr:()=>wq,MaskingPropertyExpr:()=>td,MatchAgainstExpr:()=>db,MatchExpr:()=>Fq,MatchRecognizeExpr:()=>Wy,MatchRecognizeMeasureExpr:()=>_y,MaterializedPropertyExpr:()=>xa,MaxExpr:()=>$L,Md5DigestExpr:()=>DF,Md5Expr:()=>sL,Md5NumberLower64Expr:()=>qF,Md5NumberUpper64Expr:()=>UF,MedianExpr:()=>N$,MergeBlockRatioPropertyExpr:()=>qn,MergeExpr:()=>GA,MergeTreeTtlActionExpr:()=>In,MergeTreeTtlExpr:()=>Pn,MinExpr:()=>GL,MinhashCombineExpr:()=>r$,MinhashExpr:()=>s$,MinuteExpr:()=>_v,MlForecastExpr:()=>WF,MlTranslateExpr:()=>VF,ModExpr:()=>jr,ModeExpr:()=>I$,ModelAttributeExpr:()=>Iq,ModifyColumnExpr:()=>ZD,MonthExpr:()=>rL,MonthnameExpr:()=>iL,MonthsBetweenExpr:()=>dv,MulExpr:()=>xs,MultitableInsertsExpr:()=>nu,MultitableInsertsExprKind:()=>IG,NONNULL_CONSTANTS:()=>AD,NationalExpr:()=>vy,NegExpr:()=>bt,NeqExpr:()=>ft,NestedJsonSelectExpr:()=>Bq,NetFuncExpr:()=>Yb,NetworkPropertyExpr:()=>sd,NextDayExpr:()=>GB,NextValueForExpr:()=>Ob,NoPrimaryIndexPropertyExpr:()=>Ta,NonClusteredColumnConstraintExpr:()=>bu,NormalExpr:()=>BF,NormalizeExpr:()=>fb,NotExpr:()=>Le,NotForReplicationColumnConstraintExpr:()=>Pu,NotNullColumnConstraintExpr:()=>PA,NthValueExpr:()=>T$,NtileExpr:()=>y$,NullExpr:()=>Pt,NullSafeEqExpr:()=>Ks,NullSafeNeqExpr:()=>Ur,NullifExpr:()=>qh,NumberToStrExpr:()=>LB,Nvl2Expr:()=>FF,ObjectAggExpr:()=>S$,ObjectIdExpr:()=>pF,ObjectIdentifierExpr:()=>_C,ObjectInsertExpr:()=>cF,OffsetExpr:()=>Cn,OnClusterExpr:()=>Dq,OnCommitPropertyExpr:()=>Hr,OnConditionExpr:()=>qy,OnConflictExpr:()=>Dy,OnPropertyExpr:()=>Vr,OnUpdateColumnConstraintExpr:()=>Lu,OpclassExpr:()=>Ly,OpenJsonColumnDefExpr:()=>IC,OpenJsonColumnDefExprKind:()=>UG,OpenJsonExpr:()=>hb,OperatorExpr:()=>ch,OrExpr:()=>pt,OrderExpr:()=>Ie,OrderedExpr:()=>hs,OutputModelPropertyExpr:()=>ha,OverflowTruncateBehaviorExpr:()=>xC,OverlapsExpr:()=>zC,OverlayExpr:()=>xb,PERCENTILES:()=>MM,POSITION_META_KEYS:()=>v_,PadExpr:()=>eb,ParameterExpr:()=>YC,ParameterStylePropertyExpr:()=>ia,ParameterizedAggExpr:()=>$M,ParenExpr:()=>Se,ParseBignumericExpr:()=>dF,ParseDatetimeExpr:()=>RF,ParseIpExpr:()=>TF,ParseJsonExpr:()=>ai,ParseNumericExpr:()=>fF,ParseTimeExpr:()=>SF,ParseUrlExpr:()=>xF,PartitionBoundSpecExpr:()=>au,PartitionByListPropertyExpr:()=>Uq,PartitionByRangePropertyDynamicExpr:()=>pq,PartitionByRangePropertyExpr:()=>qq,PartitionByTruncateExpr:()=>Ju,PartitionExpr:()=>By,PartitionIdExpr:()=>cq,PartitionListExpr:()=>uq,PartitionRangeExpr:()=>oq,PartitionedByBucketExpr:()=>Xu,PartitionedByPropertyExpr:()=>ys,PartitionedOfPropertyExpr:()=>zu,PathColumnConstraintExpr:()=>Du,PercentRankExpr:()=>C$,PercentileContExpr:()=>gd,PercentileDiscExpr:()=>YM,PeriodForSystemTimeConstraintExpr:()=>DC,PiExpr:()=>nL,PivotAliasExpr:()=>WC,PivotAnyExpr:()=>wn,PivotExpr:()=>Ln,PlaceholderExpr:()=>ar,PlaceholderExprKind:()=>WG,PosexplodeExpr:()=>li,PosexplodeOuterExpr:()=>W$,PositionalColumnExpr:()=>Pb,PowExpr:()=>Gh,PragmaExpr:()=>Ey,PreWhereExpr:()=>iC,PredicateExpr:()=>ke,PredictExpr:()=>YF,PreviousDayExpr:()=>fv,PrimaryKeyColumnConstraintExpr:()=>vC,PrimaryKeyExpr:()=>ru,PriorExpr:()=>by,ProjectionDefExpr:()=>QD,ProjectionPolicyColumnConstraintExpr:()=>kb,PropertiesExpr:()=>He,PropertiesLocation:()=>tD,PropertyEqExpr:()=>ot,PropertyExpr:()=>w,PseudoTypeExpr:()=>HC,PseudocolumnExpr:()=>_I,PutExpr:()=>jA,QUERY_MODIFIERS:()=>Nj,QualifyExpr:()=>Xs,QuantileExpr:()=>Ad,QuarterExpr:()=>aL,QueryBandExpr:()=>JD,QueryExpr:()=>ee,QueryOptionExpr:()=>Aq,QueryTransformExpr:()=>hq,RadiansExpr:()=>oL,RandExpr:()=>vr,RandnExpr:()=>XI,RandstrExpr:()=>JF,RangeBucketExpr:()=>QF,RangeNExpr:()=>zF,RankExpr:()=>P$,RawStringExpr:()=>Mn,ReadCsvExpr:()=>ZF,ReadParquetExpr:()=>KF,RecursiveWithSearchExpr:()=>xy,RecursiveWithSearchExprKind:()=>RG,ReduceExpr:()=>eB,ReferenceExpr:()=>Zy,RefreshExpr:()=>ay,RefreshExprKind:()=>dG,RefreshTriggerPropertyExpr:()=>qb,RefreshTriggerPropertyExprKind:()=>VG,RegDomainExpr:()=>GF,RegexpCountExpr:()=>aB,RegexpExtractAllExpr:()=>tB,RegexpExtractExpr:()=>ZL,RegexpFullMatchExpr:()=>rB,RegexpILikeExpr:()=>Tb,RegexpInstrExpr:()=>iB,RegexpLikeExpr:()=>Ga,RegexpReplaceExpr:()=>sB,RegexpSplitExpr:()=>nB,RegrAvgxExpr:()=>k$,RegrAvgyExpr:()=>M$,RegrCountExpr:()=>D$,RegrInterceptExpr:()=>q$,RegrR2Expr:()=>U$,RegrSlopeExpr:()=>$$,RegrSxxExpr:()=>v$,RegrSxyExpr:()=>F$,RegrSyyExpr:()=>B$,RegrValxExpr:()=>L$,RegrValyExpr:()=>w$,RemoteWithConnectionModelPropertyExpr:()=>Ra,RenameColumnExpr:()=>vA,RepeatExpr:()=>oB,ReplaceExpr:()=>KL,ReplacePartitionExpr:()=>Tq,RespectNullsExpr:()=>yA,ReturnExpr:()=>ou,ReturningExpr:()=>FA,ReturnsPropertyExpr:()=>Kr,ReverseExpr:()=>NF,RevokeExpr:()=>Gy,RightExpr:()=>mF,RollbackExpr:()=>oC,RollupExpr:()=>OA,RollupIndexExpr:()=>lq,RollupPropertyExpr:()=>Db,RoundExpr:()=>cL,RowAccessPropertyExpr:()=>rd,RowFormatDelimitedPropertyExpr:()=>Qu,RowFormatPropertyExpr:()=>ma,RowFormatSerdePropertyExpr:()=>Zu,RowNumberExpr:()=>yb,RtrimmedLengthExpr:()=>IF,SAFE_IDENTIFIER_RE:()=>tw,SQLGLOT_ANONYMOUS:()=>ND,SQLGLOT_META:()=>q_,SafeAddExpr:()=>hB,SafeConvertBytesToStringExpr:()=>dB,SafeDivideExpr:()=>pL,SafeFuncExpr:()=>Ub,SafeMultiplyExpr:()=>gB,SafeNegateExpr:()=>EB,SafeSubtractExpr:()=>AB,SamplePropertyExpr:()=>Na,SchemaCommentPropertyExpr:()=>Ia,SchemaExpr:()=>Rt,ScopeResolutionExpr:()=>CA,SearchExpr:()=>yB,SearchIpExpr:()=>CB,SecExpr:()=>_q,SechExpr:()=>Wq,SecondExpr:()=>Wv,SecurePropertyExpr:()=>La,SecurityIntegrationPropertyExpr:()=>id,SelectExpr:()=>se,SelectExprKind:()=>HG,SemanticViewExpr:()=>gq,SemicolonExpr:()=>bC,Seq1Expr:()=>cB,Seq2Expr:()=>pB,Seq4Expr:()=>lB,Seq8Expr:()=>uB,SequencePropertiesExpr:()=>Br,SerdePropertiesExpr:()=>Ku,SessionParameterExpr:()=>VC,SessionParameterExprKind:()=>_G,SessionUserExpr:()=>kh,SetConfigPropertyExpr:()=>XA,SetExpr:()=>Zl,SetItemExpr:()=>Xl,SetItemExprKind:()=>SG,SetOperationExpr:()=>Ge,SetOperationExprKind:()=>dM,SetPropertyExpr:()=>_r,SettingsPropertyExpr:()=>Ca,Sha1DigestExpr:()=>fB,Sha2DigestExpr:()=>xB,Sha2Expr:()=>uL,ShaExpr:()=>lL,SharingPropertyExpr:()=>ya,ShowExpr:()=>zD,SignExpr:()=>hL,SimilarToExpr:()=>ZC,SinExpr:()=>eP,SinhExpr:()=>tP,SkewnessExpr:()=>JL,SkipJsonColumnExpr:()=>Xy,SliceExpr:()=>On,SortArrayExpr:()=>gL,SortExpr:()=>zl,SortKeyPropertyExpr:()=>ba,SoundexExpr:()=>TB,SoundexP123Expr:()=>SB,SpaceExpr:()=>AL,SplitExpr:()=>RB,SplitPartExpr:()=>OB,SqlReadWritePropertyExpr:()=>vs,SqlSecurityPropertyExpr:()=>Pa,SqrtExpr:()=>Ch,StDistanceExpr:()=>BU,StPointExpr:()=>FU,StabilityPropertyExpr:()=>Fs,StandardHashExpr:()=>IB,StarExpr:()=>Ne,StarMapExpr:()=>Ab,StartsWithExpr:()=>Vl,StddevExpr:()=>VL,StddevPopExpr:()=>HL,StddevSampExpr:()=>_L,StorageHandlerPropertyExpr:()=>eh,StoredProcedureExpr:()=>Cq,StrPositionExpr:()=>Bs,StrToDateExpr:()=>oi,StrToMapExpr:()=>PB,StrToTimeExpr:()=>Is,StrToUnixExpr:()=>bB,StreamExpr:()=>Eu,StreamingTablePropertyExpr:()=>Sa,StrictPropertyExpr:()=>Oa,StringExpr:()=>dP,StringToArrayExpr:()=>$U,StrtokExpr:()=>mB,StructExpr:()=>Es,StructExtractExpr:()=>MB,StuffExpr:()=>kB,SubExpr:()=>ye,SubqueryExpr:()=>he,SubqueryPredicateExpr:()=>Us,SubstringExpr:()=>Ns,SubstringIndexExpr:()=>NB,SumExpr:()=>YL,SummarizeExpr:()=>hy,SwapTableExpr:()=>Kl,SystimestampExpr:()=>av,TABLE_PARTS:()=>X$,TIMESTAMP_PARTS:()=>Ij,TableAliasExpr:()=>pe,TableColumnExpr:()=>Gl,TableExpr:()=>_,TableFromRowsExpr:()=>_l,TableSampleExpr:()=>sC,TagExpr:()=>dq,TagsExpr:()=>nd,TanExpr:()=>sP,TanhExpr:()=>rP,TemporaryPropertyExpr:()=>$s,TimeAddExpr:()=>Bh,TimeDiffExpr:()=>FP,TimeExpr:()=>dL,TimeFromPartsExpr:()=>Iv,TimeSliceExpr:()=>mv,TimeSliceExprKind:()=>jG,TimeStrToDateExpr:()=>xL,TimeStrToTimeExpr:()=>Yh,TimeStrToUnixExpr:()=>qB,TimeSubExpr:()=>vP,TimeToStrExpr:()=>Or,TimeToTimeStrExpr:()=>fL,TimeToUnixExpr:()=>DB,TimeTruncExpr:()=>Nv,TimeUnitExpr:()=>te,TimestampAddExpr:()=>Fh,TimestampDiffExpr:()=>Dh,TimestampExpr:()=>Lh,TimestampFromPartsExpr:()=>vM,TimestampLtzFromPartsExpr:()=>PL,TimestampSubExpr:()=>UP,TimestampTruncExpr:()=>Sn,TimestampTzFromPartsExpr:()=>LL,TitleColumnConstraintExpr:()=>wu,ToArrayExpr:()=>EU,ToBase32Expr:()=>jP,ToBase64Expr:()=>XP,ToBinaryExpr:()=>kv,ToBooleanExpr:()=>AU,ToCharExpr:()=>QL,ToCodePointsExpr:()=>fU,ToDaysExpr:()=>Av,ToDecfloatExpr:()=>TU,ToDoubleExpr:()=>pP,ToFileExpr:()=>RU,ToMapExpr:()=>vh,ToNumberExpr:()=>xU,ToTablePropertyExpr:()=>aa,ToVariantExpr:()=>dU,TransactionExpr:()=>nC,TransformExpr:()=>hU,TransformModelPropertyExpr:()=>wa,TransientPropertyExpr:()=>Ma,TranslateCharactersExpr:()=>mq,TranslateExpr:()=>oP,TriggerEventExpr:()=>cy,TriggerExecuteExpr:()=>oy,TriggerPropertiesExpr:()=>Gn,TriggerReferencingExpr:()=>py,TrimExpr:()=>Ya,TrimPosition:()=>sD,TruncExpr:()=>ew,TruncateTableExpr:()=>ly,TryBase64DecodeBinaryExpr:()=>vv,TryBase64DecodeStringExpr:()=>Fv,TryCastExpr:()=>$t,TryExpr:()=>HU,TryHexDecodeBinaryExpr:()=>Bv,TryHexDecodeStringExpr:()=>$v,TryToDecfloatExpr:()=>SU,TsOrDiToDiExpr:()=>SL,TsOrDsAddExpr:()=>Vh,TsOrDsDiffExpr:()=>UB,TsOrDsToDateExpr:()=>os,TsOrDsToDateStrExpr:()=>TL,TsOrDsToDatetimeExpr:()=>Vb,TsOrDsToTimeExpr:()=>Hb,TsOrDsToTimestampExpr:()=>_b,TupleExpr:()=>Ze,TypeExpr:()=>fq,TypeofExpr:()=>$q,UNWRAPPED_QUERIES:()=>Ls,UdtfExpr:()=>yt,UnaryExpr:()=>qs,UncacheExpr:()=>ny,UnhexExpr:()=>vB,UnicodeExpr:()=>RL,UnicodeStringExpr:()=>MC,UniformExpr:()=>FB,UnionExpr:()=>or,UniqueColumnConstraintExpr:()=>Mu,UniqueKeyPropertyExpr:()=>vq,UnixDateExpr:()=>OL,UnixMicrosExpr:()=>CL,UnixMillisExpr:()=>bL,UnixSecondsExpr:()=>yL,UnixToStrExpr:()=>mL,UnixToTimeExpr:()=>NL,UnixToTimeStrExpr:()=>IL,UnloggedPropertyExpr:()=>ka,UnnestExpr:()=>Ee,UnpivotColumnsExpr:()=>rC,UpdateExpr:()=>us,UpperExpr:()=>dr,UppercaseColumnConstraintExpr:()=>ku,UseExpr:()=>CC,UseExprKind:()=>vG,UserDefinedFunctionExpr:()=>fy,UsingDataExpr:()=>gu,UsingTemplatePropertyExpr:()=>ad,UtcDateExpr:()=>Bb,UtcTimeExpr:()=>$b,UtcTimestampExpr:()=>Gb,UuidExpr:()=>kA,UuidPropertyExpr:()=>kq,ValuesExpr:()=>tr,VarExpr:()=>Ve,VarMapExpr:()=>Ss,VariadicExpr:()=>Lb,VarianceExpr:()=>WL,VariancePopExpr:()=>jL,VectorSearchExpr:()=>jF,VersionExpr:()=>tC,ViewAttributePropertyExpr:()=>Da,VolatilePropertyExpr:()=>qa,WatermarkColumnConstraintExpr:()=>sq,WeekExpr:()=>Ed,WeekOfYearExpr:()=>MP,WeekStartExpr:()=>zL,WhenExpr:()=>_n,WhensExpr:()=>Au,WhereExpr:()=>St,WhileBlockExpr:()=>PC,WidthBucketExpr:()=>$B,WindowExpr:()=>Ue,WindowSpecExpr:()=>pu,WindowSpecExprKind:()=>PG,WithDataPropertyExpr:()=>th,WithExpr:()=>dt,WithFillExpr:()=>jy,WithJournalTablePropertyExpr:()=>Ua,WithOperatorExpr:()=>eu,WithProcedureOptionsExpr:()=>Fa,WithSchemaBindingPropertyExpr:()=>va,WithSystemVersioningPropertyExpr:()=>sh,WithTableHintExpr:()=>cu,WithinGroupExpr:()=>ns,XmlElementExpr:()=>Sb,XmlGetExpr:()=>YB,XmlKeyValueOptionExpr:()=>yq,XmlNamespaceExpr:()=>yC,XmlTableExpr:()=>Rb,XorExpr:()=>hA,YearExpr:()=>wL,YearOfWeekExpr:()=>kP,YearOfWeekIsoExpr:()=>DP,ZeroFillColumnConstraintExpr:()=>wb,ZipfExpr:()=>VB,alias:()=>Be,and:()=>ve,array:()=>UA,case_:()=>qD,cast:()=>X,column:()=>$n,columnTableNames:()=>wM,combine:()=>VA,condition:()=>G_,convert:()=>ht,delete_:()=>wj,except:()=>$_,expand:()=>Yj,false_:()=>it,findTables:()=>Dj,from:()=>bj,func:()=>HA,insert:()=>Lj,intersect:()=>B_,isType:()=>Rn,literal:()=>Hl,maybeCopy:()=>$e,maybeParse:()=>W,merge:()=>kj,normalizeTableName:()=>aM,not:()=>ks,null_:()=>le,or:()=>Vt,paren:()=>zs,parseIdentifier:()=>ty,renameColumn:()=>vj,renameTable:()=>Uj,replaceChildren:()=>SM,replacePlaceholders:()=>Gj,replaceTables:()=>$j,replaceTree:()=>Bj,select:()=>Ye,subquery:()=>DD,table:()=>F_,tableName:()=>Fj,table_:()=>yj,toColumn:()=>j$,toIdentifier:()=>K,toInterval:()=>Cj,toTable:()=>UI,true_:()=>We,tuple:()=>qj,union:()=>WA,update:()=>Mj,values:()=>Pj,var_:()=>Z,wrap:()=>mr,xor:()=>ED});import{DateTime as D_}from"luxon";import{DateTime as UY}from"luxon";import{DateTime as Tn,Duration as fn}from"luxon";var tA=class tA{constructor(e){this._collected=!1;let{expression:t,sources:s,outerColumns:r,parent:i,scopeType:o="root",lateralSources:c,cteSources:p,canBeCorrelated:u}=e;this.expression=t,this.sources=s||new Map,this.lateralSources=c||new Map,this.cteSources=p||new Map;for(let[h,g]of this.lateralSources)this.sources.set(h,g);for(let[h,g]of this.cteSources)this.sources.set(h,g);this.outerColumns=r||[],this.parent=i,this.scopeType=o,this.subqueryScopes=[],this.derivedTableScopes=[],this.tableScopes=[],this.cteScopes=[],this.unionScopes=[],this.udtfScopes=[],this.canBeCorrelated=u??!1,this.clearCache()}clearCache(){this._collected=!1,this._rawColumns=void 0,this._tableColumns=void 0,this._stars=void 0,this._derivedTables=void 0,this._udtfs=void 0,this._tables=void 0,this._ctes=void 0,this._subqueries=void 0,this._selectedSources=void 0,this._columns=void 0,this._externalColumns=void 0,this._localColumns=void 0,this._joinHints=void 0,this._pivots=void 0,this._references=void 0,this._semiAntiJoinTables=void 0,this._columnIndex=void 0}branch(e){let{expression:t,scopeType:s,sources:r,cteSources:i,lateralSources:o,...c}=e,p=new Map(this.cteSources);if(i)for(let[u,h]of i)p.set(u,h);return new tA({expression:t.unnest(),sources:r?new Map(r):void 0,parent:this,scopeType:s,cteSources:p,lateralSources:o?new Map(o):void 0,canBeCorrelated:this.canBeCorrelated||s==="subquery"||s==="udtf",...c})}collect(){this._tables=[],this._ctes=[],this._subqueries=[],this._derivedTables=[],this._udtfs=[],this._rawColumns=[],this._tableColumns=[],this._stars=[],this._joinHints=[],this._semiAntiJoinTables=new Set,this._columnIndex=new WeakSet;for(let e of this.walk({bfs:!1}))if(e!==this.expression)if(e instanceof ge&&e.isStar)this._stars.push(e);else if(e instanceof $&&!(e instanceof _I))this._columnIndex.add(e),e.args.this instanceof Ne?this._stars.push(e):this._rawColumns.push(e);else if(e instanceof _&&!(e.parent instanceof gn)){let t=e.parent;if(t instanceof xe){let s=t;(s.args.kind==="semi"||s.args.kind==="anti")&&this._semiAntiJoinTables.add(e.aliasOrName)}this._tables.push(e)}else if(e instanceof gn)this._joinHints.push(e);else if(e instanceof yt)this._udtfs.push(e);else if(e instanceof Ft)this._ctes.push(e);else if(e instanceof he){let t=JG(e);rD(e)&&t&&this._derivedTables.push(e)}else Ls.some(t=>e instanceof t)&&!JG(e)?this._subqueries.push(e):e instanceof Gl&&this._tableColumns.push(e);this._collected=!0}ensureCollected(){this._collected||this.collect()}walk(e={}){return rA(this.expression,e)}find(...e){return PW(this.expression,e,{bfs:!0})}findAll(...e){return Dr(this.expression,e,{bfs:!0})}replace(e,t){e.replace(t),this.clearCache()}get tables(){return this.ensureCollected(),this._tables??[]}get ctes(){return this.ensureCollected(),this._ctes??[]}get derivedTables(){return this.ensureCollected(),this._derivedTables??[]}get udtfs(){return this.ensureCollected(),this._udtfs??[]}get subqueries(){return this.ensureCollected(),this._subqueries??[]}get stars(){return this.ensureCollected(),this._stars??[]}get columnIndex(){return this.ensureCollected(),this._columnIndex??new WeakSet}get isSubquery(){return this.scopeType==="subquery"}get isDerivedTable(){return this.scopeType==="derivedTable"}get isUnion(){return this.scopeType==="union"}get isCte(){return this.scopeType==="cte"}get isRoot(){return this.scopeType==="root"}get isUdtf(){return this.scopeType==="udtf"}get isCorrelatedSubquery(){return!!(this.canBeCorrelated&&0<this.externalColumns.length)}get columns(){if(this._columns===void 0){this.ensureCollected();let e=this._rawColumns??[],t=[];for(let r of[...this.subqueryScopes,...this.udtfScopes,...this.derivedTableScopes.filter(i=>i.canBeCorrelated)])t.push(...r.externalColumns);let s=new Set(this.expression.namedSelects);this._columns=[];for(let r of[...e,...t]){let i=r.findAncestor(se,Xs,Ie,ds,Ps,_,Ne,et);(!i||r.table||i instanceof se||i instanceof _&&!(i.args.this instanceof E)||(i instanceof Ie||i instanceof et)&&(i.parent instanceof Ue||i.parent instanceof ns||!(i.parent instanceof se)||!s.has(r.name))||i instanceof Ne&&r.argKey!=="except")&&this._columns.push(r)}}return this._columns}get tableColumns(){return this._tableColumns===void 0&&this.ensureCollected(),this._tableColumns??[]}get externalColumns(){if(this._externalColumns===void 0)if(this.expression instanceof Ge){let[e,t]=this.unionScopes;this._externalColumns=[...e.externalColumns,...t.externalColumns]}else{let e=new Set(this.references.map(([t])=>t));this._externalColumns=this.columns.filter(t=>!e.has(t.table)&&!this.semiOrAntiJoinTables.has(t.table))}return this._externalColumns}get localColumns(){if(this._localColumns===void 0){let e=new Set(this.externalColumns);this._localColumns=this.columns.filter(t=>!e.has(t))}return this._localColumns}get unqualifiedColumns(){return this.columns.filter(e=>!e.table)}get joinHints(){return this._joinHints===void 0?[]:this._joinHints}get pivots(){if(!this._pivots){this._pivots=[];for(let[,e]of this.references){let t=e.args.pivots;t&&Array.isArray(t)&&this._pivots.push(...t)}}return this._pivots}get semiOrAntiJoinTables(){return this._semiAntiJoinTables||new Set}get references(){if(this._references===void 0){this._references=[];for(let e of this.tables)this._references.push([e.aliasOrName,e]);for(let e of[...this.derivedTables,...this.udtfs]){let t=iD(e),s=e.getArgKey("pivots")?e:e.unnest();this._references.push([t,s])}}return this._references}get selectedSources(){if(this._selectedSources===void 0){this._selectedSources={};for(let[e,t]of this.references){if(this.semiOrAntiJoinTables.has(e))continue;if(e in this._selectedSources)throw new $l(`Alias already used: ${e}`);let s=this.sources.get(e);s!==void 0&&(this._selectedSources[e]=[t,s])}}return this._selectedSources}sourceColumns(e){return this.columns.filter(t=>t.table===e)}renameSource(e,t){let s=e||"",r=this.sources.get(s);r!==void 0&&(this.sources.delete(s),this.sources.set(t,r))}addSource(e,t){this.sources.set(e,t),this.clearCache()}removeSource(e){this.sources.delete(e),this.clearCache()}*traverse(){let e=[this],t=[];for(;0<e.length;){let s=e.pop();t.push(s),e.push(...s.cteScopes,...s.unionScopes,...s.tableScopes,...s.subqueryScopes)}for(let s=t.length-1;0<=s;s--)yield t[s]}refCount(){let e=new Map;for(let t of this.traverse()){for(let[,s]of Object.values(t.selectedSources))s instanceof tA&&e.set(s,(e.get(s)||0)+1);for(let s of t.semiOrAntiJoinTables){let r=t.sources.get(s);r!==void 0&&r instanceof tA&&e.set(r,(e.get(r)||0)+1)}}return e}toString(){return`<Scope ${this.scopeType}>`}};n(tA,"Scope");var js=tA;function sA(a){if(![ee,dn,bs].some(s=>a instanceof s))return[];let t=[];for(let s of hn(new js({expression:a})))t.push(s);return t}n(sA,"traverseScope");function*hn(a){let e=a.expression;if(e instanceof se)yield*XG(a);else if(e instanceof Ge){yield*VI(a),yield*CW(a);return}else if(e instanceof he)a.isRoot?yield*XG(a):yield*QG(a);else if(e instanceof _)yield*zG(a);else if(e instanceof yt)yield*bW(a);else if(e instanceof dn){e.args.expression instanceof ee&&(yield*VI(a),yield*hn(new js({expression:e.args.expression,cteSources:a.cteSources})));return}else if(e instanceof bs){yield*VI(a);for(let t of Dr(e,[ee])){let s=t.parent;s&&!(s instanceof Ft)&&!(s instanceof he)&&(yield*hn(new js({expression:t,cteSources:a.cteSources})))}return}else return;yield a}n(hn,"_traverseScope");function*XG(a){yield*VI(a),yield*zG(a),yield*QG(a)}n(XG,"traverseSelect");function*CW(a){let e,t=[a],s=a.expression,r=[s.right,s.left];for(;0<r.length;){let i=r.pop(),o=t[t.length-1],c=o.branch({expression:i,outerColumns:o.outerColumns,scopeType:"union"});if(i instanceof Ge){yield*VI(c),t.push(c),r.push(i.right),r.push(i.left);continue}let p;for(let u of hn(c))yield u,p=u;e&&p?(t.pop(),o.unionScopes=[e,p],e=o,yield o):e=p}}n(CW,"traverseUnion");function*VI(a){let e=new Map;for(let t of a.ctes){let s=t.alias,r=a.expression.args.with;if(r&&Y(r,dt)&&r.args.recursive){let c=t.args.this;c instanceof Ge&&c.args.this&&e.set(s,a.branch({expression:c.args.this,scopeType:"cte"}))}let i=t.args.this;if(!i)continue;let o;for(let c of hn(a.branch({expression:i,cteSources:e,outerColumns:t.aliasColumnNames||[],scopeType:"cte"})))yield c,o=c;o&&(e.set(s,o),a.cteScopes.push(o))}for(let[t,s]of e)a.sources.set(t,s),a.cteSources.set(t,s)}n(VI,"traverseCtes");function rD(a){return!!(a instanceof he&&(a.alias||Ls.some(e=>a.args.this instanceof e)))}n(rD,"isDerivedTable");function JG(a){let e=a.parent;for(;e instanceof he;)e=e.parent;return e instanceof rt||e instanceof xe}n(JG,"_isFromOrJoin");function iD(a){let e=a.getArgKey("alias"),t=a.alias;return!t&&e instanceof pe&&e.columns.length===1&&(t=e.columns[0].name),t}n(iD,"getSourceAlias");function*zG(a){let e=new Map,t=[],s=a.expression.getArgKey("from");s?.args.this&&t.push(s.args.this);for(let i of a.expression.getArgKey("joins")||[])i.args.this&&t.push(i.args.this);a.expression instanceof _&&t.push(a.expression);for(let i of a.expression.getArgKey("laterals")||[])t.push(i);let r=0;for(;r<t.length;){let i=t[r++];if(i instanceof HI&&(i=i.getArgKey("this")),i instanceof _){let h=i.name,g=i.aliasOrName;if(a.sources.has(h)&&!i.db){let f=i.args.pivots;f&&0<f.length?e.set(f[0].alias,i):e.set(g,a.sources.get(h))}else e.has(g)?e.set(En(Array.from(e.keys()),h),i):e.set(g,i);if(i!==a.expression)for(let f of i.args.joins||[])Y(f.args.this,d)&&t.push(f.args.this);continue}if(!(i instanceof An))continue;let o,c,p;if(i instanceof yt)o=e,c="udtf",p=a.udtfScopes;else if(i instanceof he&&rD(i)){o=void 0,c="derivedTable",p=a.derivedTableScopes;for(let h of i.getArgKey("joins")||[])h.args.this&&t.push(h.args.this)}else{t.push(i.getArgKey("this"));for(let h of i.getArgKey("joins")||[])h.args.this&&t.push(h.args.this);continue}let u;for(let h of hn(a.branch({expression:i,lateralSources:o,outerColumns:i.aliasColumnNames||[],scopeType:c})))yield h,u=h,e.set(iD(i),u);u&&(p.push(u),a.tableScopes.push(u))}for(let[i,o]of e)a.sources.set(i,o)}n(zG,"traverseTables");function*QG(a){for(let e of a.subqueries){let t;for(let s of hn(a.branch({expression:e,scopeType:"subquery"})))yield s,t=s;t&&a.subqueryScopes.push(t)}}n(QG,"traverseSubqueries");function*bW(a){let e;a.expression instanceof Ee?e=a.expression.args.expressions??[]:a.expression instanceof Ct&&a.expression.args.this?e=[a.expression.args.this]:e=[];let t=new Map;for(let s of e){if(!(s instanceof he))continue;let r;for(let i of hn(a.branch({expression:s,scopeType:"subquery",outerColumns:s.aliasColumnNames||[]})))yield i,r=i,t.set(iD(s),i);r&&a.subqueryScopes.push(r)}for(let[s,r]of t)a.sources.set(s,r)}n(bW,"traverseUdtfs");function $X(a){let e=sA(a);return D(e,-1)}n($X,"buildScope");function*rA(a,e={}){let{bfs:t=!0,prune:s}=e,r=!1;for(let i of a.walk({bfs:t,prune:n(o=>r||(s?s(o):!1),"prune")}))if(r=!1,yield i,i!==a&&(i instanceof Ft||(i.parent instanceof rt||i.parent instanceof xe)&&rD(i)||i.parent instanceof yt&&i instanceof ee||Ls.some(o=>i instanceof o))&&(r=!0,i instanceof he||i instanceof yt))for(let o of["joins","laterals","pivots"]){let c=i.getArgKey(o);if(Array.isArray(c))for(let p of c)yield*rA(p,{bfs:t})}}n(rA,"walkInScope");function Dr(a,e,t={}){let{bfs:s=!0}=t,r=[];for(let i of rA(a,{bfs:s}))for(let o of e)if(i instanceof o){r.push(i);break}return r}n(Dr,"findAllInScope");function PW(a,e,t={}){let{bfs:s=!0}=t;for(let r of rA(a,{bfs:s}))for(let i of J(e))if(r instanceof i)return r}n(PW,"findInScope");function XX(a,e={}){let{dnf:t=!1,maxDistance:s=128}=e,r=new nA({annotateNewExpressions:!1}),i=[];for(let o of a.walk({prune:n(c=>c instanceof Ae,"prune")}))o instanceof Ae&&i.push(o);for(let o of i){if(xM(o,{dnf:t}))continue;let c=o===a,p=o.copy();o.transform(h=>r.rewriteBetween(h),{copy:!1});let u=ZG(o,{dnf:t,max:s});if(s<u)return a;try{let h=TM(o,g=>KG(g,{dnf:t,maxDistance:s,simplifier:r}));o=o.replace(h)}catch(h){if(h instanceof $l)return o.replace(p),c?p:a;throw h}c&&(a=o)}return a}n(XX,"normalize");function xM(a,e={}){let{dnf:t=!1}=e,[s,r]=t?[Te,pt]:[pt,Te];return!Dr(a,[r]).some(i=>i.findAncestor(s))}n(xM,"normalized");function ZG(a,e={}){let{dnf:t=!1,max:s=1/0}=e,r=-1;for(let i of a.findAll(Ae))r-=1;for(let i of WI(a,{dnf:t,max:s}))if(r+=i,s<r)return r;return r}n(ZG,"normalizationDistance");function*WI(a,e){let{dnf:t,max:s=1/0,depth:r=0}=e;if(s<r){yield r;return}let i=a.unnest();if(!(i instanceof Ae)){yield 1;return}let o=r+1,c=i.left,p=i.right;if(!c||!p){yield 1;return}if(i instanceof(t?Te:pt))for(let h of WI(c,{dnf:t,max:s,depth:o}))for(let g of WI(p,{dnf:t,max:s,depth:o}))yield h+g;else yield*WI(c,{dnf:t,max:s,depth:o}),yield*WI(p,{dnf:t,max:s,depth:o})}n(WI,"predicateLengths");function KG(a,e){let{dnf:t,maxDistance:s,simplifier:r}=e;if(xM(a,{dnf:t}))return a;let i=ZG(a,{dnf:t,max:s});if(s<i)throw new $l(`Normalization distance ${i} exceeds max ${s}`);SM(a,x=>KG(x,e));let[o,c]=t?[pt,Te]:[Te,pt];if(!(a instanceof c))return a;let[p,u]=a.unnestOperands();if(!p||!u)return a;let h=c===Te?ve:Vt,g=o===Te?ve:Vt,f=r??new nA({annotateNewExpressions:!1});if(p instanceof o&&u instanceof o){let x=Array.from(p.findAll(Ae)).length;return Array.from(u.findAll(Ae)).length<x?fM(p,u,h,g,f):fM(u,p,h,g,f)}return p instanceof o?fM(u,p,h,g,f):u instanceof o?fM(p,u,h,g,f):a}n(KG,"distributiveLaw");function fM(a,e,t,s,r){let i=e.left,o=e.right;if(!i||!o)return a;if(a instanceof Ae)return SM(a,u=>{let h=iA(t([u,i])),g=iA(t([u,o]));return s([r.uniqSort(h),r.uniqSort(g)],{copy:!1})}),a;let c=iA(t([a,i])),p=iA(t([a,o]));return s([r.uniqSort(c),r.uniqSort(p)],{copy:!1})}n(fM,"distribute");var xn="final";function IM(a,e={}){let{constantPropagation:t=!1,coalesceSimplification:s=!1,dialect:r}=e;return new nA({dialect:r}).simplify(a,{constantPropagation:t,coalesceSimplification:s})}n(IM,"simplify");var hD=class hD extends Error{constructor(e){super(e),this.name="UnsupportedUnit"}};n(hD,"UnsupportedUnit");var Ms=hD;function aA(...a){return function(e,t){return function(...s){try{return e.apply(this,s)}catch(r){if(a.some(i=>r instanceof i))return s[0];throw r}}}}n(aA,"catch_");function Js(a,e){return function(...t){let s=t[0],r=a.apply(this,t);if(r===void 0)return r;if(this.annotateNewExpressions&&s!==r&&r instanceof d){this._annotator.clear();let i=this._annotator.annotate(r,{annotateScope:!1});return i.type=s.type,i}return r}}n(Js,"annotateTypesOnChange");function iA(a){if(!(a instanceof Ae))return a;let e=a.args,t=Object.values(e);for(let s of t){if(!(s instanceof d))continue;let r=s.unnest();r._constructor===a._constructor&&s.replace(r)}return a}n(iA,"flatten");function LW(a,e){if(!(a instanceof Se))return a;let t=a.args.this,s=a.parent,r=s instanceof ke;return t instanceof se||s instanceof Us||s instanceof Lt||ae.getOrRaise(e)._constructor.REQUIRES_PARENTHESIZED_STRUCT_ACCESS&&s instanceof ge&&(s.right instanceof v||s.right instanceof Ne)?a:t instanceof ke&&!(r||s instanceof bt||s instanceof U&&!(s instanceof Ae))||!(s instanceof Ce||s instanceof U)||s instanceof Se||!(t instanceof U)&&!((t instanceof Le||t instanceof ze)&&r)||t instanceof we&&s instanceof we||t instanceof xs&&s instanceof xs||t instanceof xs&&(s instanceof we||s instanceof ye)?t??a:a}n(LW,"simplifyParens");function wW(a,e={}){let{root:t=!0}=e;if(a instanceof Te&&(t||!a.sameParent)&&xM(a,{dnf:!0})){let s=new Map;for(let r of rA(a,{prune:n(i=>i instanceof fe,"prune")}))if(r instanceof Me){let i=r.left,o=r.right;i instanceof $&&o instanceof N?s.set(i.sql(),[i,o]):o instanceof $&&i instanceof N&&s.set(o.sql(),[o,i])}if(0<s.size)for(let r of Dr(a,[$])){let i=r.parent,o=s.get(r.sql()),[c,p]=o||[void 0,void 0];c!==void 0&&r!==c&&!(i instanceof ze&&i.args.expression instanceof Pt)&&r.replace(p.copy())}}return a}n(wW,"propagateConstants");function MW(a,e,t=28){let s=n(y=>{let C=y.indexOf("."),I=C===-1?0:C-y.length+1;return[BigInt(y.replace(".","")),I]},"parse"),[r,i]=s(a),[o,c]=s(e),p=r*10n**BigInt(t+1)/o,h=p.toString().length-t,g;if(h<=0)g=p;else if(h===1)g=p/10n+(5n<=p%10n?1n:0n);else{let y=10n**BigInt(h),C=10n**BigInt(h-1)*5n;g=p/y+(C<=p%y?1n:0n)}let f=g.toString(),x=f.length+(i-c-t-1+h),T;return x<=0?T="0."+"0".repeat(-x)+f:f.length<=x?T=f+"0".repeat(x-f.length):T=f.slice(0,x)+"."+f.slice(x),T.includes(".")?T.replace(/\.?0+$/,"")||"0":T}n(MW,"decimalDiv");function eY(a){return a instanceof d&&a.isNumber}n(eY,"isNumber");function kW(a){return a instanceof qe&&cD(a)!==void 0}n(kW,"isInterval");function DW(a){return AD.some(e=>a instanceof e)||qr(a)}n(DW,"isNonnullConstant");function jI(a){return dD.some(e=>a instanceof e)||qr(a)}n(jI,"isConstant");function uD(a,e,t){let s=lA(a,e,t);if(a.toMillis()===s.toMillis())return[s,s.plus(uA(e))]}n(uD,"dateTruncRange");function qW(a){if(a.length===0)return[];let e=[...a].sort((s,r)=>s[0].toMillis()-r[0].toMillis()),t=[e[0]];for(let[s,r]of e.slice(1)){let i=t[t.length-1];s.toMillis()<=i[1].toMillis()?t[t.length-1]=[i[0],i[1].toMillis()<r.toMillis()?r:i[1]]:t.push([s,r])}return t}n(qW,"mergeRanges");function MY(a,e,t){return ve([new Je({this:a,expression:fs(e[0],t)}),new Fe({this:a,expression:fs(e[1],t)})],{copy:!1})}n(MY,"dateTruncEqExpression");function UW(a,e,t,s,r){let i=uD(e,t,s);if(i)return MY(a,i,r)}n(UW,"dateTruncEq");function vW(a,e,t,s,r){let i=uD(e,t,s);if(i)return ve([new Fe({this:a,expression:fs(i[0],r)}),new Je({this:a,expression:fs(i[1],r)})],{copy:!1})}n(vW,"dateTruncNeq");function as(a){return a instanceof at&&a.args.this||a instanceof N&&a.isNumber&&!mM(a)}n(as,"alwaysTrue");function RM(a){return pA(a)||Ht(a)||mM(a)}n(RM,"alwaysFalse");function mM(a){return a instanceof N&&a.toValue()===0}n(mM,"isZero");function pA(a){return a instanceof at&&!a.args.this}n(pA,"isFalse");function Ht(a){return a instanceof Pt}n(Ht,"isNull");function nD(a,e,t){if(a instanceof Me||a instanceof ze)return cA(e===t);if(a instanceof ft)return cA(e!==t);if(a instanceof je)return cA(t<e);if(a instanceof Je)return cA(t<=e);if(a instanceof Fe)return cA(e<t);if(a instanceof nt)return cA(e<=t)}n(nD,"evalBoolean");function kY(a){let e=Tn.fromISO(a,{zone:"utc"});return e.isValid?e:Tn.fromSQL(a,{zone:"utc"})}n(kY,"parseDateTime");function FW(a){if(Tn.isDateTime(a))return a.toUTC().startOf("day");let e=typeof a=="string"?kY(a):Tn.fromMillis(a,{zone:"utc"});return e.isValid?e.startOf("day"):void 0}n(FW,"castAsDate");function oD(a){if(Tn.isDateTime(a))return a.toUTC();let e=typeof a=="string"?kY(a):Tn.fromMillis(a,{zone:"utc"});return e.isValid?e:void 0}n(oD,"castAsDatetime");function BW(a,e){if(a){if(e.isType("date"))return FW(a);if(e.isType(Array.from(m.TEMPORAL_TYPES)))return oD(a)}}n(BW,"castValue");function ws(a){let e;if(a instanceof z&&a.to instanceof m)e=a.to;else if(a instanceof os&&!a.args.format)e=new m({this:"date"});else return;let t,s=a.args.this;if(s instanceof N)t=s.name;else if(s instanceof z||s instanceof os)t=ws(s);else return;return BW(t,e)}n(ws,"extractDate");function qr(a){return ws(a)!==void 0}n(qr,"isDateLiteral");function cD(a){if(a.args.this!==void 0)try{let e=parseInt(String(a.args.this.toValue())),t=a.text("unit").toLowerCase();return uA(t,e)}catch(e){if(e instanceof Ms||e instanceof Error)return;throw e}}n(cD,"extractInterval");function oA(...a){let e;for(let t of a){if(t instanceof z){let s=t.to;e=Y(s,m)||Y(s,be)?s:void 0}else{let s=t.type;e=Y(s,m)||Y(s,be)?s:void 0}if(e)break}return e}n(oA,"extractType");function fs(a,e){let t;!e||!e.isType(Array.from(m.TEMPORAL_TYPES))?t=a.hour===0&&a.minute===0&&a.second===0?"date":"datetime":t=e.args.this;let s=t==="date"?a.toISODate():a.toFormat("yyyy-MM-dd HH:mm:ss");return new z({this:N.string(s),to:new m({this:t})})}n(fs,"dateLiteral");function uA(a,e=1){switch(a.toLowerCase()){case"year":return fn.fromObject({years:e});case"quarter":return fn.fromObject({months:3*e});case"month":return fn.fromObject({months:e});case"week":return fn.fromObject({weeks:e});case"day":return fn.fromObject({days:e});case"hour":return fn.fromObject({hours:e});case"minute":return fn.fromObject({minutes:e});case"second":return fn.fromObject({seconds:e});default:throw new Ms(`Unsupported unit: ${a}`)}}n(uA,"interval");function lA(a,e,t){switch(e.toLowerCase()){case"year":return a.set({month:1,day:1,hour:0,minute:0,second:0,millisecond:0});case"quarter":{let s=Math.floor((a.month-1)/3)*3+1;return a.set({month:s,day:1,hour:0,minute:0,second:0,millisecond:0})}case"month":return a.set({day:1,hour:0,minute:0,second:0,millisecond:0});case"week":return a.startOf("week").plus({days:t._constructor.WEEK_OFFSET||0});case"day":return a;default:throw new Ms(`Unsupported unit: ${e}`)}}n(lA,"dateFloor");function $W(a,e,t){let s=lA(a,e,t);return s.toMillis()===a.toMillis()?a:s.plus(uA(e))}n($W,"dateCeil");function cA(a){return a?We():it()}n(cA,"booleanLiteral");var tY,sY,rY,iY,nY,aY,oY,cY,pY,lY,uY,hY,gY,EY,AY,dY,fY,xY,TY,SY,RY,OY,mY,NY,IY,yY,CY,bY,PY,LY,wY,de;wY=[O],LY=[O],PY=[O],bY=[O],CY=[O],yY=[O],IY=[O],NY=[O],mY=[O],OY=[O],RY=[O],SY=[O],TY=[O],xY=[O],fY=[O],dY=[O],AY=[O],EY=[O],gY=[aA(Ms)],hY=[Js],uY=[Js],lY=[Js,aA(Ms)],pY=[Js,aA(Ms)],cY=[aA(Ms)],oY=[Js],aY=[Js],nY=[aA(Ms)],iY=[Js,aA(Ms)],rY=[Js],sY=[Js],tY=[Js];var G=class G{constructor(e={}){It(de,5,this);this.dialect=void 0;this.annotateNewExpressions=void 0;this._annotator=void 0;let{dialect:t,annotateNewExpressions:s=!0}=e;this.dialect=ae.getOrRaise(t),this.annotateNewExpressions=s,this._annotator=new Yl({schema:NM(void 0,{dialect:this.dialect}),overwriteTypes:!1})}static get SIMPLIFIABLE(){return[U,E,ps,ke,qs]}static get COMPLEMENT_COMPARISONS(){return{[Fe.key]:Je,[je.key]:nt,[nt.key]:je,[Je.key]:Fe,[Me.key]:ft,[ft.key]:Me}}static get COMPLEMENT_SUBQUERY_PREDICATES(){return{[cs.key]:Tt,[Tt.key]:cs}}static get LT_LTE(){return[Fe,nt]}static get GT_GTE(){return[je,Je]}static get COMPARISONS(){return[...G.LT_LTE,...G.GT_GTE,Me,ft,ze]}static get INVERSE_COMPARISONS(){return{[Fe.key]:je,[je.key]:Fe,[nt.key]:Je,[Je.key]:nt}}static get NONDETERMINISTIC(){return[vr,XI]}static get AND_OR(){return[Te,pt]}static get INVERSE_DATE_OPS(){return{[xt.key]:ye,[jt.key]:we,[Ds.key]:ye,[Qs.key]:we}}static get INVERSE_OPS(){return{...G.INVERSE_DATE_OPS,[we.key]:ye,[ye.key]:we}}static get NULL_OK(){return[Ks,Ur,ot]}static get CONCATS(){return[Bt,Wt]}static get DATETRUNC_BINARY_COMPARISONS(){return{[Fe.key]:(e,t,s,r,i)=>{let o=lA(t,s,r),c=t.toMillis()===o.toMillis()?t:o.plus(uA(s));return new Fe({this:e,expression:fs(c,i)})},[je.key]:(e,t,s,r,i)=>{let o=lA(t,s,r);return new Je({this:e,expression:fs(o.plus(uA(s)),i)})},[nt.key]:(e,t,s,r,i)=>{let o=lA(t,s,r);return new Fe({this:e,expression:fs(o.plus(uA(s)),i)})},[Je.key]:(e,t,s,r,i)=>{let o=$W(t,s,r);return new Je({this:e,expression:fs(o,i)})},[Me.key]:UW,[ft.key]:vW}}static get DATETRUNC_COMPARISONS(){return new Set([lt.key,...Object.keys(G.DATETRUNC_BINARY_COMPARISONS)])}static get DATETRUNCS(){return[ls,Sn]}static get SAFE_CONNECTOR_ELIMINATION_RESULT(){return[Ae,at]}static get JOINS(){return[["",""],["","inner"],["right",""],["right","outer"]]}simplify(e,t={}){let{constantPropagation:s=!1,coalesceSimplification:r=!1}=t,i=[],o=[];for(let c of e.walk({prune:n(p=>p instanceof Ce?!0:!!p.meta[xn],"prune")})){if(c.meta[xn])continue;let p=c.getArgKey("group");if(p instanceof d&&c instanceof se){let u=p.args.expressions;if(u){let h=new Set(u.map(x=>x.hash()));p.meta[xn]=!0;let g=c.selects;for(let x of g)for(let T of x.walk({prune:n(y=>!!y.meta[xn],"prune")}))if(h.has(T.hash())){x.meta[xn]=!0;break}let f=c.args.having;if(f){for(let x of f.walk())if(h.has(x.hash())){f.meta[xn]=!0;break}}}}if(c instanceof Ce){let u=TM(c,h=>this._simplify(h,{constantPropagation:s,coalesceSimplification:r}));c===e&&(e=u)}else if(c instanceof St)i.push(c);else if(c instanceof xe){let u=c.args.matchCondition;u&&(u.meta[xn]=!0),o.push(c)}}for(let c of i)as(c.args.this)&&c.pop();for(let c of o){let p=c.args.on,u=c.args.using,h=c.args.method,g=c.args.side||"",f=c.args.kind||"";p&&as(p)&&!u&&!h&&G.JOINS.some(([x,T])=>x===g&&T===f)&&(p.pop(),c.setArgKey("side",void 0),c.setArgKey("kind","cross"))}return e}_simplify(e,t){let{constantPropagation:s,coalesceSimplification:r}=t,i=[e],o=[];for(;0<i.length;){let p=i.pop();if(!p)continue;let u=p;if(!G.SIMPLIFIABLE.some(f=>u instanceof f)){u instanceof ee&&this.simplify(u,{constantPropagation:s,coalesceSimplification:r});continue}let h=u.parent,g=u===e;u=this.rewriteBetween(u),u=this.uniqSort(u,{root:g}),u=this.absorbAndEliminate(u,{root:g}),u=this.simplifyConcat(u),u=this.simplifyConditionals(u),s&&(u=wW(u,{root:g})),u!==p&&p?.replace(u);for(let f of u.iterExpressions({reverse:!0}))f.meta[xn]||i.push(f);o.push([u,h])}let c=e;for(;0<o.length;){let[p,u]=o.pop(),h=p===e;for(let[f,x]of Object.entries(p.args))p?.setArgKey(f,x);let g=this.simplifyNot(p);g=iA(g),g=this.simplifyConnectors(g,{root:h}),g=this.removeComplements(g,{root:h}),r&&(g=this.simplifyCoalesce(g)),g.parent=u,g=this.simplifyLiterals(g,{root:h}),g=this.simplifyEquality(g),g=LW(g,this.dialect),g=this.simplifyDateTrunc(g),g=this.sortComparison(g),g=this.simplifyStartsWith(g),g!==p&&p.replace(g),c=g}return c}absorbAndEliminate(e,t={}){let{root:s=!0}=t;if(G.AND_OR.some(r=>e instanceof r)&&(s||!e.sameParent)){let r=e instanceof Te?pt:Te,i=Array.from(e.flatten()),o=new Set,c=new Map,p=new Map;for(let u of i){let h=this.genSql(u);if(o.add(h),!(u instanceof r)){let T=c.get(h);T||(T=[],c.set(h,T)),T.push(new Set([h]));continue}let g=new Set(Array.from(u.flatten()).map(T=>this.genSql(T)));for(let T of g){let y=c.get(T);y||(y=[],c.set(T,y)),y.push(g)}let[f,x]=u.unnestOperands();if(f&&x){if(f instanceof Le&&f.args.this instanceof d){let T=`${this.genSql(f.args.this)}|${this.genSql(x)}`;p.has(T)||p.set(T,[]),p.get(T).push([u,x])}if(x instanceof Le&&x.args.this instanceof d){let T=`${this.genSql(x.args.this)}|${this.genSql(f)}`;p.has(T)||p.set(T,[]),p.get(T).push([u,f])}}}for(let u of i){if(!(u instanceof r))continue;let[h,g]=u.unnestOperands();if(!h||!g)continue;if(h instanceof Le&&h.args.this instanceof d&&o.has(this.genSql(h.args.this))){h.replace(r===Te?We():it());continue}if(g instanceof Le&&g.args.this instanceof d&&o.has(this.genSql(g.args.this))){g.replace(r===Te?We():it());continue}let f=new Set(Array.from(u.flatten()).map(b=>this.genSql(b)));if(Array.from(f).some(b=>{let k=c.get(b);return k?k.some(B=>{if(f.size<=B.size)return!1;for(let j of B)if(!f.has(j))return!1;return!0}):!1})){u.replace(r===Te?it():We());continue}let T=this.genSql(h),y=this.genSql(g),C=`${T}|${y}`,I=`${y}|${T}`;for(let[b,k]of[...p.get(C)||[],...p.get(I)||[]])u.replace(k),b.replace(k)}}return e}simplifyConcat(e){if(!G.CONCATS.some(u=>e instanceof u))return e;if(e instanceof _t){let[u]=e.args.expressions??[];if(!(u instanceof d)||!u.isString)return e}let t,s,r,i,o;if(e instanceof _t){let[u,...h]=e.args.expressions??[];t=u,s=h,r=t.name,i=_t,o={}}else s=e.args.expressions??[],r="",i=Bt,o={safe:e.args.safe,coalesce:e.args.coalesce};let c=[],p=[];for(let u of 0<s.length?s:Array.from(e.flatten()))u instanceof d&&(u.isString?p.push(u.name):(0<p.length&&(c.push(N.string(p.join(r))),p=[]),c.push(u)));return 0<p.length&&c.push(N.string(p.join(r))),c.length===1&&c[0].isString?c[0]:i===_t&&t?new _t({expressions:[t,...c]}):e instanceof Wt?c.reduce((u,h)=>new Wt({this:u,expression:h})):new i({expressions:c,...o})}simplifyConditionals(e){if(e instanceof ut){let t=e.args.this;for(let s of e.args.ifs||[]){let r=s.args.this;if(t&&(r=r.replace(t.pop().eq(r))),as(r))return s.getArgKey("true");if(RM(r)){s.pop();let i=e.args.ifs;if(!i||i.length===0)return e.args.default||le()}}}else if(e instanceof fe&&!(e.parent instanceof ut)){let t=e.args.this;if(as(t))return ct(e.args.true,d)??e;if(RM(t))return ct(e.args.false,d)??le()}return e}simplifyNot(e){if(e instanceof Le){let t=e.args.this;if(Ht(t))return ve([le(),We()],{copy:!1});if(t instanceof d){let s=G.COMPLEMENT_COMPARISONS[t._constructor.key];if(s){let r=t.args.expression;if(r instanceof d){let i=G.COMPLEMENT_SUBQUERY_PREDICATES[r._constructor.key];i&&(r=new i({this:r.args.this}))}return new s({this:t.args.this,expression:r})}}if(t instanceof Se){let s=t.unnest();if(s instanceof Te)return zs(Vt([ks(s.args.this!==void 0?OM(s.args.this):void 0,{copy:!1}),ks(s.args.expression!==void 0?OM(s.args.expression):void 0,{copy:!1})],{copy:!1}),{copy:!1});if(s instanceof pt)return zs(ve([ks(s.args.this,{copy:!1}),ks(s.args.expression!==void 0?OM(s.args.expression):void 0,{copy:!1})],{copy:!1}),{copy:!1});if(Ht(s))return ve([le(),We()],{copy:!1})}if(as(t))return it();if(pA(t))return We();if(t instanceof Le&&this.dialect._constructor.SAFE_TO_ELIMINATE_DOUBLE_NEGATION){let s=t.args.this;if(Rn(s,"boolean"))return s??e}}return e}simplifyConnectors(e,t={}){let{root:s=!0}=t;if(e instanceof Ae){let r=e.parent;if(e=this.flatSimplify(e,(i,o,c)=>{if(i instanceof Te)return pA(o)||pA(c)?it():mM(o)||mM(c)?it():Ht(o)&&Ht(c)||Ht(o)&&as(c)||as(o)&&Ht(c)?le():as(o)&&as(c)?We():as(o)?c:as(c)?o:this.simplifyComparison(i,o,c,{or:!1});if(i instanceof pt)return as(o)||as(c)?We():Ht(o)&&Ht(c)||Ht(o)&&RM(c)||RM(o)&&Ht(c)?le():pA(o)?c:pA(c)?o:this.simplifyComparison(i,o,c,{or:!0})},{root:s}),!G.SAFE_CONNECTOR_ELIMINATION_RESULT.some(i=>e instanceof i)&&!e.isType("boolean")){let i=r;for(;!(i instanceof Ae);){if(!(i instanceof Se)){e=ve([e,We()],{copy:!1});break}i=i.parent}}}return e}simplifyComparison(e,t,s,r){let{or:i=!1}=r;if(G.COMPARISONS.some(o=>t instanceof o)&&G.COMPARISONS.some(o=>s instanceof o)){let o=t.args.this,c=t.args.expression,p=s.args.this,u=s.args.expression;if(!o||!c||!p||!u)return;let h=[o,c],g=[p,u],f=new Map(h.map(I=>[ct(I,d)?.hash(),I])),x=new Map(g.map(I=>[ct(I,d)?.hash(),I])),T=new Set([...f.keys()].filter(I=>x.has(I))),y=[...T].map(I=>f.get(I)).filter(I=>!jI(I)&&!ct(I,d)?.find(G.NONDETERMINISTIC)),C=new Set(y.map(I=>ct(I,d)?.hash()));if(0<T.size&&0<y.length){let I=h.filter(me=>!C.has(ct(me,d)?.hash())),b=g.filter(me=>!C.has(ct(me,d)?.hash()));if(I.length===0||b.length===0)return e;let k,B;try{k=lD(I),B=lD(b)}catch{return e}if(!(k instanceof d)||!(B instanceof d))return;let j=k,Q=B,ne,H;if(j.isNumber&&Q.isNumber)ne=j.toValue(),H=Q.toValue();else if(j.isString&&Q.isString)ne=j.name,H=Q.name;else{let me=ws(j);if(!me)return;let Ot=ws(Q);if(!Ot)return;ne=oD(me),H=oD(Ot)}let Pe=[[[t,ne],[s,H]],[[s,H],[t,ne]]];for(let[[me,Ot],[gt,Cs]]of Pe){let Xe=typeof Ot=="number"?Ot:Tn.isDateTime(Ot)?Ot.toMillis():String(Ot),mt=typeof Cs=="number"?Cs:Tn.isDateTime(Cs)?Cs.toMillis():String(Cs);if(G.LT_LTE.some(Zt=>me instanceof Zt)&&G.LT_LTE.some(Zt=>gt instanceof Zt))return i?mt<Xe?t:s:Xe<=mt?t:s;if(G.GT_GTE.some(Zt=>me instanceof Zt)&&G.GT_GTE.some(Zt=>gt instanceof Zt))return i?Xe<mt?t:s:mt<=Xe?t:s;if(!i){if(me instanceof Fe&&G.GT_GTE.some(Zt=>gt instanceof Zt)){if(Xe<=mt)return it()}else if(me instanceof je&&G.LT_LTE.some(Zt=>gt instanceof Zt)){if(mt<=Xe)return it()}else if(me instanceof Me){if(gt instanceof Fe)return mt<=Xe?it():me;if(gt instanceof nt)return mt<Xe?it():me;if(gt instanceof je)return Xe<=mt?it():me;if(gt instanceof Je)return Xe<mt?it():me;if(gt instanceof ft)return Xe===mt?it():me}}}}}}flatSimplify(e,t,s){let{root:r}=s;if(!r&&e.sameParent)return e;let i=[],o=Array.from(e.flatten({unnest:!1})),c=o.length;for(;o.length;){let p=o.shift(),u=!1;for(let h of o){let g=t(e,p,h);if(g&&g!==e){o.splice(o.indexOf(h),1),o.unshift(g),u=!0;break}}u||i.push(p)}return i.length<c?i.reduce((p,u)=>new e._constructor({this:p,expression:u})):e}removeComplements(e,t={}){let{root:s=!0}=t;if(G.AND_OR.some(r=>e instanceof r)&&(s||!e.sameParent)){let r=Array.from(e.flatten()),i=new Set(r.map(o=>o.hash()));for(let o of r)if(o instanceof Le){let c=o.args.this;if(c&&i.has(c.hash())&&e.meta.nonnull===!0)return e instanceof Te?it():We()}}return e}simplifyCoalesce(e){if(e instanceof tt&&(e.args.expressions?.length===0||DW(e.args.this))&&!(e.parent instanceof Ps))return e.args.this;if(this.dialect._constructor.COALESCE_COMPARISON_NON_STANDARD||!G.COMPARISONS.some(u=>e instanceof u))return e;let t,s,r=e.args.this,i=e.args.expression;if(r instanceof tt)t=r,s=i;else if(i instanceof tt)t=i,s=r;else return e;if(!jI(s))return e;let o=-1;for(let u=0;u<(t.args.expressions?.length??0);u++){let h=t.args.expressions?.[u];if(jI(h)){o=u;break}}if(o===-1)return e;let c=t.args.expressions?.[o];t.setArgKey("expressions",t.args.expressions?.slice(0,o));let p=0<(t.args.expressions?.length??0)?t:t.args.this;return zs(Vt([ve([ks(p?.is(le()),{copy:!1}),e.copy()],{copy:!1}),ve([p?.is(le()),new e._constructor({this:c.copy(),expression:s.copy()})],{copy:!1})],{copy:!1}),{copy:!1})}simplifyLiterals(e,t={}){let{root:s=!0}=t;if(e instanceof U&&!(e instanceof Ae))return this.flatSimplify(e,(r,i,o)=>this.simplifyBinary(r,i,o),{root:s});if(e instanceof bt&&e.args.this instanceof bt)return e.args.this.args.this??e;if(G.INVERSE_DATE_OPS[e._constructor.key]){let r=e.args.this;if(r instanceof d&&e instanceof Zs)return this.simplifyBinary(e,r,e.interval())||e}return e}simplifyIntegerCast(e){if(!(e instanceof z))return e;let t=e.args.this,s;if(t instanceof z?s=this.simplifyIntegerCast(t):s=t,s instanceof d&&s.isInteger){let r=s.toValue(),i=e.args.to;if(!i)return e;if(i instanceof d&&(G.TINYINT_MIN<=r&&r<=G.TINYINT_MAX&&i.args.this&&m.SIGNED_INTEGER_TYPES.has(i.args.this)||G.UTINYINT_MIN<=r&&r<=G.UTINYINT_MAX&&i.args.this&&m.UNSIGNED_INTEGER_TYPES.has(i.args.this)))return s}return e}simplifyBinary(e,t,s){if(G.COMPARISONS.some(r=>e instanceof r)&&(t=this.simplifyIntegerCast(t),s=this.simplifyIntegerCast(s)),e instanceof ze){let r,i;if(s instanceof Le?(r=s.args.this,i=!0):(r=s,i=!1),Ht(r)){if(t instanceof N)return i?We():it();if(Ht(t))return i?it():We()}}else{if(G.NULL_OK.some(r=>e instanceof r))return;if((Ht(t)||Ht(s))&&e.parent instanceof fe)return le()}if(t.isNumber&&s.isNumber){let r=t.toValue(),i=s.toValue(),o=n(x=>{let T=x.match(/[eE]([+-]?\d+)/),y=T?parseInt(T[1]):0,C=x.replace(/[eE][+-]?\d+/,"").match(/\.(\d+)/),I=C?C[1].length:0;return Math.max(0,I-y)},"decimalPlaces"),c=String(t.args.this??""),p=String(s.args.this??""),u=o(c),h=o(p),g=n((x,T)=>0<T?x.toFixed(T):String(x),"fmt");if(e instanceof we)return N.number(g(r+i,Math.max(u,h)));if(e instanceof xs)return N.number(g(r*i,u+h));if(e instanceof ye)return t.parent===s.parent?N.number(g(r-i,Math.max(u,h))):void 0;if(e instanceof wt){let x=!c.includes(".")&&!c.toLowerCase().includes("e"),T=!p.includes(".")&&!p.toLowerCase().includes("e");return x&&T||t.parent!==s.parent?void 0:N.number(MW(c,p))}let f=nD(e,r,i);if(f)return f}else if(t.isString&&s.isString){let r=t.args.this,i=s.args.this,o=nD(e,r,i);if(o)return o}else if(qr(t)&&s instanceof qe){let r=ws(t),i=cD(s);if(r&&i!==void 0){if(e instanceof we||e instanceof xt||e instanceof Ds)return fs(r.plus(i),oA(t));if(e instanceof ye||e instanceof jt||e instanceof Qs)return fs(r.minus(i),oA(t))}}else if(t instanceof qe&&qr(s)){let r=cD(t),i=ws(s);if(r!==void 0&&i&&e instanceof we)return fs(i.plus(r),oA(s))}else if(qr(t)&&qr(s)&&e instanceof ke){let r=ws(t),i=ws(s);if(r&&i){let o=nD(e,r.toMillis(),i.toMillis());if(o)return o}}}simplifyEquality(e){if(G.COMPARISONS.some(t=>e instanceof t)){let t=e.args.this,s=e.args.expression;if(!(t instanceof d)||!(s instanceof d))return e;let r=G.INVERSE_OPS[t._constructor.key];if(!r)return e;let i,o;if(s.isNumber)i=eY,o=eY;else if(qr(s))i=qr,o=kW;else return e;let c,p;if(G.INVERSE_DATE_OPS[t._constructor.key]?(c=t.args.this,p=t.interval()):(c=t.args.this,p=t.args.expression),!c||!p)return e;if(!(!i(c)&&o(p)))if(!i(p)&&o(c))[c,p]=[p,c];else return e;return new e._constructor({this:c,expression:new r({this:s,expression:p})})}return e}isDatetruncPredicate(e,t){return G.DATETRUNCS.some(s=>e instanceof s)&&qr(t)}simplifyDateTrunc(e){let t=e._constructor;if(G.DATETRUNCS.some(s=>e instanceof s)){let s=e,r=s.args.this,i=r&&oA(r),o=ws(r);if(o&&s.args.unit){let c=s.args.unit.name.toLowerCase();return fs(lA(o,c,this.dialect),i)}}else if(!G.DATETRUNC_COMPARISONS.has(t.key))return e;if(e instanceof U){let s=e.args.this,r=e.args.expression;if(!this.isDatetruncPredicate(s,r))return e;let i=s.args.unit.name.toLowerCase(),o=s.args.this,c=ws(r);return c&&G.DATETRUNC_BINARY_COMPARISONS[t.key]?.(o,c,i,this.dialect,oA(r))||e}if(e instanceof lt){let s=e.args.this,r=e.args.expressions;if(r&&r.every(i=>this.isDatetruncPredicate(s,i))){let i=s.args.unit.name.toLowerCase(),o=[];for(let u of r){let h=ws(u);if(!h)return e;let g=uD(h,i,this.dialect);g&&o.push(g)}if(o.length===0)return e;let c=qW(o),p=oA(...r.filter(u=>u instanceof d));return Vt(c.map(u=>MY(s,u,p)),{copy:!1})}}return e}sortComparison(e){if(Object.values(G.COMPLEMENT_COMPARISONS).some(t=>e instanceof t)){let t=e.args.this,s=e.args.expression,r=t instanceof $,i=s instanceof $,o=jI(t),c=jI(s);if(r&&!i||c&&!o||s instanceof Us)return e;if(i&&!r||o&&!c||aD(s)<aD(t)){let p=G.INVERSE_COMPARISONS[e._constructor.key]||e._constructor;return new p({this:s,expression:t})}}return e}simplifyStartsWith(e){return e instanceof Vl&&e.args.this instanceof d&&e.args.expression instanceof d&&e.args.this.isString&&e.args.expression.isString?e.args.this.name.startsWith(e.args.expression.name)?We():it():e}rewriteBetween(e){if(!(e instanceof Ts))return e;let s=e.parent instanceof Le,r=e.args.this,i=e.args.low,o=e.args.high;if(!(r instanceof d)||!(i instanceof d)||!(o instanceof d))return e;let c=ve([new Je({this:r.copy(),expression:i}),new nt({this:r.copy(),expression:o})],{copy:!1});return s&&(c=zs(c,{copy:!1})),c}uniqSort(e,t={}){let{root:s=!0}=t;if(!(e instanceof Ae)||!s&&e.sameParent)return e;let r=Array.from(e.flatten()),i,o,c;if(e instanceof hA)i=ED,o=void 0,c=r.map(p=>[this.genSql(p),p]);else{i=e instanceof Te?ve:Vt,o=new Map;for(let p of r){let u=this.genSql(p);o.has(u)||o.set(u,p)}c=Array.from(o.entries())}for(let p=1;p<c.length;p++)if(c[p][0]<c[p-1][0]){let u=c.sort((h,g)=>h[0]<g[0]?-1:g[0]<h[0]?1:0);return e=i(u.map(([,h])=>h),{copy:!1}),e}if(o&&o.size<r.length){let p=r[0];o.size===1?p instanceof d&&(e=ve([p,We()],{copy:!1})):e=i(Array.from(o.values()),{copy:!1})}return e}genSql(e){return aD(e)}};de=vt(null),R(de,10,"SIMPLIFIABLE",wY,G),R(de,10,"COMPLEMENT_COMPARISONS",LY,G),R(de,10,"COMPLEMENT_SUBQUERY_PREDICATES",PY,G),R(de,10,"LT_LTE",bY,G),R(de,10,"GT_GTE",CY,G),R(de,10,"COMPARISONS",yY,G),R(de,10,"INVERSE_COMPARISONS",IY,G),R(de,10,"NONDETERMINISTIC",NY,G),R(de,10,"AND_OR",mY,G),R(de,10,"INVERSE_DATE_OPS",OY,G),R(de,10,"INVERSE_OPS",RY,G),R(de,10,"NULL_OK",SY,G),R(de,10,"CONCATS",TY,G),R(de,10,"DATETRUNC_BINARY_COMPARISONS",xY,G),R(de,10,"DATETRUNC_COMPARISONS",fY,G),R(de,10,"DATETRUNCS",dY,G),R(de,10,"SAFE_CONNECTOR_ELIMINATION_RESULT",AY,G),R(de,10,"JOINS",EY,G),R(de,1,"absorbAndEliminate",gY,G),R(de,1,"simplifyConcat",hY,G),R(de,1,"simplifyConditionals",uY,G),R(de,1,"simplifyNot",lY,G),R(de,1,"simplifyConnectors",pY,G),R(de,1,"removeComplements",cY,G),R(de,1,"simplifyCoalesce",oY,G),R(de,1,"simplifyLiterals",aY,G),R(de,1,"simplifyEquality",nY,G),R(de,1,"simplifyDateTrunc",iY,G),R(de,1,"sortComparison",rY,G),R(de,1,"simplifyStartsWith",sY,G),R(de,1,"uniqSort",tY,G),Nt(de,G),It(de,3,G),n(G,"Simplifier"),G.TINYINT_MIN=-128,G.TINYINT_MAX=127,G.UTINYINT_MIN=0,G.UTINYINT_MAX=255;var nA=G;function aD(a,e={}){return new pD().gen(a,e)}n(aD,"gen");var gD=class gD{constructor(){this.stack=[];this.sqls=[]}gen(e,t={}){let{comments:s=!1}=t;for(this.stack=[e],this.sqls=[];0<this.stack.length;){let r=this.stack.pop();if(r instanceof d){s&&r.comments&&0<r.comments.length&&this.stack.push(` /*${r.comments.join(",")}*/`);let i=`${r._constructor.key}Sql`;if(typeof this[i]=="function")this[i].call(this,r);else if(r instanceof E)this.function(r);else{let o=r._constructor.key.toUpperCase();this.stack.push(this.args(r)?`${o} `:o)}}else if(Array.isArray(r)){let i=!1;for(let o=r.length-1;0<=o;o--){let c=r[o];if(c!=null)if(Array.isArray(c)&&typeof c[0]=="string"&&c[0].startsWith(":")){let[p,u]=c;this.stack.push(u),this.stack.push(p),i=!1}else Array.isArray(c)?(this.stack.push(c),this.stack.push(","),i=!0):(this.stack.push(c),this.stack.push(","),i=!0)}i&&this.stack.pop()}else r!=null&&this.sqls.push(String(r))}return this.sqls.join("")}addDql(e){this.binary(e," + ")}aliasSql(e){this.stack.push(e.args.alias," AS ",e.args.this)}andSql(e){this.binary(e," AND ")}anonymousSql(e){let t=e.args.this,s;if(typeof t=="string")s=t.toUpperCase();else if(t instanceof v){let r=t.args.this;s=t.args.quoted?`"${r}"`:String(r).toUpperCase()}else throw new Error(`Anonymous.args.this expects a string or an Identifier, got '${t?._constructor?.name||typeof t}'.`);this.stack.push(")",e.args.expressions||[],"(",s)}betweenSql(e){this.stack.push(e.args.high," AND ",e.args.low," BETWEEN ",e.args.this)}booleanSql(e){this.stack.push(e.args.this?"TRUE":"FALSE")}bracketSql(e){this.stack.push("]",e.args.expressions||[],"[",e.args.this)}columnSql(e){let t=e.parts;for(let s=t.length-1;0<=s;s--)this.stack.push(t[s],".");this.stack.pop()}dataTypeSql(e){this.args(e,1);let t=e.args.this,s=typeof t=="string"?t:String(t);this.stack.push(`${s} `)}divSql(e){this.binary(e," / ")}dotSql(e){this.binary(e,".")}eqSql(e){this.binary(e," = ")}fromSql(e){this.stack.push(e.args.this,"FROM ")}gtSql(e){this.binary(e," > ")}gteSql(e){this.binary(e," >= ")}identifierSql(e){let t=e.args.this,s=String(t);this.stack.push(e.args.quoted?`"${s}"`:s)}iLikeSql(e){this.binary(e," ILIKE ")}inSql(e){this.stack.push(")"),this.args(e,1),this.stack.push("("," IN ",e.args.this)}intdivSql(e){this.binary(e," DIV ")}isSql(e){this.binary(e," IS ")}likeSql(e){this.binary(e," LIKE ")}literalSql(e){let t=e.args.this;this.stack.push(e.isString?`'${t}'`:String(t))}ltSql(e){this.binary(e," < ")}lteSql(e){this.binary(e," <= ")}modSql(e){this.binary(e," % ")}mulSql(e){this.binary(e," * ")}negSql(e){this.unary(e,"-")}neqSql(e){this.binary(e," <> ")}notSql(e){this.unary(e,"NOT ")}nullSql(e){this.stack.push("NULL")}orSql(e){this.binary(e," OR ")}parenSql(e){this.stack.push(")",e.args.this,"(")}subSql(e){this.binary(e," - ")}subquerySql(e){this.args(e,2);let t=e.args.alias;t&&this.stack.push(t),this.stack.push(")",e.args.this,"(")}tableSql(e){this.args(e,4);let t=e.args.alias;t&&this.stack.push(t);let s=e.parts;for(let r=s.length-1;0<=r;r--)this.stack.push(s[r],".");this.stack.pop()}tableAliasSql(e){let t=e.columns;t&&0<t.length&&this.stack.push(")",t,"("),this.stack.push(e.args.this||[]," AS ")}varSql(e){this.stack.push(String(e.args.this))}binary(e,t){this.stack.push(e.args.expression,t,e.args.this)}unary(e,t){this.stack.push(e.args.this,t)}function(e){this.stack.push(")",Object.values(e.args),"(",e._constructor.sqlName())}args(e,t=0){let s=[],r=Array.from(e._constructor.availableArgs||[]),i=0<t?r.slice(t):r;for(let o of i){let c=e.getArgKey(o);c!=null&&s.push([`:${o}`,c])}return 0<s.length?(this.stack.push(s),!0):!1}};n(gD,"Gen");var pD=gD;function fD(a,e,t){let s=GW(e,t,1),r=D(s,0),i=r?` Did you mean ${r}?`:"";throw new Error(`Unknown ${a} '${e}'.${i}`)}n(fD,"suggestClosestMatchAndFail");function D(a,e){if(Array.isArray(a)){let r=e<0?a.length+e:e;return 0<=r&&r<a.length?a[r]:void 0}let t=[...a],s=e<0?t.length+e:e;return 0<=s&&s<t.length?t[s]:void 0}n(D,"seqGet");function OM(a){return typeof a=="boolean"||typeof a=="number"?String(a):a}n(OM,"expressionValueToOrString");function J(a){return a===void 0?[]:a instanceof d?[a]:typeof a!="string"&&$I(a)?[...a]:[a]}n(J,"ensureList");function JI(a,e={}){let{sep:t=", "}=e,s=[];for(let r of a)r&&s.push(r);return s.join(t??", ")}n(JI,"csv");function GW(a,e,t,s=.6){let r=[];for(let i of e){let o=YW(a,i);s<=o&&r.push({match:i,ratio:o})}return r.sort((i,o)=>o.ratio-i.ratio),r.slice(0,t).map(i=>i.match)}n(GW,"getCloseMatches");function YW(a,e){let t=e.length<a.length?a:e,s=e.length<a.length?e:a;if(t.length===0)return 1;let r=VW(s,t);return(t.length-r)/t.length}n(YW,"similarity");function VW(a,e){let t=[];for(let s=0;s<=e.length;s++)t[s]=[s];for(let s=0;s<=a.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let r=1;r<=a.length;r++)e.charAt(s-1)===a.charAt(r-1)?t[s][r]=t[s-1][r-1]:t[s][r]=Math.min(t[s-1][r-1]+1,t[s][r-1]+1,t[s-1][r]+1);return t[e.length][a.length]}n(VW,"levenshteinDistance");function yM(a){return a.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}n(yM,"snakeToCamelCase");function TM(a,e){let t=a;for(;;){let s=DY(t);t=e(t);let r=DY(t);if(s===r)break}return t}n(TM,"whileChanging");function DY(a){return a instanceof d?a.sql():JSON.stringify(a)}n(DY,"hashObject");function vY(a){let e=[],t=new Map(a);for(let[s,r]of Array.from(a.entries()))for(let i of Array.from(r))t.has(i)||t.set(i,new Set);for(;0<t.size;){let s=new Set;for(let[r,i]of Array.from(t.entries()))i.size===0&&s.add(r);if(s.size===0)throw new Error("Cycle error");for(let r of Array.from(s))t.delete(r);for(let r of Array.from(t.values()))for(let i of Array.from(s))r.delete(i);e.push(...Array.from(s).sort())}return e}n(vY,"tsort");function En(a,e){let t=new Set(a);if(!t.has(e))return e;let s=2,r=`${e}_${s}`;for(;t.has(r);)s++,r=`${e}_${s}`;return r}n(En,"findNewName");function FY(a){return a?HW(a,e=>{let t=Number(e);return Number.isInteger(t)}):!1}n(FY,"isInt");function HW(a,e){try{return e(a)}catch{return!1}}n(HW,"isType");function CM(a){let e=0;return()=>`${a}${e++}`}n(CM,"nameSequence");function BY(a,e,t,s={}){let{fillFromStart:r=!0}=s,i=a.split(e),o=Math.max(0,t-i.length);return r?[...Array(o).fill(void 0),...i]:[...i,...Array(o).fill(void 0)]}n(BY,"splitNumWords");function gA(a){try{if(typeof a!="object"||a===null||a.constructor!==Object)return 0;let e=Object.values(a);return e.length===0?1:1+gA(e[0])}catch{return 0}}n(gA,"objectDepth");function lD(a){for(let e of a)return e;throw new Error("Iterable is empty")}n(lD,"first");function $Y(a){if(typeof a=="boolean"||a===void 0)return a;let e=a.toLowerCase();return e==="true"||e==="1"?!0:e==="false"||e==="0"?!1:a}n($Y,"toBool");function EA(a){return UY.fromISO(a).isValid&&/^\d{4}-\d{2}-\d{2}$/.test(a)}n(EA,"isIsoDate");function zI(a){return UY.fromSQL(a).isValid}n(zI,"isIsoDatetime");var _W=new Set(["day","week","month","quarter","year","year_month"]);function AA(a){return a!==void 0&&_W.has(a.name.toLowerCase())}n(AA,"isDateUnit");var xD=class xD{constructor(e,t){this._keys=new Set(e),this._value=t}get(e){return this._keys.has(e)?this._value:void 0}has(e){return this._keys.has(e)}get size(){return this._keys.size}*[Symbol.iterator](){for(let e of Array.from(this._keys))yield[e,this._value]}*entries(){for(let e of Array.from(this._keys))yield[e,this._value]}keys(){return this._keys.values()}*values(){for(let e of Array.from(this._keys))yield this._value}forEach(e,t){for(let s of Array.from(this._keys))e.call(t,this._value,s,this)}clear(){throw new Error("Method not supported")}delete(e){throw new Error("Method not supported")}set(e,t){throw new Error("Method not supported")}get[Symbol.toStringTag](){return"SingleValuedMapping"}};n(xD,"SingleValuedMapping");var qY=xD;function dA(a,e,t,s){let r=[...e];if(!t||r.length!==1)return r;let i=r[0];a.type||Kt(a,{dialect:s?.dialect});let o=a.type;if(o?.args.this!=="unknown"&&o?.args.this!=="array")return r;i.type||Kt(i,{dialect:s?.dialect});let c=i.type;if(c?.args.this&&m.INTEGER_TYPES?.has(c.args.this)){console.info(`Applying array index offset (${t})`);let p=new we({this:i,expression:Hl(t)});return[IM(p)]}return r}n(dA,"applyIndexOffset");function GY(a,e){return a instanceof d?e==="name"?a.name:e==="sql"?a.sql():e(a):a}n(GY,"mapOnExpression");function bM(a){return a.replace(/([A-Z])/g,"_$1").toUpperCase()}n(bM,"camelToScreamingSnakeCase");var WW=new Set(["EPOCH_SECOND","EPOCH_MILLISECOND","EPOCH_MICROSECOND","EPOCH_NANOSECOND","NANOSECOND"]);function Kt(a,e={}){let{schema:t,expressionMetadata:s,coercesTo:r,dialect:i,overwriteTypes:o=!0}=e,c=NM(t,{dialect:i});return new Yl({schema:c,expressionMetadata:s,coercesTo:r,overwriteTypes:o}).annotate(a)}n(Kt,"annotateTypes");function YY(a,e){let t=a.name,s=EA(t);return s&&AA(e)?"date":s||zI(t)?"datetime":"unknown"}n(YY,"coerceDateLiteral");function VY(a,e){if(!AA(e))return"datetime";let t=a.type?.args.this;return typeof t=="string"?t:t instanceof v?t.args.this:"unknown"}n(VY,"coerceDate");function jW(a){return(e,t)=>a(t,e)}n(jW,"swapArgs");function XW(a){let e=new KE;for(let[[t,s],r]of a)e.set(t,s,r),e.set(s,t,jW(r));return e}n(XW,"swapAll");var HY,_Y,WY,QI;WY=[O],_Y=[O],HY=[O];var er=class er{constructor(e){this.schema=void 0;this.dialect=void 0;this.overwriteTypes=void 0;this.expressionMetadata=void 0;this.coercesTo=void 0;this.binaryCoercions=void 0;this.visited=void 0;this.nullExpressions=void 0;this.supportsNullType=void 0;this.setopColumnTypes=void 0;this.scopeSelects=void 0;let{schema:t,expressionMetadata:s,coercesTo:r,binaryCoercions:i,overwriteTypes:o=!0}=e;if(this.schema=t,this.dialect=t.dialect||new ae,this.overwriteTypes=o,this.expressionMetadata=s??this.dialect._constructor.EXPRESSION_METADATA,r)this.coercesTo=r;else{let c=this.dialect._constructor.COERCES_TO;c instanceof Map&&0<c.size?this.coercesTo=c:!(c instanceof Map)&&0<Object.keys(c).length?this.coercesTo=new Map(Object.entries(c).map(([p,u])=>[p,new Set(u)])):this.coercesTo=er.COERCES_TO}this.binaryCoercions=i??er.BINARY_COERCIONS,this.visited=new Set,this.nullExpressions=new Map,this.supportsNullType=this.dialect._constructor.SUPPORTS_NULL_TYPE,this.setopColumnTypes=new Map,this.scopeSelects=new Map}static get NESTED_TYPES(){return new Set(["array"])}static get COERCES_TO(){let e=new Map,t=["text","nvarchar","varchar","nchar","char"],s=["decfloat","double","float","bigdecimal","decimal","bigint","int","smallint","tinyint"],r=["timestampltz","timestamptz","timestamp","datetime","date"];for(let i of[t,s,r]){let o=new Set;for(let c of i)e.set(c,new Set(o)),o.add(c)}return e}static get BINARY_COERCIONS(){return XW((()=>{let e=new KE;for(let t of m.TEXT_TYPES)e.set(t,"interval",(s,r)=>YY(s,r.unit));for(let t of m.TEXT_TYPES)for(let s of m.NUMERIC_TYPES)e.set(t,s,(r,i)=>{let o=r.type?.args.this;return m.NUMERIC_TYPES.has(o)?o:i.type?.args.this});return e.set("date","interval",(t,s)=>VY(t,s.unit)),e})())}clear(){this.visited.clear(),this.nullExpressions.clear(),this.setopColumnTypes.clear(),this.scopeSelects.clear()}annotate(e,t={}){let{annotateScope:s=!0}=t;if(s)for(let i of sA(e))this.annotateScope(i);this.annotateExpression(e);let r=this.dialect._constructor.DEFAULT_NULL_TYPE;for(let[,i]of this.nullExpressions)i.type=r;return e}annotateScope(e){if(this.schema instanceof ZI)for(let t of e.tableColumns){let s=e.sources.get(t.name);if(s instanceof _){let r=this.schema.find(s,{raiseOnMissing:!1,ensureDataTypes:!0});if(typeof r!="object"||!r)continue;let i=new m({this:"struct",expressions:Object.entries(r).map(([o,c])=>new be({this:K(o),kind:c})),nested:!0});this.setType(t,i)}else s instanceof js&&s.expression instanceof ee&&(s.expression.meta.queryType||m.build("unknown")).isType("struct")&&this.setType(t,s.expression.meta.queryType)}if(this.annotateExpression(e.expression,e),this.fixupOrderByAliases(e),this.dialect._constructor.QUERY_RESULTS_ARE_STRUCTS&&e.expression instanceof ee){let t=new m({this:"struct",expressions:e.expression.selects.map(s=>new be({this:K(s.outputName),kind:s.type instanceof d?s.type.name:s.type||""})),nested:!0});t.args.expressions?.some(s=>{let r=s.args.kind;return r?typeof r=="string"?r==="unknown":r.isType("unknown"):!0})||(e.expression.meta.queryType=t)}}getScopeSelects(e){let t=this.scopeSelects.get(e);if(t!==void 0)return t;let s=new Map;for(let[r,i]of e.sources){if(!(i instanceof js))continue;let o=i.expression;if(o instanceof yt&&!(o instanceof _l)){let c=[];if(o instanceof Ct){let u=o.args.this;u instanceof Xt&&(c=[u.args.this])}else if(o instanceof Ee)c=[o];else{let u=D(o.args.expressions??[],0);u&&(c=u instanceof d?u.args.expressions:[])}if(c.length===0)continue;let p=o.aliasColumnNames;if(o instanceof Ee&&o.type instanceof d&&o.type.isType("struct")){let u={};for(let h of o.type.args.expressions||[]){let g=h.name,f=h.args.kind;g&&(u[g]=f)}s.set(r,u)}else{let u={};for(let h=0;h<p.length&&h<c.length;h++){let g=c[h].type;u[p[h]]=Y(g,m)||Y(g,be)?g:void 0}s.set(r,u)}}else if(o instanceof Ge&&Y(o.left,ee)&&Y(o.right,ee)&&o.left.selects.length===o.right.selects.length)s.set(r,this.getSetopColumnTypes(o));else{let c={};for(let p of o.selects){let u=p.type;c[p.aliasOrName]=Y(u,m)||Y(u,be)?u:void 0}s.set(r,c)}}return this.scopeSelects.set(e,s),s}getSetopColumnTypes(e){let t=this.setopColumnTypes.get(e);if(t!==void 0)return t;let s={},r=e.left,i=e.right;if(!Y(r,ee)||!Y(i,ee)||!r.selects.length||!i.selects.length||r.selects.length!==i.selects.length)return s;for(let o of e.walk({prune:n(c=>!(c instanceof Ge)&&!(c instanceof he),"prune")})){if(!(o instanceof Ge))continue;let c,p=o.left,u=o.right;if(re(p,ee),re(u,ee),o.args.byName){let h={};for(let g of u.selects){let f=g.type;h[g.aliasOrName]=Y(f,m)||Y(f,be)?f:void 0}c={};for(let g of p.selects){let f=g.type,x=(Y(f,m)?f:void 0)??"unknown",T=h[g.aliasOrName]??"unknown";c[g.aliasOrName]=this.maybeCoerce(x,T)}}else{c={};for(let h=0;h<p.selects.length;h++){let g=p.selects[h],f=u.selects[h],x=g.type,T=f.type,y=(Y(x,m)?x:void 0)??"unknown",C=(Y(T,m)?T:void 0)??"unknown";c[g.aliasOrName]=this.maybeCoerce(y,C)}}for(let[h,g]of Object.entries(c)){let f=s[h]??"null";s[h]=this.maybeCoerce(g,f)}}return this.setopColumnTypes.set(e,s),s}annotateExpression(e,t){let s=[[e,!1]];for(;0<s.length;){let[r,i]=s.pop();if(this.visited.has(r)||!this.overwriteTypes&&r.type&&!r.isType("unknown"))continue;if(!i){s.push([r,!0]);for(let c of r.iterExpressions())s.push([c,!1]);continue}if(t&&r instanceof $&&r.args.table){let c,p=t;for(;p&&!c;)c=p.sources.get(r.table),c||(p=p.parent);if(c instanceof _)this.setType(r,this.schema.getColumnType?.(c,r));else if(c){let u=p?this.getScopeSelects(p).get(r.table)?.[r.name]:void 0;if(u)this.setType(r,u);else if(c.expression instanceof Ee){let h=c.expression.type;this.setType(r,Y(h,m)?h:void 0)}else this.setType(r,"unknown")}else this.setType(r,"unknown");r.type?.getArgKey("nullable")===!1&&(r.meta.nonnull=!0);continue}let o=this.expressionMetadata.get(r._constructor);if(o){if(o.annotator){o.annotator(this,r);continue}if(o.returns!==void 0){this.setType(r,o.returns);continue}}if(r instanceof Lt){this.annotateBracket(r);continue}if(r instanceof U){this.annotateBinary(r);continue}if(r instanceof qs){this.annotateUnary(r);continue}r instanceof z||r instanceof $t||this.setType(r,"unknown")}}fixupOrderByAliases(e){let t=e.expression;if(!(t instanceof ee))return;let s=t.getArgKey("order");if(!s)return;let r=new Map;for(let i of t.selects)i instanceof Re&&i.args.this instanceof d&&i.args.this.type&&!Rn(i.args.this,"unknown")&&r.set(i.alias,i.args.this.type);if(r.size)for(let i of s.args.expressions??[]){let o=[...i.findAll($)].filter(c=>!c.table&&r.has(c.name));for(let c of o)this.setType(c,r.get(c.name));if(o.length){for(let c of i.walk({prune:n(p=>p instanceof he,"prune")}))!(c instanceof $)&&!(c instanceof N)&&this.visited.delete(c);this.annotateExpression(i,e)}}}maybeCoerce(e,t){let s;if(e instanceof m){if(e.args.expressions&&0<e.args.expressions.length)return e;s=e.args.this}else s=e??"unknown";let r;if(t instanceof m){if(t.args.expressions&&0<t.args.expressions.length)return t;r=t.args.this}else r=t??"unknown";return s==="unknown"||r==="unknown"?"unknown":s==="null"?r:r==="null"?s:this.coercesTo.get(s)?.has(r)?r:s}setType(e,t){let s=e.type;if(e.type=t??"unknown",this.visited.add(e),!this.supportsNullType&&e.type?.args.this==="null"?this.nullExpressions.set(e,e):s?.isType("null")&&this.nullExpressions.delete(e),e instanceof $&&e.isType("json")&&e.meta.dotParts){let i=e.meta.dotParts[Symbol.iterator](),o=e.parent;for(;o instanceof ge;){let c=i.next();c.done||o.setArgKey("expression",K(c.value,{quoted:!0})),o=o.parent}delete e.meta.dotParts}return e}annotateBinary(e){let t=e.left,s=e.right;if(!t||!s){this.setType(e);return}let r=t.type?.args.this?.toString(),i=s.type?.args.this?.toString();if(e instanceof Ae||e instanceof ke)this.setType(e,"boolean");else{let o=this.binaryCoercions.get(r,i);o?this.setType(e,o(t,s)):this.annotateByArgs(e,[t,s])}(e instanceof ze||t.meta.nonnull===!0&&s.meta.nonnull===!0)&&(e.meta.nonnull=!0)}annotateUnary(e){if(e instanceof Le)this.setType(e,"boolean");else{let r=e.args.this?.type;this.setType(e,r)}e.args.this?.meta.nonnull===!0&&(e.meta.nonnull=!0)}annotateLiteral(e){e.args.isString?this.setType(e,"varchar"):e.isInteger?this.setType(e,"int"):this.setType(e,"double"),e.meta.nonnull=!0}annotateByArgs(e,t,s={}){let{promote:r=!1,array:i=!1}=s,o,c,p;e:for(let h of t){let g;if(typeof h=="string"){let f=e.args[h];g=J(f)}else Array.isArray(h)?g=h:g=[h];for(let f of g){if(!(f instanceof d))continue;let x=f.type;if(!x)continue;let T=Y(x,m)||Y(x,be)?x:void 0;if(T){if(T.getArgKey("nested")){p=T;break e}f instanceof N?o=this.maybeCoerce(o??T,T):c=this.maybeCoerce(c??T,T)}}}let u;if(p)u=p;else if(o!==void 0&&c!==void 0){if(this.dialect._constructor.PRIORITIZE_NON_LITERAL_TYPES){let h=o instanceof m?o.args.this:o,g=c instanceof m?c.args.this:c;(m.INTEGER_TYPES.has(h)&&m.INTEGER_TYPES.has(g)||m.REAL_TYPES.has(h)&&m.REAL_TYPES.has(g))&&(u=c)}}else u=o??c??"unknown";if(this.setType(e,u??this.maybeCoerce(c??void 0,o??void 0)),r){let h=e.type?.args.this;m.INTEGER_TYPES.has(h)?this.setType(e,"bigint"):m.FLOAT_TYPES.has(h)&&this.setType(e,"double")}if(i){let h=e.type?.copy()??new m({this:"unknown"});this.setType(e,new m({this:"array",expressions:[h],nested:!0}))}}annotateTimeunit(e){let t=e.args.this;if(!t?.type){this.setType(e,"unknown");return}let s=t.type.args.this,r;if(m.TEXT_TYPES.has(s)){let i=e.unit;r=YY(t,i)}else if(m.TEMPORAL_TYPES.has(s)){let i=e.unit;r=VY(t,i)}else r="unknown";this.setType(e,r)}annotateBracket(e){let t=D(e.args.expressions??[],0),s=e.args.this;if(t instanceof On){let r=s.type;this.setType(e,Y(r,m)?r:void 0)}else if(s.type?.isType("array")){let r=D(s.type.args.expressions??[],0);this.setType(e,r)}else if(s instanceof mn||s instanceof Ss){let r=s.keys;if(t){let i=r.findIndex(o=>o instanceof d&&o.equals(t));if(0<=i){let o=s.values,c=D(o,i),p=c instanceof d?c.type:void 0;this.setType(e,Y(p,m)?p:void 0)}else this.setType(e,"unknown")}else this.setType(e,"unknown")}else this.setType(e,"unknown")}annotateDiv(e){let t=e.left,s=e.right,r=t?.type?.args.this,i=s?.type?.args.this;if(e.args.typed&&m.INTEGER_TYPES.has(r)&&m.INTEGER_TYPES.has(i))this.setType(e,"bigint");else{this.setType(e,this.maybeCoerce(r,i));let o=e.type?.args.this;if(!m.REAL_TYPES.has(o)){let c=e.type;this.setType(e,this.maybeCoerce(Y(c,m)?c:void 0,"double"))}}}annotateDot(e){this.setType(e);let t=e.args.expression;if(t instanceof Qe){let r=t.type;this.setType(e,Y(r,m)?r:void 0);return}let s=e.args.this?.type;if(Rn(s,"struct")){for(let r of s?.args.expressions||[])if(r.name===t?.name){let i=r.args.kind;this.setType(e,i);break}}}annotateExtract(e){let t=e.name?.toUpperCase();t==="TIME"?this.setType(e,"time"):t==="DATE"?this.setType(e,"date"):t&&WW.has(t)?this.setType(e,"bigint"):this.setType(e,"int")}annotateExplode(e){let t=e.args.this,s=D(t?.type?.args.expressions??[],0);this.setType(e,s)}annotateUnnest(e){let t=D(e.args.expressions??[],0),s;t instanceof d&&t.isType("array")&&(s=D(t.type?.args.expressions??[],0)),this.setType(e,s)}annotateSubquery(e){let t=e.unnest();if(t instanceof ee){let s=t.selects;if(s.length===1){let r=s[0].type;this.setType(e,Y(r,m)||Y(r,be)?r:void 0);return}}this.setType(e,"unknown")}annotateStructValue(e){let t,s=e.type,r=Y(s,m)||Y(s,be)?s:void 0,i=e.args.alias;if(i instanceof d)t=i.copy();else if(e.args.expression instanceof d){t=e.args.this?.copy();let o=e.args.expression?.type;r=Y(o,m)||Y(o,be)?o:void 0}else e instanceof $&&(t=e.args.this?.copy());if(!(Y(r,m)&&r.isType("unknown")))return t?new be({this:t,kind:r}):r??"unknown"}annotateStruct(e){let t=[];for(let s of e.args.expressions){let r=this.annotateStructValue(s);if(r===void 0){this.setType(e);return}t.push(r)}this.setType(e,new m({this:"struct",expressions:t,nested:!0}))}annotateMap(e){let t,s;if(e instanceof Ss)t=e.args.keys,s=e.args.values;else{let i=e.args.keys,o=e.args.values;t=i?.[0]instanceof ue?i[0]:void 0,s=o?.[0]instanceof ue?o[0]:void 0}let r=new m({this:"map"});if(t instanceof ue&&s instanceof ue){let i=D(t.type?.args.expressions??[],0),o=D(s.type?.args.expressions??[],0),c=i instanceof m?i.args.this:i,p=o instanceof m?o.args.this:o;c!=="unknown"&&p!=="unknown"&&(r.setArgKey("expressions",[i??new m({this:"unknown"}),o??new m({this:"unknown"})]),r.setArgKey("nested",!0))}this.setType(e,r)}annotateToMap(e){let t=new m({this:"map"}),s=e.args.this;if(s?.isType("struct")&&s.type instanceof d)for(let r of s.type.args.expressions||[]){let i=r.args.kind,o=i instanceof m?i.args.this:i;if(o!=="unknown"){let c=m.build("varchar");t.setArgKey("expressions",[...c?[c]:[],i instanceof m?i:new m({this:o??"unknown"})]),t.args.nested=!0;break}}this.setType(e,t)}annotateByArrayElement(e){let t=e.args.this;if(t?.type?.isType("array")){let s=D(t.type.args.expressions??[],0);this.setType(e,s??"unknown")}else this.setType(e,"unknown")}};QI=vt(null),R(QI,10,"NESTED_TYPES",WY,er),R(QI,10,"COERCES_TO",_Y,er),R(QI,10,"BINARY_COERCIONS",HY,er),Nt(QI,er),It(QI,3,er),n(er,"TypeAnnotator");var Yl=er;function Gt(a,e){let t=e??{};for(let s of a){let r=t;for(let i of s)r[i]||(r[i]={}),r=r[i];r["\0"]=!0}return t}n(Gt,"newTrie");function Nn(a,e){let t=Array.from(e);if(!t.length)return[0,a];let s=a;for(let r of t){if(!s[r])return[0,s];s=s[r]}return s["\0"]?[2,s]:[1,s]}n(Nn,"inTrie");var PM=(A=>(A.L_PAREN="lParen",A.R_PAREN="rParen",A.L_BRACKET="lBracket",A.R_BRACKET="rBracket",A.L_BRACE="lBrace",A.R_BRACE="rBrace",A.COMMA="comma",A.DOT="dot",A.DASH="dash",A.PLUS="plus",A.COLON="colon",A.DOTCOLON="dotcolon",A.DOTCARET="dotcaret",A.DCOLON="dcolon",A.DCOLONDOLLAR="dcolondollar",A.DCOLONPERCENT="dcolonpercent",A.DCOLONQMARK="dcolonqmark",A.DQMARK="dqmark",A.SEMICOLON="semicolon",A.STAR="star",A.BACKSLASH="backslash",A.SLASH="slash",A.LT="lt",A.LTE="lte",A.GT="gt",A.GTE="gte",A.NOT="not",A.EQ="eq",A.NEQ="neq",A.NULLSAFE_EQ="nullsafeEq",A.COLON_EQ="colonEq",A.COLON_GT="colonGt",A.NCOLON_GT="ncolonGt",A.AND="and",A.OR="or",A.AMP="amp",A.DPIPE="dpipe",A.PIPE_GT="pipeGt",A.PIPE="pipe",A.PIPE_SLASH="pipeSlash",A.DPIPE_SLASH="dpipeSlash",A.CARET="caret",A.CARET_AT="caretAt",A.TILDE="tilde",A.ARROW="arrow",A.DARROW="darrow",A.FARROW="farrow",A.HASH="hash",A.HASH_ARROW="hashArrow",A.DHASH_ARROW="dhashArrow",A.LR_ARROW="lrArrow",A.DAT="dat",A.LT_AT="ltAt",A.AT_GT="atGt",A.DOLLAR="dollar",A.PARAMETER="parameter",A.SESSION="session",A.SESSION_PARAMETER="sessionParameter",A.SESSION_USER="sessionUser",A.DAMP="damp",A.AMP_LT="ampLt",A.AMP_GT="ampGt",A.ADJACENT="adjacent",A.XOR="xor",A.DSTAR="dstar",A.QMARK_AMP="qmarkAmp",A.QMARK_PIPE="qmarkPipe",A.HASH_DASH="hashDash",A.EXCLAMATION="exclamation",A.URI_START="uriStart",A.BLOCK_START="blockStart",A.BLOCK_END="blockEnd",A.SPACE="space",A.BREAK="break",A.STRING="string",A.NUMBER="number",A.IDENTIFIER="identifier",A.DATABASE="database",A.COLUMN="column",A.COLUMN_DEF="columnDef",A.SCHEMA="schema",A.TABLE="table",A.WAREHOUSE="warehouse",A.STAGE="stage",A.STREAM="stream",A.STREAMLIT="streamlit",A.VAR="var",A.BIT_STRING="bitString",A.HEX_STRING="hexString",A.BYTE_STRING="byteString",A.NATIONAL_STRING="nationalString",A.RAW_STRING="rawString",A.HEREDOC_STRING="heredocString",A.UNICODE_STRING="unicodeString",A.BIT="bit",A.BOOLEAN="boolean",A.TINYINT="tinyint",A.UTINYINT="utinyint",A.SMALLINT="smallint",A.USMALLINT="usmallint",A.MEDIUMINT="mediumint",A.UMEDIUMINT="umediumint",A.INT="int",A.UINT="uint",A.BIGINT="bigint",A.UBIGINT="ubigint",A.BIGNUM="bignum",A.INT128="int128",A.UINT128="uint128",A.INT256="int256",A.UINT256="uint256",A.FLOAT="float",A.DOUBLE="double",A.UDOUBLE="udouble",A.DECIMAL="decimal",A.DECIMAL32="decimal32",A.DECIMAL64="decimal64",A.DECIMAL128="decimal128",A.DECIMAL256="decimal256",A.DECFLOAT="decfloat",A.UDECIMAL="udecimal",A.BIGDECIMAL="bigdecimal",A.CHAR="char",A.NCHAR="nchar",A.VARCHAR="varchar",A.NVARCHAR="nvarchar",A.BPCHAR="bpchar",A.TEXT="text",A.MEDIUMTEXT="mediumtext",A.LONGTEXT="longtext",A.BLOB="blob",A.MEDIUMBLOB="mediumblob",A.LONGBLOB="longblob",A.TINYBLOB="tinyblob",A.TINYTEXT="tinytext",A.NAME="name",A.BINARY="binary",A.VARBINARY="varbinary",A.JSON="json",A.JSONB="jsonb",A.TIME="time",A.TIMETZ="timetz",A.TIME_NS="timeNs",A.TIMESTAMP="timestamp",A.TIMESTAMPTZ="timestamptz",A.TIMESTAMPLTZ="timestampltz",A.TIMESTAMPNTZ="timestampntz",A.TIMESTAMP_S="timestampS",A.TIMESTAMP_MS="timestampMs",A.TIMESTAMP_NS="timestampNs",A.DATETIME="datetime",A.DATETIME2="datetime2",A.DATETIME64="datetime64",A.SMALLDATETIME="smalldatetime",A.DATE="date",A.DATE32="date32",A.INT4RANGE="int4range",A.INT4MULTIRANGE="int4multirange",A.INT8RANGE="int8range",A.INT8MULTIRANGE="int8multirange",A.NUMRANGE="numrange",A.NUMMULTIRANGE="nummultirange",A.TSRANGE="tsrange",A.TSMULTIRANGE="tsmultirange",A.TSTZRANGE="tstzrange",A.TSTZMULTIRANGE="tstzmultirange",A.DATERANGE="daterange",A.DATEMULTIRANGE="datemultirange",A.UUID="uuid",A.GEOGRAPHY="geography",A.GEOGRAPHYPOINT="geographypoint",A.NULLABLE="nullable",A.GEOMETRY="geometry",A.POINT="point",A.RING="ring",A.LINESTRING="linestring",A.LOCALTIME="localtime",A.LOCALTIMESTAMP="localtimestamp",A.SYSTIMESTAMP="systimestamp",A.MULTILINESTRING="multilinestring",A.POLYGON="polygon",A.MULTIPOLYGON="multipolygon",A.HLLSKETCH="hllsketch",A.HSTORE="hstore",A.SUPER="super",A.SERIAL="serial",A.SMALLSERIAL="smallserial",A.BIGSERIAL="bigserial",A.XML="xml",A.YEAR="year",A.USERDEFINED="userdefined",A.MONEY="money",A.SMALLMONEY="smallmoney",A.ROWVERSION="rowversion",A.IMAGE="image",A.VARIANT="variant",A.OBJECT="object",A.INET="inet",A.IPADDRESS="ipaddress",A.IPPREFIX="ipprefix",A.IPV4="ipv4",A.IPV6="ipv6",A.ENUM="enum",A.ENUM8="enum8",A.ENUM16="enum16",A.FIXEDSTRING="fixedstring",A.LOWCARDINALITY="lowcardinality",A.NESTED="nested",A.AGGREGATEFUNCTION="aggregatefunction",A.SIMPLEAGGREGATEFUNCTION="simpleaggregatefunction",A.TDIGEST="tdigest",A.UNKNOWN="unknown",A.VECTOR="vector",A.DYNAMIC="dynamic",A.VOID="void",A.ALIAS="alias",A.ALTER="alter",A.ALL="all",A.ANTI="anti",A.ANY="any",A.APPLY="apply",A.ARRAY="array",A.ASC="asc",A.ASOF="asof",A.ATTACH="attach",A.AUTO_INCREMENT="autoIncrement",A.BEGIN="begin",A.BETWEEN="between",A.BULK_COLLECT_INTO="bulkCollectInto",A.CACHE="cache",A.CASE="case",A.CHARACTER_SET="characterSet",A.CLUSTER_BY="clusterBy",A.COLLATE="collate",A.COMMAND="command",A.COMMENT="comment",A.COMMIT="commit",A.CONNECT_BY="connectBy",A.CONSTRAINT="constraint",A.COPY="copy",A.CREATE="create",A.CROSS="cross",A.CUBE="cube",A.CURRENT_DATE="currentDate",A.CURRENT_DATETIME="currentDatetime",A.CURRENT_SCHEMA="currentSchema",A.CURRENT_TIME="currentTime",A.CURRENT_TIMESTAMP="currentTimestamp",A.CURRENT_USER="currentUser",A.CURRENT_ROLE="currentRole",A.CURRENT_CATALOG="currentCatalog",A.DECLARE="declare",A.DEFAULT="default",A.DELETE="delete",A.DESC="desc",A.DESCRIBE="describe",A.DETACH="detach",A.DICTIONARY="dictionary",A.DISTINCT="distinct",A.DISTRIBUTE_BY="distributeBy",A.DIV="div",A.DROP="drop",A.ELSE="else",A.END="end",A.ESCAPE="escape",A.EXCEPT="except",A.EXECUTE="execute",A.EXISTS="exists",A.FALSE="false",A.FETCH="fetch",A.FILE="file",A.FILE_FORMAT="fileFormat",A.FILTER="filter",A.FINAL="final",A.FIRST="first",A.FOR="for",A.FORCE="force",A.FOREIGN_KEY="foreignKey",A.FORMAT="format",A.FROM="from",A.FULL="full",A.FUNCTION="function",A.GET="get",A.GLOB="glob",A.GLOBAL="global",A.GRANT="grant",A.GROUP_BY="groupBy",A.GROUPING_SETS="groupingSets",A.HAVING="having",A.HINT="hint",A.IGNORE="ignore",A.ILIKE="ilike",A.IN="in",A.INDEX="index",A.INDEXED_BY="indexedBy",A.INNER="inner",A.INSERT="insert",A.INSTALL="install",A.INTEGRATION="integration",A.INTERSECT="intersect",A.INTERVAL="interval",A.INTO="into",A.INTRODUCER="introducer",A.IRLIKE="irlike",A.IS="is",A.ISNULL="isnull",A.JOIN="join",A.JOIN_MARKER="joinMarker",A.KEEP="keep",A.KEY="key",A.KILL="kill",A.LANGUAGE="language",A.LATERAL="lateral",A.LEFT="left",A.LIKE="like",A.LIMIT="limit",A.LIST="list",A.LOAD="load",A.LOCK="lock",A.MAP="map",A.MATCH="match",A.MATCH_CONDITION="matchCondition",A.MATCH_RECOGNIZE="matchRecognize",A.MEMBER_OF="memberOf",A.MERGE="merge",A.MOD="mod",A.MODEL="model",A.NATURAL="natural",A.NEXT="next",A.NOTHING="nothing",A.NOTNULL="notnull",A.NULL="null",A.OBJECT_IDENTIFIER="objectIdentifier",A.OFFSET="offset",A.ON="on",A.ONLY="only",A.OPERATOR="operator",A.ORDER_BY="orderBy",A.ORDER_SIBLINGS_BY="orderSiblingsBy",A.ORDERED="ordered",A.ORDINALITY="ordinality",A.OUT="out",A.INOUT="inout",A.OUTER="outer",A.OVER="over",A.OVERLAPS="overlaps",A.OVERWRITE="overwrite",A.PACKAGE="package",A.PARTITION="partition",A.PARTITION_BY="partitionBy",A.PERCENT="percent",A.PIVOT="pivot",A.PLACEHOLDER="placeholder",A.POLICY="policy",A.POOL="pool",A.POSITIONAL="positional",A.PRAGMA="pragma",A.PREWHERE="prewhere",A.PRIMARY_KEY="primaryKey",A.PROCEDURE="procedure",A.PROPERTIES="properties",A.PSEUDO_TYPE="pseudoType",A.PUT="put",A.QUALIFY="qualify",A.QUOTE="quote",A.QDCOLON="qdcolon",A.RANGE="range",A.RECURSIVE="recursive",A.REFRESH="refresh",A.RENAME="rename",A.REPLACE="replace",A.RETURNING="returning",A.REVOKE="revoke",A.REFERENCES="references",A.RIGHT="right",A.RLIKE="rlike",A.ROLE="role",A.ROLLBACK="rollback",A.ROLLUP="rollup",A.ROW="row",A.RULE="rule",A.ROWS="rows",A.SELECT="select",A.SEMI="semi",A.SEPARATOR="separator",A.SEQUENCE="sequence",A.SERDE_PROPERTIES="serdeProperties",A.SET="set",A.SETTINGS="settings",A.SHOW="show",A.SIMILAR_TO="similarTo",A.SOME="some",A.SORT_BY="sortBy",A.SOUNDS_LIKE="soundsLike",A.SQL_SECURITY="sqlSecurity",A.START_WITH="startWith",A.STORAGE_INTEGRATION="storageIntegration",A.STRAIGHT_JOIN="straightJoin",A.STRUCT="struct",A.SUMMARIZE="summarize",A.TABLE_SAMPLE="tableSample",A.TAG="tag",A.TEMPORARY="temporary",A.TOP="top",A.THEN="then",A.TRUE="true",A.TRIGGER="trigger",A.TRUNCATE="truncate",A.TYPE="type",A.UNCACHE="uncache",A.UNION="union",A.UNNEST="unnest",A.UNPIVOT="unpivot",A.UPDATE="update",A.USE="use",A.USING="using",A.VALUES="values",A.VARIADIC="variadic",A.VIEW="view",A.SEMANTIC_VIEW="semanticView",A.VOLATILE="volatile",A.VOLUME="volume",A.WHEN="when",A.WHERE="where",A.WINDOW="window",A.WITH="with",A.UNIQUE="unique",A.UTC_DATE="utcDate",A.UTC_TIME="utcTime",A.UTC_TIMESTAMP="utcTimestamp",A.VERSION_SNAPSHOT="versionSnapshot",A.TIMESTAMP_SNAPSHOT="timestampSnapshot",A.OPTION="option",A.SINK="sink",A.SOURCE="source",A.ANALYZE="analyze",A.NAMESPACE="namespace",A.EXPORT="export",A.HIVE_TOKEN_STREAM="hiveTokenStream",A))(PM||{}),fA=class fA{static number(e){return new fA("number",String(e))}static string(e){return new fA("string",e)}static identifier(e){return new fA("identifier",e)}constructor(e,t,s=1,r=1,i=0,o=0,c=[]){this.tokenType=e,this.text=t,this.line=s,this.col=r,this.start=i,this.end=o,this.comments=c}};n(fA,"Token");var KI=fA,jY,XY,JY,zY,QY,ZY,KY,eV,tV,sV,Rs;sV=[O],tV=[O],eV=[O],KY=[O],ZY=[O],QY=[O],zY=[O],JY=[O],XY=[O],jY=[O];var ie=class ie{constructor(e={}){this.sql="";this.size=0;this.tokens=[];this.dialect=void 0;this._start=0;this._current=0;this.line=1;this._col=0;this.comments=[];this.char="";this._end=!1;this.peek="";this.prevTokenLine=-1;let{dialect:t}=e;this.dialect=ae.getOrRaise(t),this.reset()}static get BYTE_STRING_ESCAPES(){return this.STRING_ESCAPES}static get _COMMENTS(){let e={};for(let t of this.COMMENTS)typeof t=="string"?e[t]=void 0:e[t[0]]=t[1];return e["{#"]="#}",this.HINT_START in this.KEYWORDS&&(e[this.HINT_START]="*/"),e}static get _FORMAT_STRINGS(){let e={};for(let[t,s]of Object.entries(this._QUOTES))for(let r of["n","N"])e[r+t]=[s,"nationalString"];return{...e,...this.quotesToFormat("bitString",this.BIT_STRINGS),...this.quotesToFormat("byteString",this.BYTE_STRINGS),...this.quotesToFormat("hexString",this.HEX_STRINGS),...this.quotesToFormat("rawString",this.RAW_STRINGS),...this.quotesToFormat("heredocString",this.HEREDOC_STRINGS),...this.quotesToFormat("unicodeString",this.UNICODE_STRINGS)}}static get _IDENTIFIERS(){return this.convertQuotes(this.IDENTIFIERS)}static get _IDENTIFIER_ESCAPES(){return new Set(this.IDENTIFIER_ESCAPES)}static get _QUOTES(){return this.convertQuotes(this.QUOTES)}static get _STRING_ESCAPES(){return new Set(this.STRING_ESCAPES)}static get _BYTE_STRING_ESCAPES(){return new Set(this.BYTE_STRING_ESCAPES)}static get _ESCAPE_FOLLOW_CHARS(){return new Set(this.ESCAPE_FOLLOW_CHARS)}static get _KEYWORD_TRIE(){let e=Object.keys(this.SINGLE_TOKENS),t=[...Object.keys(this.KEYWORDS),...Object.keys(this._COMMENTS),...Object.keys(this._QUOTES),...Object.keys(this._FORMAT_STRINGS)];return Gt(t.filter(s=>s.includes(" ")||e.some(r=>s.includes(r))).map(s=>Array.from(s.toUpperCase())))}static get KEYWORDS(){return this.ORIGINAL_KEYWORDS}reset(){this.sql="",this.size=0,this.tokens=[],this._start=0,this._current=0,this.line=1,this._col=0,this.comments=[],this.char="",this._end=!1,this.peek="",this.prevTokenLine=-1}tokenize(e){this.reset(),this.sql=e,this.size=e.length;try{this.scan()}catch{let t=Math.max(this._current-50,0),s=Math.min(this._current+50,this.size-1),r=this.sql.slice(t,s);throw new ZE(`Error tokenizing '${r}'`)}return this.tokens}scan(e){for(;this.size&&!this._end;){let t=this._current;for(;t<this.size;){let r=this.sql[t];if(this.isWhitespace(r)&&(r===" "||r===" "))t++;else break}let s=this._current<t?t-this._current:1;if(this._start=t,this.advance({i:s}),this.isWhitespace(this.char)||(this.isDigit(this.char)?this.scanNumber():this.char in this._constructor._IDENTIFIERS?this.scanIdentifier(this._constructor._IDENTIFIERS[this.char]):this.scanKeywords()),e?.())break}this.tokens.length&&this.comments.length&&this.tokens[this.tokens.length-1].comments.push(...this.comments)}chars(e){if(e===1)return this.char;let t=this._current-1,s=t+e;return s<=this.size?this.sql.slice(t,s):""}advance(e={}){let{i:t=1,alnum:s=!1}=e;if(this._constructor.WHITE_SPACE[this.char]==="break"?this.char==="\r"&&this.peek===`
|
|
4
|
-
`||(this._col=t,this.line+=1):this._col+=t,this._current+=t,this._end=this.size<=this._current,this.char=this.sql[this._current-1],this.char===void 0)throw new Error("Index out of bound");if(this.peek=this._end?"":this.sql[this._current],s&&this.isAlnum(this.char)){let{_col:i,_current:o,_end:c,peek:p}=this;for(;this.isAlnum(p);)i+=1,o+=1,c=this.size<=o,p=c?"":this.sql[o];this._col=i,this._current=o,this._end=c,this.peek=p,this.char=this.sql[o-1]}}get text(){return this.sql.slice(this._start,this._current)}add(e,t){this.prevTokenLine=this.line,this.comments.length&&e==="semicolon"&&this.tokens.length&&(this.tokens[this.tokens.length-1].comments.push(...this.comments),this.comments=[]),this.tokens.push(new KI(e,t??this.text,this.line,this._col,this._start,this._current-1,this.comments)),this.comments=[];let s=this._constructor;if(s.COMMANDS.has(e)&&this.peek!==";"&&(this.tokens.length===1||s.COMMAND_PREFIX_TOKENS.has(this.tokens[this.tokens.length-2].tokenType))){let r=this._current,i=this.tokens.length;this.scan(()=>this.peek===";"),this.tokens=this.tokens.slice(0,i);let o=this.sql.slice(r,this._current).trim();o&&this.add("string",o)}}scanKeywords(){let e=0,t,s=this.text,r=s,i=!1,o=!1,c=this._constructor,p=c._KEYWORD_TRIE,u=r in this._constructor.SINGLE_TOKENS;for(;s;){let g;if(o?g=1:[g,p]=Nn(p,Array.from(r.toUpperCase())),g===0)break;g===2&&(t=s);let f=this._current+e;if(e+=1,f<this.size){r=this.sql[f],u=u||r in this._constructor.SINGLE_TOKENS;let x=this.isWhitespace(r);!x||!i?(x&&(r=" "),s+=r,i=x,o=!1):o=!0}else{r="";break}}if(t){if(this.scanString(t)||this.scanComment(t))return;if(i||u||!r){this.advance({i:e-1});let g=t.toUpperCase();this.add(c.KEYWORDS[g],g);return}}let h=this._constructor.SINGLE_TOKENS[this.char];if(h!==void 0){this.add(h,this.char);return}this.scanVar()}scanComment(e){let t=this._constructor;if(!(e in t._COMMENTS))return!1;let s=this.line,r=e.length,i=t._COMMENTS[e];if(i){this.advance({i:r});let o=1,c=i.length;for(;!this._end&&!(this.chars(c)===i&&(o-=1,!o));)this.advance({alnum:!0}),t.NESTED_COMMENTS&&!this._end&&this.chars(r)===e&&(this.advance({i:r}),o+=1);this.comments.push(this.text.slice(r,-c+1)),this.advance({i:c-1})}else{for(;!this._end&&t.WHITE_SPACE[this.peek]!=="break";)this.advance({i:1,alnum:!0});this.comments.push(this.text.slice(r))}return e===t.HINT_START&&this.tokens.length&&t.TOKENS_PRECEDING_HINT.has(this.tokens[this.tokens.length-1].tokenType)&&this.add("hint"),s===this.prevTokenLine&&(this.tokens[this.tokens.length-1].comments.push(...this.comments),this.comments=[],this.prevTokenLine=this.line),!0}scanNumber(){let e=this._constructor;if(this.char==="0"){let p=this.peek.toUpperCase();if(p==="B")return e.BIT_STRINGS.length?this.scanBits():this.add("number");if(p==="X")return e.HEX_STRINGS.length?this.scanHex():this.add("number")}let t=!1,s=0,r=!1,i="",o="",c;for(;;)if(this.isDigit(this.peek))this.advance();else if(this.peek==="."&&!t){if(this.tokens.length&&this.tokens[this.tokens.length-1].tokenType==="parameter")break;t=!0,this.advance()}else if(["-","+"].includes(this.peek)&&s===1)if(this._current+1<this.size&&this.isDigit(this.sql[this._current+1]))s+=1,this.advance();else break;else if(this.peek.toUpperCase()==="E"&&!s)s+=1,this.advance();else if(this.peek==="_"&&this.dialect._constructor.NUMBERS_CAN_BE_UNDERSCORE_SEPARATED)r=!0,this.advance();else if(this.isIdentifierChar(this.peek)){for(i=this.text;this.peek.trim()&&!this._constructor.SINGLE_TOKENS[this.peek];)o+=this.peek,this.advance();if(c=e.KEYWORDS[e.NUMERIC_LITERALS[o.toUpperCase()]||""],c)break;if(this.dialect._constructor.IDENTIFIERS_CAN_START_WITH_DIGIT)return this.add("var");this.advance({i:-o.length});break}else break;i=i||this.sql.slice(this._start,this._current),r&&(i=i.replaceAll("_","")),this.add("number",i),c&&(this.add("dcolon","::"),this.add(c,o))}scanBits(){this.advance();let e=this.extractValue();Number.isNaN(parseInt(e,2))?this.add("identifier"):this.add("bitString",e.slice(2))}scanHex(){this.advance();let e=this.extractValue();Number.isNaN(parseInt(e,16))?this.add("identifier"):this.add("hexString",e.slice(2))}extractValue(){for(;;){let e=this.peek.trim();if(e&&!this._constructor.SINGLE_TOKENS[e])this.advance({i:1,alnum:!0});else break}return this.text}scanString(e){let t=this._constructor,s,r="string",i;if(e in t._QUOTES)i=t._QUOTES[e];else if(e in t._FORMAT_STRINGS){if([i,r]=t._FORMAT_STRINGS[e],r==="hexString")s=16;else if(r==="bitString")s=2;else if(r==="heredocString"){this.advance();let c;if(this.char===i?c="":c=this.extractString(i,void 0,{rawString:!0,raiseUnmatched:!t.HEREDOC_TAG_IS_IDENTIFIER}),c&&t.HEREDOC_TAG_IS_IDENTIFIER&&(this._end||this.isDigit(c)||this.isWhitespace(c)))return this._end||this.advance({i:-1}),this.advance({i:-c.length}),this.add(t.HEREDOC_STRING_ALTERNATIVE),!0;i=`${e}${c}${i}`}}else return!1;this.advance({i:e.length});let o=this.extractString(i,r==="byteString"?t._BYTE_STRING_ESCAPES:t._STRING_ESCAPES,{rawString:r==="rawString"});if(s&&o&&Number.isNaN(parseInt(o,s)))throw new Error(`Numeric string contains invalid characters from ${this.line}:${this._start}`);return this.add(r,o),!0}scanIdentifier(e){this.advance();let t=this._constructor,s=new Set([...Array.from(t._IDENTIFIER_ESCAPES),e]),r=this.extractString(e,s);this.add("identifier",r)}scanVar(){let e=this._constructor;for(;;){let t=this.peek.trim();if(t&&(e.VAR_SINGLE_TOKENS.has(t)||!this._constructor.SINGLE_TOKENS[t]))this.advance({i:1,alnum:!0});else break}this.add(this.tokens.length&&this.tokens[this.tokens.length-1].tokenType==="parameter"?"var":e.KEYWORDS[this.text.toUpperCase()]||"var")}extractString(e,t=void 0,s={}){let{rawString:r=!1,raiseUnmatched:i=!0}=s,o=this._constructor,c="",p=e.length;for(t=t===void 0?o._STRING_ESCAPES:t;;){if(!r&&this.dialect._constructor.UNESCAPED_SEQUENCES&&this.peek&&t.has(this.char)){let h=this.dialect._constructor.UNESCAPED_SEQUENCES[this.char+this.peek];if(h){this.advance({i:2}),c+=h;continue}}let u=o.ESCAPE_FOLLOW_CHARS.length&&this.char==="\\"&&!o.ESCAPE_FOLLOW_CHARS.includes(this.peek);if((o.STRING_ESCAPES_ALLOWED_IN_RAW_STRINGS||!r)&&t.has(this.char)&&(this.peek===e||t.has(this.peek)||u)&&(!(this.char in o._QUOTES)||this.char===this.peek))if(this.peek===e?c+=this.peek:u&&this.char!==this.peek?c+=this.peek:c+=this.char+this.peek,this._current+1<this.size)this.advance({i:2});else throw new ZE(`Missing ${e} from ${this.line}:${this._current}`);else{if(this.chars(p)===e){1<p&&this.advance({i:p-1});break}if(this._end){if(!i)return c+this.char;throw new ZE(`Missing ${e} from ${this.line}:${this._start}`)}let h=this._current-1;this.advance({i:1,alnum:!0}),c+=this.sql.slice(h,this._current-1)}}return c}static convertQuotes(e){let t={};for(let s of e){let r=typeof s=="string"?s:s[0],i=typeof s=="string"?s:s[1];t[r]=i}return t}static quotesToFormat(e,t){let s=this.convertQuotes(t),r={};for(let[i,o]of Object.entries(s))r[i]=[o,e];return r}isWhitespace(e){return/\s/.test(e)}isDigit(e){return/\d/.test(e)}isAlnum(e){return/[a-zA-Z0-9]/.test(e)}isIdentifierChar(e){return/[a-zA-Z_]/.test(e)}get _constructor(){return this.constructor}};Rs=vt(null),R(Rs,10,"_COMMENTS",sV,ie),R(Rs,10,"_FORMAT_STRINGS",tV,ie),R(Rs,10,"_IDENTIFIERS",eV,ie),R(Rs,10,"_IDENTIFIER_ESCAPES",KY,ie),R(Rs,10,"_QUOTES",ZY,ie),R(Rs,10,"_STRING_ESCAPES",QY,ie),R(Rs,10,"_BYTE_STRING_ESCAPES",zY,ie),R(Rs,10,"_ESCAPE_FOLLOW_CHARS",JY,ie),R(Rs,10,"_KEYWORD_TRIE",XY,ie),R(Rs,10,"KEYWORDS",jY,ie),Nt(Rs,ie),It(Rs,3,ie),n(ie,"Tokenizer"),ie.SINGLE_TOKENS={"(":"lParen",")":"rParen","[":"lBracket","]":"rBracket","{":"lBrace","}":"rBrace","&":"amp","^":"caret",":":"colon",",":"comma",".":"dot","-":"dash","=":"eq",">":"gt","<":"lt","%":"mod","!":"not","|":"pipe","+":"plus",";":"semicolon","/":"slash","\\":"backslash","*":"star","~":"tilde","?":"placeholder","@":"parameter","#":"hash","'":"unknown","`":"unknown",'"':"unknown"},ie.BIT_STRINGS=[],ie.BYTE_STRINGS=[],ie.HEX_STRINGS=[],ie.RAW_STRINGS=[],ie.HEREDOC_STRINGS=[],ie.IDENTIFIERS=['"'],ie.QUOTES=["'"],ie.UNICODE_STRINGS=[],ie.STRING_ESCAPES=["'"],ie.VAR_SINGLE_TOKENS=new Set,ie.ESCAPE_FOLLOW_CHARS=[],ie.IDENTIFIER_ESCAPES=[],ie.HEREDOC_TAG_IS_IDENTIFIER=!1,ie.HEREDOC_STRING_ALTERNATIVE="var",ie.STRING_ESCAPES_ALLOWED_IN_RAW_STRINGS=!0,ie.NESTED_COMMENTS=!0,ie.HINT_START="/*+",ie.TOKENS_PRECEDING_HINT=new Set(["select","insert","update","delete"]),ie.ORIGINAL_KEYWORDS={"{%":"blockStart","{%+":"blockStart","{%-":"blockStart","%}":"blockEnd","+%}":"blockEnd","-%}":"blockEnd","{{+":"blockStart","{{-":"blockStart","+}}":"blockEnd","-}}":"blockEnd",[ie.HINT_START]:"hint","&<":"ampLt","&>":"ampGt","==":"eq","::":"dcolon","?::":"qdcolon","||":"dpipe","|>":"pipeGt",">=":"gte","<=":"lte","<>":"neq","!=":"neq",":=":"colonEq","<=>":"nullsafeEq","->":"arrow","->>":"darrow","=>":"farrow","#>":"hashArrow","#>>":"dhashArrow","<->":"lrArrow","&&":"damp","??":"dqmark","~~~":"glob","~~":"like","~~*":"ilike","~*":"irlike","-|-":"adjacent",ALL:"all",AND:"and",ANTI:"anti",ANY:"any",ASC:"asc",AS:"alias",ASOF:"asof",AUTOINCREMENT:"autoIncrement",AUTO_INCREMENT:"autoIncrement",BEGIN:"begin",BETWEEN:"between",CACHE:"cache",UNCACHE:"uncache",CASE:"case","CHARACTER SET":"characterSet","CLUSTER BY":"clusterBy",COLLATE:"collate",COLUMN:"column",COMMIT:"commit","CONNECT BY":"connectBy",CONSTRAINT:"constraint",COPY:"copy",CREATE:"create",CROSS:"cross",CUBE:"cube",CURRENT_DATE:"currentDate",CURRENT_SCHEMA:"currentSchema",CURRENT_TIME:"currentTime",CURRENT_TIMESTAMP:"currentTimestamp",CURRENT_USER:"currentUser",CURRENT_CATALOG:"currentCatalog",DATABASE:"database",DEFAULT:"default",DELETE:"delete",DESC:"desc",DESCRIBE:"describe",DISTINCT:"distinct","DISTRIBUTE BY":"distributeBy",DIV:"div",DROP:"drop",ELSE:"else",END:"end",ENUM:"enum",ESCAPE:"escape",EXCEPT:"except",EXECUTE:"execute",EXISTS:"exists",FALSE:"false",FETCH:"fetch",FILTER:"filter",FILE:"file",FIRST:"first",FULL:"full",FUNCTION:"function",FOR:"for","FOREIGN KEY":"foreignKey",FORMAT:"format",FROM:"from",GEOGRAPHY:"geography",GEOMETRY:"geometry",GLOB:"glob","GROUP BY":"groupBy","GROUPING SETS":"groupingSets",HAVING:"having",ILIKE:"ilike",IN:"in",INDEX:"index",INET:"inet",INNER:"inner",INSERT:"insert",INTERVAL:"interval",INTERSECT:"intersect",INTO:"into",IS:"is",ISNULL:"isnull",JOIN:"join",KEEP:"keep",KILL:"kill",LATERAL:"lateral",LEFT:"left",LIKE:"like",LIMIT:"limit",LOAD:"load",LOCALTIME:"localtime",LOCALTIMESTAMP:"localtimestamp",LOCK:"lock",MERGE:"merge",NAMESPACE:"namespace",NATURAL:"natural",NEXT:"next",NOT:"not",NOTNULL:"notnull",NULL:"null",OBJECT:"object",OFFSET:"offset",ON:"on",OR:"or",XOR:"xor","ORDER BY":"orderBy",ORDINALITY:"ordinality",OUT:"out",OUTER:"outer",OVER:"over",OVERLAPS:"overlaps",OVERWRITE:"overwrite",PARTITION:"partition","PARTITION BY":"partitionBy","PARTITIONED BY":"partitionBy",PARTITIONED_BY:"partitionBy",PERCENT:"percent",PIVOT:"pivot",PRAGMA:"pragma","PRIMARY KEY":"primaryKey",PROCEDURE:"procedure",OPERATOR:"operator",QUALIFY:"qualify",RANGE:"range",RECURSIVE:"recursive",REGEXP:"rlike",RENAME:"rename",REPLACE:"replace",RETURNING:"returning",REFERENCES:"references",RIGHT:"right",RLIKE:"rlike",ROLLBACK:"rollback",ROLLUP:"rollup",ROW:"row",ROWS:"rows",SCHEMA:"schema",SELECT:"select",SEMI:"semi",SESSION:"session",SESSION_USER:"sessionUser",SET:"set",SETTINGS:"settings",SHOW:"show","SIMILAR TO":"similarTo",SOME:"some","SORT BY":"sortBy","SQL SECURITY":"sqlSecurity","START WITH":"startWith",STRAIGHT_JOIN:"straightJoin",TABLE:"table",TABLESAMPLE:"tableSample",TEMP:"temporary",TEMPORARY:"temporary",THEN:"then",TRUE:"true",TRIGGER:"trigger",TRUNCATE:"truncate",UNION:"union",UNKNOWN:"unknown",UNNEST:"unnest",UNPIVOT:"unpivot",UPDATE:"update",USE:"use",USING:"using",UUID:"uuid",VALUES:"values",VIEW:"view",VOLATILE:"volatile",WHEN:"when",WHERE:"where",WINDOW:"window",WITH:"with",APPLY:"apply",ARRAY:"array",BIT:"bit",BOOL:"boolean",BOOLEAN:"boolean",BYTE:"tinyint",MEDIUMINT:"mediumint",INT1:"tinyint",TINYINT:"tinyint",INT16:"smallint",SHORT:"smallint",SMALLINT:"smallint",HUGEINT:"int128",UHUGEINT:"uint128",INT2:"smallint",INTEGER:"int",INT:"int",INT4:"int",INT32:"int",INT64:"bigint",INT128:"int128",INT256:"int256",LONG:"bigint",BIGINT:"bigint",INT8:"tinyint",UINT:"uint",UINT128:"uint128",UINT256:"uint256",DEC:"decimal",DECIMAL:"decimal",DECIMAL32:"decimal32",DECIMAL64:"decimal64",DECIMAL128:"decimal128",DECIMAL256:"decimal256",DECFLOAT:"decfloat",BIGDECIMAL:"bigdecimal",BIGNUMERIC:"bigdecimal",BIGNUM:"bignum",LIST:"list",MAP:"map",NULLABLE:"nullable",NUMBER:"decimal",NUMERIC:"decimal",FIXED:"decimal",REAL:"float",FLOAT:"float",FLOAT4:"float",FLOAT8:"double",DOUBLE:"double","DOUBLE PRECISION":"double",JSON:"json",JSONB:"jsonb",CHAR:"char",CHARACTER:"char","CHAR VARYING":"varchar","CHARACTER VARYING":"varchar",NCHAR:"nchar",VARCHAR:"varchar",VARCHAR2:"varchar",NVARCHAR:"nvarchar",NVARCHAR2:"nvarchar",BPCHAR:"bpchar",STR:"text",STRING:"text",TEXT:"text",LONGTEXT:"longtext",MEDIUMTEXT:"mediumtext",TINYTEXT:"tinytext",CLOB:"text",LONGVARCHAR:"text",BINARY:"binary",BLOB:"varbinary",LONGBLOB:"longblob",MEDIUMBLOB:"mediumblob",TINYBLOB:"tinyblob",BYTEA:"varbinary",VARBINARY:"varbinary",TIME:"time",TIMETZ:"timetz",TIME_NS:"timeNs",TIMESTAMP:"timestamp",TIMESTAMPTZ:"timestamptz",TIMESTAMPLTZ:"timestampltz",TIMESTAMP_LTZ:"timestampltz",TIMESTAMPNTZ:"timestampntz",TIMESTAMP_NTZ:"timestampntz",DATE:"date",DATETIME:"datetime",INT4RANGE:"int4range",INT4MULTIRANGE:"int4multirange",INT8RANGE:"int8range",INT8MULTIRANGE:"int8multirange",NUMRANGE:"numrange",NUMMULTIRANGE:"nummultirange",TSRANGE:"tsrange",TSMULTIRANGE:"tsmultirange",TSTZRANGE:"tstzrange",TSTZMULTIRANGE:"tstzmultirange",DATERANGE:"daterange",DATEMULTIRANGE:"datemultirange",UNIQUE:"unique",VECTOR:"vector",STRUCT:"struct",SEQUENCE:"sequence",VARIANT:"variant",ALTER:"alter",ANALYZE:"analyze",CALL:"command",COMMENT:"comment",EXPLAIN:"command",GRANT:"grant",REVOKE:"revoke",OPTIMIZE:"command",PREPARE:"command",VACUUM:"command","USER-DEFINED":"userdefined","FOR VERSION":"versionSnapshot","FOR TIMESTAMP":"timestampSnapshot"},ie.WHITE_SPACE={" ":"space"," ":"space","\n":"break","\r":"break"},ie.COMMANDS=new Set(["command","execute","fetch","show","rename"]),ie.COMMAND_PREFIX_TOKENS=new Set(["semicolon","begin"]),ie.NUMERIC_LITERALS={},ie.COMMENTS=["--",["/*","*/"]];var Fr=ie;function Wl(a,e,t){if(!a)return;let s=0,r=1,i=a.length,o=t??Gt(Object.keys(e).map(h=>Array.from(h))),c=o,p=[],u;for(;r<=i;){let h=a.substring(s,r),[g,f]=Nn(c,[h[h.length-1]]);c=f,g===0?(u?(r-=1,h=u,u=void 0):(h=h[0],r=s+1),s+=h.length,p.push(h),c=o):g===2&&(u=h),r+=1,g!==0&&i<r&&p.push(h)}return p.map(h=>e[h]??h).join("")}n(Wl,"formatTime");var SD=new Set(["africa/abidjan","africa/accra","africa/addis_ababa","africa/algiers","africa/asmara","africa/asmera","africa/bamako","africa/bangui","africa/banjul","africa/bissau","africa/blantyre","africa/brazzaville","africa/bujumbura","africa/cairo","africa/casablanca","africa/ceuta","africa/conakry","africa/dakar","africa/dar_es_salaam","africa/djibouti","africa/douala","africa/el_aaiun","africa/freetown","africa/gaborone","africa/harare","africa/johannesburg","africa/juba","africa/kampala","africa/khartoum","africa/kigali","africa/kinshasa","africa/lagos","africa/libreville","africa/lome","africa/luanda","africa/lubumbashi","africa/lusaka","africa/malabo","africa/maputo","africa/maseru","africa/mbabane","africa/mogadishu","africa/monrovia","africa/nairobi","africa/ndjamena","africa/niamey","africa/nouakchott","africa/ouagadougou","africa/porto-novo","africa/sao_tome","africa/timbuktu","africa/tripoli","africa/tunis","africa/windhoek","america/adak","america/anchorage","america/anguilla","america/antigua","america/araguaina","america/argentina/buenos_aires","america/argentina/catamarca","america/argentina/comodrivadavia","america/argentina/cordoba","america/argentina/jujuy","america/argentina/la_rioja","america/argentina/mendoza","america/argentina/rio_gallegos","america/argentina/salta","america/argentina/san_juan","america/argentina/san_luis","america/argentina/tucuman","america/argentina/ushuaia","america/aruba","america/asuncion","america/atikokan","america/atka","america/bahia","america/bahia_banderas","america/barbados","america/belem","america/belize","america/blanc-sablon","america/boa_vista","america/bogota","america/boise","america/buenos_aires","america/cambridge_bay","america/campo_grande","america/cancun","america/caracas","america/catamarca","america/cayenne","america/cayman","america/chicago","america/chihuahua","america/ciudad_juarez","america/coral_harbour","america/cordoba","america/costa_rica","america/creston","america/cuiaba","america/curacao","america/danmarkshavn","america/dawson","america/dawson_creek","america/denver","america/detroit","america/dominica","america/edmonton","america/eirunepe","america/el_salvador","america/ensenada","america/fort_nelson","america/fort_wayne","america/fortaleza","america/glace_bay","america/godthab","america/goose_bay","america/grand_turk","america/grenada","america/guadeloupe","america/guatemala","america/guayaquil","america/guyana","america/halifax","america/havana","america/hermosillo","america/indiana/indianapolis","america/indiana/knox","america/indiana/marengo","america/indiana/petersburg","america/indiana/tell_city","america/indiana/vevay","america/indiana/vincennes","america/indiana/winamac","america/indianapolis","america/inuvik","america/iqaluit","america/jamaica","america/jujuy","america/juneau","america/kentucky/louisville","america/kentucky/monticello","america/knox_in","america/kralendijk","america/la_paz","america/lima","america/los_angeles","america/louisville","america/lower_princes","america/maceio","america/managua","america/manaus","america/marigot","america/martinique","america/matamoros","america/mazatlan","america/mendoza","america/menominee","america/merida","america/metlakatla","america/mexico_city","america/miquelon","america/moncton","america/monterrey","america/montevideo","america/montreal","america/montserrat","america/nassau","america/new_york","america/nipigon","america/nome","america/noronha","america/north_dakota/beulah","america/north_dakota/center","america/north_dakota/new_salem","america/nuuk","america/ojinaga","america/panama","america/pangnirtung","america/paramaribo","america/phoenix","america/port-au-prince","america/port_of_spain","america/porto_acre","america/porto_velho","america/puerto_rico","america/punta_arenas","america/rainy_river","america/rankin_inlet","america/recife","america/regina","america/resolute","america/rio_branco","america/rosario","america/santa_isabel","america/santarem","america/santiago","america/santo_domingo","america/sao_paulo","america/scoresbysund","america/shiprock","america/sitka","america/st_barthelemy","america/st_johns","america/st_kitts","america/st_lucia","america/st_thomas","america/st_vincent","america/swift_current","america/tegucigalpa","america/thule","america/thunder_bay","america/tijuana","america/toronto","america/tortola","america/vancouver","america/virgin","america/whitehorse","america/winnipeg","america/yakutat","america/yellowknife","antarctica/casey","antarctica/davis","antarctica/dumontdurville","antarctica/macquarie","antarctica/mawson","antarctica/mcmurdo","antarctica/palmer","antarctica/rothera","antarctica/south_pole","antarctica/syowa","antarctica/troll","antarctica/vostok","arctic/longyearbyen","asia/aden","asia/almaty","asia/amman","asia/anadyr","asia/aqtau","asia/aqtobe","asia/ashgabat","asia/ashkhabad","asia/atyrau","asia/baghdad","asia/bahrain","asia/baku","asia/bangkok","asia/barnaul","asia/beirut","asia/bishkek","asia/brunei","asia/calcutta","asia/chita","asia/choibalsan","asia/chongqing","asia/chungking","asia/colombo","asia/dacca","asia/damascus","asia/dhaka","asia/dili","asia/dubai","asia/dushanbe","asia/famagusta","asia/gaza","asia/harbin","asia/hebron","asia/ho_chi_minh","asia/hong_kong","asia/hovd","asia/irkutsk","asia/istanbul","asia/jakarta","asia/jayapura","asia/jerusalem","asia/kabul","asia/kamchatka","asia/karachi","asia/kashgar","asia/kathmandu","asia/katmandu","asia/khandyga","asia/kolkata","asia/krasnoyarsk","asia/kuala_lumpur","asia/kuching","asia/kuwait","asia/macao","asia/macau","asia/magadan","asia/makassar","asia/manila","asia/muscat","asia/nicosia","asia/novokuznetsk","asia/novosibirsk","asia/omsk","asia/oral","asia/phnom_penh","asia/pontianak","asia/pyongyang","asia/qatar","asia/qostanay","asia/qyzylorda","asia/rangoon","asia/riyadh","asia/saigon","asia/sakhalin","asia/samarkand","asia/seoul","asia/shanghai","asia/singapore","asia/srednekolymsk","asia/taipei","asia/tashkent","asia/tbilisi","asia/tehran","asia/tel_aviv","asia/thimbu","asia/thimphu","asia/tokyo","asia/tomsk","asia/ujung_pandang","asia/ulaanbaatar","asia/ulan_bator","asia/urumqi","asia/ust-nera","asia/vientiane","asia/vladivostok","asia/yakutsk","asia/yangon","asia/yekaterinburg","asia/yerevan","atlantic/azores","atlantic/bermuda","atlantic/canary","atlantic/cape_verde","atlantic/faeroe","atlantic/faroe","atlantic/jan_mayen","atlantic/madeira","atlantic/reykjavik","atlantic/south_georgia","atlantic/st_helena","atlantic/stanley","australia/act","australia/adelaide","australia/brisbane","australia/broken_hill","australia/canberra","australia/currie","australia/darwin","australia/eucla","australia/hobart","australia/lhi","australia/lindeman","australia/lord_howe","australia/melbourne","australia/nsw","australia/north","australia/perth","australia/queensland","australia/south","australia/sydney","australia/tasmania","australia/victoria","australia/west","australia/yancowinna","brazil/acre","brazil/denoronha","brazil/east","brazil/west","cet","cst6cdt","canada/atlantic","canada/central","canada/eastern","canada/mountain","canada/newfoundland","canada/pacific","canada/saskatchewan","canada/yukon","chile/continental","chile/easterisland","cuba","eet","est","est5edt","egypt","eire","etc/gmt","etc/gmt+0","etc/gmt+1","etc/gmt+10","etc/gmt+11","etc/gmt+12","etc/gmt+2","etc/gmt+3","etc/gmt+4","etc/gmt+5","etc/gmt+6","etc/gmt+7","etc/gmt+8","etc/gmt+9","etc/gmt-0","etc/gmt-1","etc/gmt-10","etc/gmt-11","etc/gmt-12","etc/gmt-13","etc/gmt-14","etc/gmt-2","etc/gmt-3","etc/gmt-4","etc/gmt-5","etc/gmt-6","etc/gmt-7","etc/gmt-8","etc/gmt-9","etc/gmt0","etc/greenwich","etc/uct","etc/utc","etc/universal","etc/zulu","europe/amsterdam","europe/andorra","europe/astrakhan","europe/athens","europe/belfast","europe/belgrade","europe/berlin","europe/bratislava","europe/brussels","europe/bucharest","europe/budapest","europe/busingen","europe/chisinau","europe/copenhagen","europe/dublin","europe/gibraltar","europe/guernsey","europe/helsinki","europe/isle_of_man","europe/istanbul","europe/jersey","europe/kaliningrad","europe/kiev","europe/kirov","europe/kyiv","europe/lisbon","europe/ljubljana","europe/london","europe/luxembourg","europe/madrid","europe/malta","europe/mariehamn","europe/minsk","europe/monaco","europe/moscow","europe/nicosia","europe/oslo","europe/paris","europe/podgorica","europe/prague","europe/riga","europe/rome","europe/samara","europe/san_marino","europe/sarajevo","europe/saratov","europe/simferopol","europe/skopje","europe/sofia","europe/stockholm","europe/tallinn","europe/tirane","europe/tiraspol","europe/ulyanovsk","europe/uzhgorod","europe/vaduz","europe/vatican","europe/vienna","europe/vilnius","europe/volgograd","europe/warsaw","europe/zagreb","europe/zaporozhye","europe/zurich","gb","gb-eire","gmt","gmt+0","gmt-0","gmt0","greenwich","hst","hongkong","iceland","indian/antananarivo","indian/chagos","indian/christmas","indian/cocos","indian/comoro","indian/kerguelen","indian/mahe","indian/maldives","indian/mauritius","indian/mayotte","indian/reunion","iran","israel","jamaica","japan","kwajalein","libya","met","mst","mst7mdt","mexico/bajanorte","mexico/bajasur","mexico/general","nz","nz-chat","navajo","prc","pst8pdt","pacific/apia","pacific/auckland","pacific/bougainville","pacific/chatham","pacific/chuuk","pacific/easter","pacific/efate","pacific/enderbury","pacific/fakaofo","pacific/fiji","pacific/funafuti","pacific/galapagos","pacific/gambier","pacific/guadalcanal","pacific/guam","pacific/honolulu","pacific/johnston","pacific/kanton","pacific/kiritimati","pacific/kosrae","pacific/kwajalein","pacific/majuro","pacific/marquesas","pacific/midway","pacific/nauru","pacific/niue","pacific/norfolk","pacific/noumea","pacific/pago_pago","pacific/palau","pacific/pitcairn","pacific/pohnpei","pacific/ponape","pacific/port_moresby","pacific/rarotonga","pacific/saipan","pacific/samoa","pacific/tahiti","pacific/tarawa","pacific/tongatapu","pacific/truk","pacific/wake","pacific/wallis","pacific/yap","poland","portugal","roc","rok","singapore","turkey","uct","us/alaska","us/aleutian","us/arizona","us/central","us/east-indiana","us/eastern","us/hawaii","us/indiana-starke","us/michigan","us/mountain","us/pacific","us/samoa","utc","universal","w-su","wet","zulu"]);function rV(a){try{let e=a.match(/\.(\d+)/);if(!e)return 0;let s=e[1].replace(/0+$/,"").length;return 3<s?6:0<s?3:0}catch{return 0}}n(rV,"subsecondPrecision");function ey(a,e={}){let{dialect:t,storeOriginalColumnIdentifiers:s=!1}=e,r=ae.getOrRaise(t),i;typeof a=="string"?i=ty(a,{dialect:r}):i=a;for(let o of i.walk({prune:n(c=>!!c.meta?.caseSensitive,"prune")}))if(!o.meta?.caseSensitive){if(s&&o instanceof $){let c=o;for(;c&&c.parent instanceof ge;)c=c.parent;"parts"in c&&Array.isArray(c.parts)&&(o.meta.dotParts=c.parts.map(p=>p.name))}r.normalizeIdentifier(o)}return i}n(ey,"normalizeIdentifiers");var jl=new Map,sy=new Set;function iV(a){sy.add(a);let e=a.sqlNames();for(let t of e)jl.set(t.toUpperCase(),a)}n(iV,"registerFunc");function z0(a,e){return ae.getOrRaise(e?.read??e?.dialect).parse(a,e)}n(z0,"parse");function mD(a,e){let t=ae.getOrRaise(e?.read??e?.dialect),s=e?.into?t.parseIntoTypes(e.into,a,e):t.parse(a,e);if(!s.length||s[0]===void 0)throw new Ke(`No expression was parsed from '${a}'`);return 1<s.length?new $A({expressions:s}):s[0]}n(mD,"parseOne");var JW=/:.*?[a-zA-Z+\-]/;function zW(a){if(a.length===1&&a[0].isStar)return new Ab({this:a[0]});let e=[],t=[];for(let s=0;s<a.length;s+=2)e.push(a[s]),t.push(a[s+1]);return new Ss({keys:UA(e,{copy:!1}),values:UA(t,{copy:!1})})}n(zW,"buildVarMap");function QW(a){if(a.length<2)throw new Error("buildLike only accept expression lists with at least 2 expressions");let e=new Qt({this:a[1],expression:a[0]});return 2<a.length?new Ba({this:e,expression:a[2]}):e}n(QW,"buildLike");function Jt(a,e={}){let{reverseArgs:t=!1}=e;return n(function(r){let i=this.parseBitwise(),o=r;return t&&([o,i]=[i,o]),this.parseEscape(this.expression(a,{this:o,expression:i}))},"parseBinaryRange")}n(Jt,"binaryRangeParser");function ZW(a,{dialect:e}){if(a.length<1)throw new Error("buildAlgorithm only accepts an expression list with at least one expression");let t=D(a,0),s=D(a,1);return t&&s?(e._constructor.LOG_BASE_FIRST||([t,s]=[s,t]),new ur({this:t,expression:s})):e._constructor.parserClass?.LOG_DEFAULTS_TO_LN??!1?new yh({this:t}):new ur({this:t})}n(ZW,"buildLogarithm");function nV(a,{dialect:e}){if(a.length<1)throw new Error("buildHex only accepts an expression list with at least one expression");let t=a[0];return e._constructor.HEX_LOWERCASE?new Ph({this:t}):new $a({this:t})}n(nV,"buildHex");function KW(a){if(a.length<1)throw new Error("buildLower only accepts an expression list with at least one expression");let e=a[0];return e instanceof $a?new Ph({this:e.args.this}):new Ar({this:e})}n(KW,"buildLower");function ej(a){if(a.length<1)throw new Error("buildUpper only accepts an expression list with at least one expression");let e=a[0];return e instanceof Ph?new $a({this:e.args.this}):new dr({this:e})}n(ej,"buildUpper");function RD(a){return n(function(t,{dialect:s}){if(t.length<2)throw new Error("buildExtractJsonWithPath only accepts an expression list with at least two expressions");let r=new a({this:t[0],expression:s.toJsonPath(D(t,1))});return 2<t.length&&r instanceof ms&&r.setArgKey("expressions",t.slice(2)),r instanceof bn&&r.setArgKey("scalarOnly",s._constructor.JSON_EXTRACT_SCALAR_SCALAR_ONLY),r},"builder")}n(RD,"buildExtractJsonWithPath");function tj(a){if(a.length<2)throw new Error("buildMod only accepts an expression list with at least two expressions");let e=a[0],t=a[1];return e=e instanceof U?new Se({this:e}):e,t=t instanceof U?new Se({this:t}):t,new jr({this:e,expression:t})}n(tj,"buildMod");function LM(a,e={}){if(a.length<2)throw new Error("buildPad only accepts an expression list with at least two expressions");let{isLeft:t=!0}=e;return new eb({this:D(a,0),expression:D(a,1),fillPattern:D(a,2),isLeft:t})}n(LM,"buildPad");function aV(a,e,t,s){let r=new a({expressions:e});return r instanceof ue&&s._constructor.HAS_DISTINCT_ARRAY_CONSTRUCTORS&&r.setArgKey("bracketNotation",t==="lBracket"),r}n(aV,"buildArrayConstructor");function sj(a,e={}){if(a.length<2)throw new Error("buildConvertTimezone only accepts an expression list with at least two expressions");let{defaultSourceTz:t}=e;if(a.length===2){let s=t?N.string(t):void 0,r=D(a,0),i=typeof r=="string"?N.string(r):r,o=D(a,1),c=typeof o=="string"?N.string(o):o;return new vn({sourceTz:s,targetTz:i,timestamp:c})}return vn.fromArgList(a)}n(sj,"buildConvertTimezone");function oV(a,e={}){if(a.length<1)throw new Error("buildTrim only accepts an expression list with at least one expression");let{isLeft:t=!0,reverseArgs:s=!1}=e,r=D(a,0),i=D(a,1);return i&&s&&([r,i]=[i,r]),new Ya({this:r,expression:i,position:t?"leading":"trailing"})}n(oV,"buildTrim");function rj(a,e={}){if(a.length<1)throw new Error("buildCoalesce only accepts an expression list with at least one expression");let{isNvl:t,isNull:s}=e;return new tt({this:D(a,0),expressions:a.slice(1),isNvl:t,isNull:s})}n(rj,"buildCoalesce");function cV(a){if(a.length<2)throw new Error("buildLocateStrposition only accepts an expression list with at least two expressions");return new Bs({this:D(a,1),substr:D(a,0),position:D(a,2)})}n(cV,"buildLocateStrPosition");function ij(a,{dialect:e}){if(a.length<2)throw new Error("buildArrayAppend only accepts an expression list with at least two expressions");return new sb({this:D(a,0),expression:D(a,1),nullPropagation:e._constructor.ARRAY_FUNCS_PROPAGATES_NULLS})}n(ij,"buildArrayAppend");function nj(a,{dialect:e}){if(a.length<2)throw new Error("buildArrayPrepend only accepts an expression list with at least two expressions");return new rb({this:a[0],expression:a[1],nullPropagation:e._constructor.ARRAY_FUNCS_PROPAGATES_NULLS})}n(nj,"buildArrayPrepend");function pV(a,{dialect:e}){if(a.length<1)throw new Error("buildArrayConcat only accepts an expression list with at least one expression");return new hh({this:a[0],expressions:a.slice(1),nullPropagation:e._constructor.ARRAY_FUNCS_PROPAGATES_NULLS})}n(pV,"buildArrayConcat");function aj(a,{dialect:e}){if(a.length<2)throw new Error("buildArrayRemove only accepts an expression list with at least two expressions");return new uh({this:a[0],expression:a[1],nullPropagation:e._constructor.ARRAY_FUNCS_PROPAGATES_NULLS})}n(aj,"buildArrayRemove");var lV,uV,hV,gV,EV,AV,dV,fV,xV,TV,SV,RV,OV,mV,NV,IV,yV,CV,bV,PV,LV,wV,MV,kV,DV,qV,UV,vV,FV,BV,$V,GV,YV,VV,HV,_V,WV,jV,XV,JV,zV,QV,ZV,KV,eH,tH,sH,rH,iH,nH,aH,oH,cH,pH,lH,uH,hH,gH,EH,AH,dH,fH,xH,TH,SH,RH,OH,mH,NH,IH,yH,CH,bH,PH,LH,wH,MH,F;MH=[O],wH=[O],LH=[O],PH=[O],bH=[O],CH=[O],yH=[O],IH=[O],NH=[O],mH=[O],OH=[O],RH=[O],SH=[O],TH=[O],xH=[O],fH=[O],dH=[O],AH=[O],EH=[O],gH=[O],hH=[O],uH=[O],lH=[O],pH=[O],cH=[O],oH=[O],aH=[O],nH=[O],iH=[O],rH=[O],sH=[O],tH=[O],eH=[O],KV=[O],ZV=[O],QV=[O],zV=[O],JV=[O],XV=[O],jV=[O],WV=[O],_V=[O],HV=[O],VV=[O],YV=[O],GV=[O],$V=[O],BV=[O],FV=[O],vV=[O],UV=[O],qV=[O],DV=[O],kV=[O],MV=[O],wV=[O],LV=[O],PV=[O],bV=[O],CV=[O],yV=[O],IV=[O],NV=[O],mV=[O],OV=[O],RV=[O],SV=[O],TV=[O],xV=[O],fV=[O],dV=[O],AV=[O],EV=[O],gV=[O],hV=[O],uV=[O],lV=[O];var S=class S{constructor(e={}){this.sql=void 0;this.dialect=void 0;this.errorLevel=void 0;this.errorMessageContext=void 0;this.maxErrors=void 0;this.errors=void 0;this.tokens=void 0;this.index=void 0;this.curr=void 0;this.next=void 0;this.prev=void 0;this.prevComments=void 0;this.pipeCteCounter=void 0;this._chunks=void 0;this._chunkIndex=void 0;let{errorLevel:t=3,errorMessageContext:s=100,maxErrors:r=3}=e;this.sql="",this.dialect=ae.getOrRaise(e.dialect),this.errorLevel=t,this.errorMessageContext=s,this.maxErrors=r,this.errors=[],this.tokens=[],this.index=0,this.curr=void 0,this.next=void 0,this.prev=void 0,this.prevComments=void 0,this.pipeCteCounter=0,this._chunks=[],this._chunkIndex=0,this.reset()}static get SHOW_TRIE(){return this._showTrie||(this._showTrie=Gt(Object.keys(this.SHOW_PARSERS).map(e=>e.split(" ")))),this._showTrie}static get SET_TRIE(){return this._setTrie||(this._setTrie=Gt(Object.keys(this.SET_PARSERS).map(e=>e.split(" ")))),this._setTrie}static get FUNCTIONS(){return{...Object.fromEntries(Array.from(jl.entries()).map(([e,t])=>[e,(s,r)=>t.fromArgList(s)])),...Object.fromEntries(["COALESCE","IFNULL","NVL"].map(e=>[e,(t,s)=>rj(t)])),ARRAY:n((e,t)=>new ue({expressions:e}),"ARRAY"),ARRAYAGG:n((e,{dialect:t})=>new Bn({this:e[0],nullsExcluded:t._constructor.ARRAY_AGG_INCLUDES_NULLS===void 0?!0:void 0}),"ARRAYAGG"),ARRAY_AGG:n((e,{dialect:t})=>new Bn({this:e[0],nullsExcluded:t._constructor.ARRAY_AGG_INCLUDES_NULLS===void 0?!0:void 0}),"ARRAY_AGG"),ARRAY_APPEND:ij,ARRAY_CAT:pV,ARRAY_CONCAT:pV,ARRAY_INTERSECT:n(e=>new wA({expressions:e}),"ARRAY_INTERSECT"),ARRAY_INTERSECTION:n(e=>new wA({expressions:e}),"ARRAY_INTERSECTION"),ARRAY_PREPEND:nj,ARRAY_REMOVE:aj,COUNT:n((e,t)=>new bh({this:e[0],expressions:e.slice(1),bigInt:!0}),"COUNT"),CONCAT:n((e,{dialect:t})=>new Bt({expressions:e,safe:!t._constructor.STRICT_STRING_CONCAT,coalesce:t._constructor.CONCAT_COALESCE}),"CONCAT"),CONCAT_WS:n((e,{dialect:t})=>new _t({expressions:e,safe:!t._constructor.STRICT_STRING_CONCAT,coalesce:t._constructor.CONCAT_COALESCE}),"CONCAT_WS"),CONVERT_TIMEZONE:n((e,t)=>sj(e),"CONVERT_TIMEZONE"),DATE_ADD:n(e=>e.length===3?OD(xt)([e[2],e[1],e[0]]):new xt({this:D(e,0),expression:D(e,1)}),"DATE_ADD"),DATE_SUB:n(e=>e.length===3?OD(jt)([e[2],e[1],e[0]]):new jt({this:D(e,0),expression:D(e,1)}),"DATE_SUB"),DATE_TO_DATE_STR:n((e,t)=>new z({this:e[0],to:new m({this:"text"})}),"DATE_TO_DATE_STR"),TIME_TO_TIME_STR:n((e,t)=>new z({this:e[0],to:new m({this:"text"})}),"TIME_TO_TIME_STR"),GENERATE_DATE_ARRAY:n((e,t)=>new ii({start:e[0],end:e[1],step:D(e,2)||new qe({this:N.string("1"),unit:Z("DAY")})}),"GENERATE_DATE_ARRAY"),GENERATE_UUID:n((e,{dialect:t})=>new kA({isString:t._constructor.UUID_IS_STRING_TYPE||void 0}),"GENERATE_UUID"),GLOB:n((e,t)=>new LA({this:e[1],expression:e[0]}),"GLOB"),LIKE:n((e,t)=>QW(e),"LIKE"),GREATEST:n((e,{dialect:t})=>new ni({this:e[0],expressions:e.slice(1),ignoreNulls:t._constructor.LEAST_GREATEST_IGNORES_NULLS}),"GREATEST"),LEAST:n((e,{dialect:t})=>new Ih({this:e[0],expressions:e.slice(1),ignoreNulls:t._constructor.LEAST_GREATEST_IGNORES_NULLS}),"LEAST"),HEX:n((e,{dialect:t})=>nV(e,{dialect:t}),"HEX"),TO_HEX:n((e,{dialect:t})=>nV(e,{dialect:t}),"TO_HEX"),JSON_EXTRACT:RD(ms),JSON_EXTRACT_SCALAR:RD(bn),JSON_EXTRACT_PATH_TEXT:RD(bn),JSON_KEYS:n((e,{dialect:t})=>new lb({this:e[0],expression:t.toJsonPath(D(e,1))}),"JSON_KEYS"),LOG:n((e,{dialect:t})=>ZW(e,{dialect:t}),"LOG"),LOG2:n((e,t)=>new ur({this:N.number(2),expression:D(e,0)}),"LOG2"),LOG10:n((e,t)=>new ur({this:N.number(10),expression:D(e,0)}),"LOG10"),MOD:n((e,t)=>tj(e),"MOD"),LOWER:n((e,t)=>KW(e),"LOWER"),UPPER:n((e,t)=>ej(e),"UPPER"),LPAD:n((e,t)=>LM(e),"LPAD"),LEFTPAD:n((e,t)=>LM(e),"LEFTPAD"),RPAD:n((e,t)=>LM(e,{isLeft:!1}),"RPAD"),RIGHTPAD:n((e,t)=>LM(e,{isLeft:!1}),"RIGHTPAD"),LTRIM:n((e,t)=>oV(e),"LTRIM"),RTRIM:n((e,t)=>oV(e,{isLeft:!1}),"RTRIM"),STRPOS:n((e,t)=>Bs.fromArgList(e),"STRPOS"),INSTR:n((e,t)=>Bs.fromArgList(e),"INSTR"),CHARINDEX:n((e,t)=>cV(e),"CHARINDEX"),LOCATE:n((e,t)=>cV(e),"LOCATE"),SCOPE_RESOLUTION:n((e,t)=>e.length!==2?new CA({expression:e[0]}):new CA({this:D(e,0),expression:e[1]}),"SCOPE_RESOLUTION"),TS_OR_DS_TO_DATE_STR:n((e,t)=>new Ns({this:new z({this:e[0],to:new m({this:"text"})}),start:N.number(1),length:N.number(10)}),"TS_OR_DS_TO_DATE_STR"),UNNEST:n((e,t)=>new Ee({expressions:[e[0]]}),"UNNEST"),UUID:n((e,{dialect:t})=>new kA({isString:t._constructor.UUID_IS_STRING_TYPE||void 0}),"UUID"),VAR_MAP:n((e,t)=>zW(e),"VAR_MAP")}}static get NO_PAREN_FUNCTIONS(){return{currentDate:pr,currentDatetime:pr,currentTime:si,currentTimestamp:ri,currentUser:fh,localtime:dh,localtimestamp:nb,currentRole:ab}}static get STRUCT_TYPE_TOKENS(){return new Set(["nested","object","struct","union"])}static get NESTED_TYPE_TOKENS(){return new Set(["array","list","lowcardinality","map","nullable","range",...S.STRUCT_TYPE_TOKENS])}static get ENUM_TYPE_TOKENS(){return new Set(["dynamic","enum","enum8","enum16"])}static get AGGREGATE_TYPE_TOKENS(){return new Set(["aggregatefunction","simpleaggregatefunction"])}static get TYPE_TOKENS(){return new Set(["bit","boolean","tinyint","utinyint","smallint","usmallint","int","uint","bigint","ubigint","bignum","int128","uint128","int256","uint256","mediumint","umediumint","fixedstring","float","double","udouble","char","nchar","varchar","nvarchar","bpchar","text","mediumtext","longtext","blob","mediumblob","longblob","binary","varbinary","json","jsonb","interval","tinyblob","tinytext","time","timetz","timeNs","timestamp","timestampS","timestampMs","timestampNs","timestamptz","timestampltz","timestampntz","datetime","datetime2","datetime64","smalldatetime","date","date32","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange","decimal","decimal32","decimal64","decimal128","decimal256","decfloat","udecimal","bigdecimal","uuid","geography","geographypoint","geometry","point","ring","linestring","multilinestring","polygon","multipolygon","hllsketch","hstore","pseudoType","super","serial","smallserial","bigserial","xml","year","userdefined","money","smallmoney","rowversion","image","variant","vector","void","object","objectIdentifier","inet","ipaddress","ipprefix","ipv4","ipv6","unknown","nothing","null","name","tdigest","dynamic",...S.ENUM_TYPE_TOKENS,...S.NESTED_TYPE_TOKENS,...S.AGGREGATE_TYPE_TOKENS])}static get SIGNED_TO_UNSIGNED_TYPE_TOKEN(){return{bigint:"ubigint",int:"uint",mediumint:"umediumint",smallint:"usmallint",tinyint:"utinyint",decimal:"udecimal",double:"udouble"}}static get SUBQUERY_PREDICATES(){return{any:Tt,all:cs,exists:Ys,some:Tt}}static get SUBQUERY_TOKENS(){return new Set(["select","with","from"])}static get RESERVED_TOKENS(){return new Set([...Object.values(Fr.SINGLE_TOKENS),"select"].filter(e=>e!=="identifier"))}static get DB_CREATABLES(){return new Set(["database","dictionary","fileFormat","model","namespace","schema","semanticView","sequence","sink","source","stage","storageIntegration","streamlit","table","tag","view","warehouse"])}static get CREATABLES(){return new Set(["column","constraint","foreignKey","function","index","procedure","trigger","type",...S.DB_CREATABLES])}static get TRIGGER_EVENTS(){return new Set(["insert","update","delete","truncate"])}static get ALTERABLES(){return new Set(["index","table","view","session"])}static get ID_VAR_TOKENS(){return(()=>{let e=new Set(["all","analyze","attach","var","anti","apply","asc","asof","autoIncrement","begin","bpchar","cache","case","collate","command","comment","commit","constraint","copy","cube","currentSchema","default","delete","desc","describe","detach","dictionary","div","end","execute","export","escape","false","first","file","filter","final","format","full","get","identifier","inout","is","isnull","interval","keep","kill","left","limit","load","lock","match","merge","natural","next","offset","operator","ordinality","over","overlaps","overwrite","partition","percent","pivot","pragma","put","range","recursive","references","refresh","rename","replace","right","rollup","row","rows","semi","set","settings","show","stream","streamlit","temporary","top","true","truncate","unique","unnest","unpivot","update","use","volatile","window",...S.ALTERABLES,...S.CREATABLES,...Object.keys(S.SUBQUERY_PREDICATES),...S.TYPE_TOKENS,...Object.keys(S.NO_PAREN_FUNCTIONS)]);return e.delete("union"),e})()}static get TABLE_ALIAS_TOKENS(){return new Set([...S.ID_VAR_TOKENS].filter(e=>!["anti","asof","full","left","lock","natural","right","semi","window"].includes(e)))}static get ALIAS_TOKENS(){return S.ID_VAR_TOKENS}static get COLON_PLACEHOLDER_TOKENS(){return S.ID_VAR_TOKENS}static get ARRAY_CONSTRUCTORS(){return{ARRAY:ue,LIST:KC}}static get COMMENT_TABLE_ALIAS_TOKENS(){return new Set([...S.TABLE_ALIAS_TOKENS].filter(e=>e!=="is"))}static get UPDATE_ALIAS_TOKENS(){return new Set([...S.TABLE_ALIAS_TOKENS].filter(e=>e!=="set"))}static get TRIM_TYPES(){return new Set(["leading".toUpperCase(),"trailing".toUpperCase(),"both".toUpperCase()])}static get TABLE_FAST_TERMINATORS(){return new Set(["comma","groupBy","having","join","limit","on","orderBy","rParen","semicolon","where",...S.SET_OPERATIONS,...S.JOIN_KINDS,...S.JOIN_METHODS,...S.JOIN_SIDES])}static get FUNC_TOKENS(){return new Set(["collate","command","currentDate","currentDatetime","currentSchema","currentTimestamp","currentTime","currentUser","currentCatalog","filter","first","format","get","glob","identifier","index","isnull","ilike","insert","like","localtime","localtimestamp","merge","next","offset","primaryKey","range","replace","rlike","row","sessionUser","unnest","var","left","right","sequence","date","datetime","table","timestamp","timestamptz","truncate","utcDate","utcTime","utcTimestamp","window","xor",...S.TYPE_TOKENS,...Object.keys(S.SUBQUERY_PREDICATES)])}static get CONJUNCTION(){return{and:Te}}static get ASSIGNMENT(){return{colonEq:ot}}static get DISJUNCTION(){return{or:pt}}static get EQUALITY(){return{eq:Me,neq:ft,nullsafeEq:Ks}}static get COMPARISON(){return{gt:je,gte:Je,lt:Fe,lte:nt}}static get BITWISE(){return{amp:rh,caret:JC,pipe:XC}}static get TERM(){return{dash:ye,plus:we,mod:jr,collate:MA}}static get FACTOR(){return{div:Un,lrArrow:QC,slash:wt,star:xs}}static get EXPONENT(){return{}}static get TIMES(){return new Set(["time","timetz"])}static get TIMESTAMPS(){return new Set(["timestamp","timestampntz","timestamptz","timestampltz",...S.TIMES])}static get SET_OPERATIONS(){return new Set(["union","intersect","except"])}static get JOIN_METHODS(){return new Set(["asof","natural","positional"])}static get JOIN_SIDES(){return new Set(["left","right","full"])}static get JOIN_KINDS(){return new Set(["anti","cross","inner","outer","semi","straightJoin"])}static get LAMBDAS(){return{arrow:function(e){return this.expression(ps,{this:this.replaceLambda(this.parseDisjunction(),e),expressions:e})},farrow:function(e){return this.expression(oh,{this:Z(e[0].name),expression:this.parseDisjunction()})}}}static get COLUMN_OPERATORS(){return{dot:void 0,dotcolon:function(e,t){return this.expression(mb,{this:e,to:t})},dcolon:function(e,t){return this.buildCast({strict:this._constructor.STRICT_CAST,this:e,to:t})},arrow:function(e,t){return this.expression(ms,{this:e,expression:this.dialect.toJsonPath(t),onlyJsonTypes:this._constructor.JSON_ARROWS_REQUIRE_JSON_TYPE})},darrow:function(e,t){return this.expression(bn,{this:e,expression:this.dialect.toJsonPath(t),onlyJsonTypes:this._constructor.JSON_ARROWS_REQUIRE_JSON_TYPE,scalarOnly:this._dialectConstructor.JSON_EXTRACT_SCALAR_SCALAR_ONLY})},hashArrow:function(e,t){return this.expression(Nh,{this:e,expression:t})},dhashArrow:function(e,t){return this.expression(Eb,{this:e,expression:t})},placeholder:function(e,t){return this.expression(gb,{this:e,expression:t})}}}static get CAST_COLUMN_OPERATORS(){return new Set(["dotcolon","dcolon"])}static get EXPRESSION_PARSERS(){return{cluster:function(){return this.parseSort(rr,"clusterBy")},column:function(){return this.parseColumn()},columnDef:function(){return this.parseColumnDef(this.parseColumn())},condition:function(){return this.parseDisjunction()},dataType:function(){return this.parseTypes({allowIdentifiers:!1,schema:!0})},expression:function(){return this.parseExpression()},from:function(){return this.parseFrom({joins:!0})},grantPrincipal:function(){return this.parseGrantPrincipal()},grantPrivilege:function(){return this.parseGrantPrivilege()},group:function(){return this.parseGroup()},having:function(){return this.parseHaving()},hint:function(){return this.parseHintBody()},identifier:function(){return this.parseIdVar()},join:function(){return this.parseJoin()},lambda:function(){return this.parseLambda()},lateral:function(){return this.parseLateral()},limit:function(){return this.parseLimit()},offset:function(){return this.parseOffset()},order:function(){return this.parseOrder()},ordered:function(){return this.parseOrdered()},properties:function(){return this.parseProperties()},partitionedByProperty:function(){return this.parsePartitionedBy()},qualify:function(){return this.parseQualify()},returning:function(){return this.parseReturning()},select:function(){return this.parseSelect()},sort:function(){return this.parseSort(zl,"sortBy")},table:function(){return this.parseTableParts()},tableAlias:function(){return this.parseTableAlias()},tuple:function(){return this.parseValue({values:!1})},whens:function(){return this.parseWhenMatched()},where:function(){return this.parseWhere()},window:function(){return this.parseNamedWindow()},with:function(){return this.parseWith()},JOIN_TYPE:n(function(){let{method:e,side:t,kind:s}=this.parseJoinParts();return new xe({method:e?.text,side:st(Yt,t?.text),kind:st(Yt,s?.text)})},"JOIN_TYPE")}}static get STATEMENT_PARSERS(){return{alter:function(){return this.parseAlter()},analyze:function(){return this.parseAnalyze()},begin:function(){return this.parseTransaction()},cache:function(){return this.parseCache()},comment:function(){return this.parseComment()},commit:function(){return this.parseCommitOrRollback()},copy:function(){return this.parseCopy()},create:function(){return this.parseCreate()},delete:function(){return this.parseDelete()},desc:function(){return this.parseDescribe()},describe:function(){return this.parseDescribe()},drop:function(){return this.parseDrop()},grant:function(){return this.parseGrant()},revoke:function(){return this.parseRevoke()},insert:function(){return this.parseInsert()},kill:function(){return this.parseKill()},load:function(){return this.parseLoad()},merge:function(){return this.parseMerge()},pivot:function(){return this.parseSimplifiedPivot()},pragma:function(){return this.expression(Ey,{this:this.parseExpression()})},refresh:function(){return this.parseRefresh()},rollback:function(){return this.parseCommitOrRollback()},set:function(){return this.parseSet()},truncate:function(){return this.parseTruncateTable()},uncache:function(){return this.parseUncache()},unpivot:function(){return this.parseSimplifiedPivot({isUnpivot:!0})},update:function(){return this.parseUpdate()},use:function(){return this.parseUse()},semicolon:()=>new bC({})}}static get UNARY_PARSERS(){return{plus:function(){return this.parseUnary()},not:function(){return this.expression(Le,{this:this.parseEquality()})},tilde:function(){return this.expression(lh,{this:this.parseUnary()})},dash:function(){return this.expression(bt,{this:this.parseUnary()})},pipeSlash:function(){return this.expression(Ch,{this:this.parseUnary()})},dpipeSlash:function(){return this.expression(Ah,{this:this.parseUnary()})}}}static get STRING_PARSERS(){return{heredocString:function(e){return this.expression(Mn,{token:e})},nationalString:function(e){return this.expression(vy,{token:e})},rawString:function(e){return this.expression(Mn,{token:e})},string:function(e){return this.expression(N,{token:e,isString:!0})},unicodeString:function(e){return this.expression(MC,{token:e,escape:this.matchTextSeq("UESCAPE")&&this.parseString()})}}}static get NUMERIC_PARSERS(){return{bitString:function(e){return this.expression(LC,{token:e})},byteString:function(e){return this.expression(wC,{token:e,isBytes:this._dialectConstructor.BYTE_STRING_IS_BYTES_TYPE||void 0})},hexString:function(e){return this.expression(fu,{token:e,isInteger:this._dialectConstructor.HEX_STRING_IS_INTEGER_TYPE||void 0})},number:function(e){return this.expression(N,{token:e,isString:!1})}}}static get PRIMARY_PARSERS(){return{...S.STRING_PARSERS,...S.NUMERIC_PARSERS,introducer:function(e){return this.parseIntroducer(e)},null:function(e){return this.expression(Pt,{})},true:function(e){return this.expression(at,{this:!0})},false:function(e){return this.expression(at,{this:!1})},sessionParameter:function(e){return this.parseSessionParameter()},star:function(e){return this.parseStarOps()}}}static get PLACEHOLDER_PARSERS(){return{placeholder:function(){return this.expression(ar)},parameter:function(){return this.parseParameter()},colon:function(){return this.matchSet(this._constructor.COLON_PLACEHOLDER_TOKENS)?this.expression(ar,{this:this.prev?.text}):void 0}}}static get RANGE_PARSERS(){return{atGt:Jt(Fn),between:function(e){return this.parseBetween(e)},glob:Jt(LA),ilike:Jt(Gs),in:function(e){return this.parseIn(e)},irlike:Jt(Tb),is:function(e){return this.parseIs(e)},like:Jt(Qt),ltAt:Jt(Fn,{reverseArgs:!0}),overlaps:Jt(zC),rlike:Jt(Ga),similarTo:Jt(ZC),for:function(e){return this.parseComprehension(e)},qmarkAmp:Jt(Oh),qmarkPipe:Jt(Rh),hashDash:Jt(mh),adjacent:Jt(ph),operator:function(e){return this.parseOperator(e)},ampLt:Jt(nh),ampGt:Jt(ah)}}static get PIPE_SYNTAX_TRANSFORM_PARSERS(){return{AGGREGATE:n(function(e){return this.parsePipeSyntaxAggregate(e)},"AGGREGATE"),AS:n(function(e){return this.buildPipeCte({query:e,expressions:[new Ne({})],aliasCte:this.parseTableAlias()})},"AS"),EXTEND:n(function(e){return this.parsePipeSyntaxExtend(e)},"EXTEND"),LIMIT:n(function(e){return this.parsePipeSyntaxLimit(e)},"LIMIT"),"ORDER BY":n(function(e){return e.orderBy(this.parseOrder(),{append:!1,copy:!1})},"ORDER BY"),PIVOT:n(function(e){return this.parsePipeSyntaxPivot(e)},"PIVOT"),SELECT:n(function(e){return this.parsePipeSyntaxSelect(e)},"SELECT"),TABLESAMPLE:n(function(e){return this.parsePipeSyntaxTablesample(e)},"TABLESAMPLE"),UNPIVOT:n(function(e){return this.parsePipeSyntaxPivot(e)},"UNPIVOT"),WHERE:n(function(e){return e.where(this.parseWhere(),{copy:!1})},"WHERE")}}static get PROPERTY_PARSERS(){return{ALLOWED_VALUES:n(function(){return this.expression(Vn,{expressions:this.parseCsv(this.parsePrimary.bind(this))})},"ALLOWED_VALUES"),ALGORITHM:n(function(){return this.parsePropertyAssignment(Wn)},"ALGORITHM"),AUTO:n(function(){return this.parseAutoProperty()},"AUTO"),AUTO_INCREMENT:n(function(){return this.parsePropertyAssignment(jn)},"AUTO_INCREMENT"),BACKUP:n(function(){return this.expression(Jn,{this:this.parseVar({anyToken:!0})})},"BACKUP"),BLOCKCOMPRESSION:n(function(){return this.parseBlockCompression()},"BLOCKCOMPRESSION"),CHARSET:n(function(e){return this.parseCharacterSet(e)},"CHARSET"),"CHARACTER SET":n(function(e){return this.parseCharacterSet(e)},"CHARACTER SET"),CHECKSUM:n(function(){return this.parseChecksum()},"CHECKSUM"),"CLUSTER BY":n(function(){return this.parseCluster()},"CLUSTER BY"),CLUSTERED:n(function(){return this.parseClusteredBy()},"CLUSTERED"),COLLATE:n(function(...e){return this.parsePropertyAssignment(zn,e[0])},"COLLATE"),COMMENT:n(function(){return this.parsePropertyAssignment(Ia)},"COMMENT"),CONTAINS:n(function(){return this.parseContainsProperty()},"CONTAINS"),COPY:n(function(){return this.parseCopyProperty()},"COPY"),DATABLOCKSIZE:n(function(e){return this.parseDataBlocksize(e)},"DATABLOCKSIZE"),DATA_DELETION:n(function(){return this.parseDataDeletionProperty()},"DATA_DELETION"),DEFINER:n(function(){return this.parseDefiner()},"DEFINER"),DETERMINISTIC:n(function(){return this.expression(Fs,{this:N.string("IMMUTABLE")})},"DETERMINISTIC"),DISTRIBUTED:n(function(){return this.parseDistributedProperty()},"DISTRIBUTED"),DUPLICATE:n(function(){return this.parseCompositeKeyProperty(Bu)},"DUPLICATE"),DYNAMIC:n(function(){return this.expression(Aa,{})},"DYNAMIC"),DISTKEY:n(function(){return this.parseDistkey()},"DISTKEY"),DISTSTYLE:n(function(){return this.parsePropertyAssignment(ta)},"DISTSTYLE"),EMPTY:n(function(){return this.expression(da,{})},"EMPTY"),ENGINE:n(function(){return this.parsePropertyAssignment(sa)},"ENGINE"),ENVIRONMENT:n(function(){return this.expression(ga,{expressions:this.parseWrappedCsv(this.parseAssignment.bind(this))})},"ENVIRONMENT"),HANDLER:n(function(){return this.parsePropertyAssignment(ra)},"HANDLER"),EXECUTE:n(function(){return this.parsePropertyAssignment(nr)},"EXECUTE"),EXTERNAL:n(function(){return this.expression(oa,{})},"EXTERNAL"),FALLBACK:n(function(e){return this.parseFallback(e)},"FALLBACK"),FORMAT:n(function(){return this.parsePropertyAssignment(ir)},"FORMAT"),FREESPACE:n(function(){return this.parseFreespace()},"FREESPACE"),GLOBAL:n(function(){return this.expression(ca,{})},"GLOBAL"),HEAP:n(function(){return this.expression(na,{})},"HEAP"),ICEBERG:n(function(){return this.expression(pa,{})},"ICEBERG"),IMMUTABLE:n(function(){return this.expression(Fs,{this:N.string("IMMUTABLE")})},"IMMUTABLE"),INHERITS:n(function(){return this.expression(la,{expressions:this.parseWrappedCsv(this.parseTable.bind(this))})},"INHERITS"),INPUT:n(function(){return this.expression(ua,{this:this.parseSchema()})},"INPUT"),JOURNAL:n(function(e){return this.parseJournal(e)},"JOURNAL"),LANGUAGE:n(function(){return this.parsePropertyAssignment(Qr)},"LANGUAGE"),LAYOUT:n(function(){return this.parseDictProperty({this:"LAYOUT"})},"LAYOUT"),LIFETIME:n(function(){return this.parseDictRange({this:"LIFETIME"})},"LIFETIME"),LIKE:n(function(){return this.parseCreateLike()},"LIKE"),LOCATION:n(function(){return this.parsePropertyAssignment(Zr)},"LOCATION"),LOCK:n(function(){return this.parseLocking()},"LOCK"),LOCKING:n(function(){return this.parseLocking()},"LOCKING"),LOG:n(function(e){return this.parseLog(e)},"LOG"),MATERIALIZED:n(function(){return this.expression(xa,{})},"MATERIALIZED"),MERGEBLOCKRATIO:n(function(e){return this.parseMergeBlockRatio(e)},"MERGEBLOCKRATIO"),MODIFIES:n(function(){return this.parseModifiesProperty()},"MODIFIES"),MULTISET:n(function(){return this.expression(_r,{multi:!0})},"MULTISET"),NO:n(function(){return this.parseNoProperty()},"NO"),ON:n(function(){return this.parseOnProperty()},"ON"),"ORDER BY":n(function(){return this.parseOrder({skipOrderToken:!0})},"ORDER BY"),OUTPUT:n(function(){return this.expression(ha,{this:this.parseSchema()})},"OUTPUT"),PARTITION:n(function(){return this.parsePartitionedOf()},"PARTITION"),"PARTITION BY":n(function(){return this.parsePartitionedBy()},"PARTITION BY"),"PARTITIONED BY":n(function(){return this.parsePartitionedBy()},"PARTITIONED BY"),PARTITIONED_BY:n(function(){return this.parsePartitionedBy()},"PARTITIONED_BY"),"PRIMARY KEY":n(function(){return this.parsePrimaryKey({inProps:!0})},"PRIMARY KEY"),RANGE:n(function(){return this.parseDictRange({this:"RANGE"})},"RANGE"),READS:n(function(){return this.parseReadsProperty()},"READS"),REMOTE:n(function(){return this.parseRemoteWithConnection()},"REMOTE"),RETURNS:n(function(){return this.parseReturns()},"RETURNS"),STRICT:n(function(){return this.expression(Oa,{})},"STRICT"),STREAMING:n(function(){return this.expression(Sa,{})},"STREAMING"),ROW:n(function(){return this.parseRow()},"ROW"),ROW_FORMAT:n(function(){return this.parsePropertyAssignment(ma)},"ROW_FORMAT"),SAMPLE:n(function(){return this.expression(Na,{this:this.matchTextSeq("BY")&&this.parseBitwise()})},"SAMPLE"),SECURE:n(function(){return this.expression(La,{})},"SECURE"),SECURITY:n(function(){return this.parseSqlSecurity()},"SECURITY"),"SQL SECURITY":n(function(){return this.parseSqlSecurity()},"SQL SECURITY"),SET:n(function(){return this.expression(_r,{multi:!1})},"SET"),SETTINGS:n(function(){return this.parseSettingsProperty()},"SETTINGS"),SHARING:n(function(){return this.parsePropertyAssignment(ya)},"SHARING"),SORTKEY:n(function(){return this.parseSortkey()},"SORTKEY"),SOURCE:n(function(){return this.parseDictProperty({this:"SOURCE"})},"SOURCE"),STABLE:n(function(){return this.expression(Fs,{this:N.string("STABLE")})},"STABLE"),STORED:n(function(){return this.parseStored()},"STORED"),SYSTEM_VERSIONING:n(function(){return this.parseSystemVersioningProperty()},"SYSTEM_VERSIONING"),TBLPROPERTIES:n(function(){return this.parseWrappedProperties()},"TBLPROPERTIES"),TEMP:n(function(){return this.expression($s,{})},"TEMP"),TEMPORARY:n(function(){return this.expression($s,{})},"TEMPORARY"),TO:n(function(){return this.parseToTable()},"TO"),TRANSIENT:n(function(){return this.expression(Ma,{})},"TRANSIENT"),TRANSFORM:n(function(){return this.expression(wa,{expressions:this.parseWrappedCsv(this.parseExpression.bind(this))})},"TRANSFORM"),TTL:n(function(){return this.parseTtl()},"TTL"),USING:n(function(){return this.parsePropertyAssignment(ir)},"USING"),UNLOGGED:n(function(){return this.expression(ka,{})},"UNLOGGED"),VOLATILE:n(function(){return this.parseVolatileProperty()},"VOLATILE"),WITH:n(function(){return this.parseWithProperty()},"WITH")}}static get CONSTRAINT_PARSERS(){return{AUTOINCREMENT:n(function(){return this.parseAutoIncrement()},"AUTOINCREMENT"),AUTO_INCREMENT:n(function(){return this.parseAutoIncrement()},"AUTO_INCREMENT"),CASESPECIFIC:n(function(){return this.expression(kn,{not:!1})},"CASESPECIFIC"),"CHARACTER SET":n(function(){return this.expression(xu,{this:this.parseVarOrString()})},"CHARACTER SET"),CHECK:n(function(){return this.parseCheckConstraint()},"CHECK"),COLLATE:n(function(){return this.expression(Su,{this:this.parseIdentifier()||this.parseColumn()})},"COLLATE"),COMMENT:n(function(){return this.expression(Ru,{this:this.parseString()})},"COMMENT"),COMPRESS:n(function(){return this.parseCompress()},"COMPRESS"),CLUSTERED:n(function(){return this.expression(Tu,{this:this.parseWrappedCsv(()=>this.parseOrdered())})},"CLUSTERED"),NONCLUSTERED:n(function(){return this.expression(bu,{this:this.parseWrappedCsv(()=>this.parseOrdered())})},"NONCLUSTERED"),DEFAULT:n(function(){return this.expression(mu,{this:this.parseBitwise()})},"DEFAULT"),ENCODE:n(function(){return this.expression(Nu,{this:this.parseVar()})},"ENCODE"),EPHEMERAL:n(function(){return this.expression(yu,{this:this.parseBitwise()})},"EPHEMERAL"),EXCLUDE:n(function(){return this.expression(Iu,{this:this.parseIndexParams()})},"EXCLUDE"),"FOREIGN KEY":n(function(){return this.parseForeignKey()},"FOREIGN KEY"),FORMAT:n(function(){return this.expression(Ou,{this:this.parseVarOrString()})},"FORMAT"),GENERATED:n(function(){return this.parseGeneratedAsIdentity()},"GENERATED"),IDENTITY:n(function(){return this.parseAutoIncrement()},"IDENTITY"),INLINE:n(function(){return this.parseInline()},"INLINE"),LIKE:n(function(){return this.parseCreateLike()},"LIKE"),NOT:n(function(){return this.parseNotConstraint()},"NOT"),NULL:n(function(){return this.expression(PA,{allowNull:!0})},"NULL"),ON:n(function(){return this.match("update")&&this.expression(Lu,{this:this.parseFunction()})||this.expression(Vr,{this:this.parseIdVar()})},"ON"),PATH:n(function(){return this.expression(Du,{this:this.parseString()})},"PATH"),PERIOD:n(function(){return this.parsePeriodForSystemTime()},"PERIOD"),"PRIMARY KEY":n(function(){return this.parsePrimaryKey()},"PRIMARY KEY"),REFERENCES:n(function(){return this.parseReferences({match:!1})},"REFERENCES"),TITLE:n(function(){return this.expression(wu,{this:this.parseVarOrString()})},"TITLE"),TTL:n(function(){return this.expression(Pn,{expressions:[this.parseBitwise()]})},"TTL"),UNIQUE:n(function(){return this.parseUnique()},"UNIQUE"),UPPERCASE:n(function(){return this.expression(ku)},"UPPERCASE"),WITH:n(function(){return this.expression(He,{expressions:this.parseWrappedProperties()})},"WITH"),BUCKET:n(function(){return this.parsePartitionedByBucketOrTruncate()},"BUCKET"),TRUNCATE:n(function(){return this.parsePartitionedByBucketOrTruncate()},"TRUNCATE")}}static get ALTER_PARSERS(){return{ADD:n(function(){return this.parseAlterTableAdd()},"ADD"),AS:n(function(){return this.parseSelect()},"AS"),ALTER:n(function(){return this.parseAlterTableAlter()},"ALTER"),"CLUSTER BY":n(function(){return this.parseCluster({wrapped:!0})},"CLUSTER BY"),DELETE:n(function(){return this.expression(Gr,{where:this.parseWhere()})},"DELETE"),DROP:n(function(){return this.parseAlterTableDrop()},"DROP"),RENAME:n(function(){return this.parseAlterTableRename()},"RENAME"),SET:n(function(){return this.parseAlterTableSet()},"SET"),SWAP:n(function(){return this.expression(Kl,{this:this.match("with")&&this.parseTable({schema:!0})})},"SWAP")}}static get NO_PAREN_FUNCTION_PARSERS(){return{ANY:n(function(){return this.expression(Tt,{this:this.parseBitwise()})},"ANY"),CASE:n(function(){return this.parseCase()},"CASE"),CONNECT_BY_ROOT:n(function(){return this.expression(Eh,{this:this.parseColumn()})},"CONNECT_BY_ROOT"),IF:n(function(){return this.parseIf()},"IF")}}static get INVALID_FUNC_NAME_TOKENS(){return new Set(["identifier","string"])}static get KEY_VALUE_DEFINITIONS(){return new Set([Re,Me,ot,On])}static get FUNCTION_PARSERS(){return{...Object.fromEntries(DA.sqlNames().map(e=>[e,function(){return this.parseMaxMinBy(DA)}])),...Object.fromEntries(qA.sqlNames().map(e=>[e,function(){return this.parseMaxMinBy(qA)}])),CAST:n(function(){return this.parseCast({strict:this._constructor.STRICT_CAST})},"CAST"),CEIL:n(function(){return this.parseCeilFloor(ti)},"CEIL"),CONVERT:n(function(){return this.parseConvert({strict:this._constructor.STRICT_CAST})},"CONVERT"),CHAR:n(function(){return this.parseChar()},"CHAR"),CHR:n(function(){return this.parseChar()},"CHR"),DECODE:n(function(){return this.parseDecode()},"DECODE"),EXTRACT:n(function(){return this.parseExtract()},"EXTRACT"),FLOOR:n(function(){return this.parseCeilFloor(xh)},"FLOOR"),GAP_FILL:n(function(){return this.parseGapFill()},"GAP_FILL"),INITCAP:n(function(){return this.parseInitcap()},"INITCAP"),JSON_OBJECT:n(function(){return this.parseJsonObject()},"JSON_OBJECT"),JSON_OBJECTAGG:n(function(){return this.parseJsonObject({agg:!0})},"JSON_OBJECTAGG"),JSON_TABLE:n(function(){return this.parseJsonTable()},"JSON_TABLE"),MATCH:n(function(){return this.parseMatchAgainst()},"MATCH"),NORMALIZE:n(function(){return this.parseNormalize()},"NORMALIZE"),OPENJSON:n(function(){return this.parseOpenJson()},"OPENJSON"),OVERLAY:n(function(){return this.parseOverlay()},"OVERLAY"),POSITION:n(function(){return this.parsePosition()},"POSITION"),SAFE_CAST:n(function(){return this.parseCast({strict:!1,safe:!0})},"SAFE_CAST"),STRING_AGG:n(function(){return this.parseStringAgg()},"STRING_AGG"),SUBSTRING:n(function(){return this.parseSubstring()},"SUBSTRING"),TRIM:n(function(){return this.parseTrim()},"TRIM"),TRY_CAST:n(function(){return this.parseCast({strict:!1,safe:!0})},"TRY_CAST"),TRY_CONVERT:n(function(){return this.parseConvert({strict:!1,safe:!0})},"TRY_CONVERT"),XMLELEMENT:n(function(){return this.parseXmlElement()},"XMLELEMENT"),XMLTABLE:n(function(){return this.parseXmlTable()},"XMLTABLE")}}static get QUERY_MODIFIER_PARSERS(){return{matchRecognize:function(){return["match",this.parseMatchRecognize()]},prewhere:function(){return["prewhere",this.parsePrewhere()]},where:function(){return["where",this.parseWhere()]},groupBy:function(){return["group",this.parseGroup()]},having:function(){return["having",this.parseHaving()]},qualify:function(){return["qualify",this.parseQualify()]},window:function(){return["windows",this.parseWindowClause()]},orderBy:function(){return["order",this.parseOrder()]},limit:function(){return["limit",this.parseLimit()]},fetch:function(){return["limit",this.parseLimit()]},offset:function(){return["offset",this.parseOffset()]},for:function(){return["locks",this.parseLocks()]},lock:function(){return["locks",this.parseLocks()]},tableSample:function(){return["sample",this.parseTableSample({asModifier:!0})]},using:function(){return["sample",this.parseTableSample({asModifier:!0})]},clusterBy:function(){return["cluster",this.parseSort(rr,"clusterBy")]},distributeBy:function(){return["distribute",this.parseSort($C,"distributeBy")]},sortBy:function(){return["sort",this.parseSort(zl,"sortBy")]},connectBy:function(){return["connect",this.parseConnect({skipStartToken:!0})]},startWith:function(){return["connect",this.parseConnect()]}}}static get QUERY_MODIFIER_TOKENS(){return new Set(Object.keys(S.QUERY_MODIFIER_PARSERS))}static get TYPE_LITERAL_PARSERS(){return{json:function(e,t){return this.expression(ai,{this:e})}}}static get TYPE_CONVERTERS(){return{}}static get DDL_SELECT_TOKENS(){return new Set(["select","with","lParen"])}static get PRE_VOLATILE_TOKENS(){return new Set(["create","replace","unique"])}static get OPTYPE_FOLLOW_TOKENS(){return new Set(["comma","rParen"])}static get TABLE_INDEX_HINT_TOKENS(){return new Set(["force","ignore","use"])}static get WINDOW_ALIAS_TOKENS(){return(()=>{let e=new Set(S.ID_VAR_TOKENS);return e.delete("range"),e.delete("rows"),e})()}static get WINDOW_BEFORE_PAREN_TOKENS(){return new Set(["over"])}static get JSON_KEY_VALUE_SEPARATOR_TOKENS(){return new Set(["colon","comma","is"])}static get FETCH_TOKENS(){return(()=>{let e=new Set(S.ID_VAR_TOKENS);return e.delete("row"),e.delete("rows"),e.delete("percent"),e})()}static get ADD_CONSTRAINT_TOKENS(){return new Set(["constraint","foreignKey","index","key","primaryKey","unique"])}static get DISTINCT_TOKENS(){return new Set(["distinct"])}static get UNNEST_OFFSET_ALIAS_TOKENS(){return(()=>{let e=new Set(S.TABLE_ALIAS_TOKENS);for(let t of S.SET_OPERATIONS)e.delete(t);return e})()}static get SELECT_START_TOKENS(){return new Set(["lParen","with","select"])}static get PRIVILEGE_FOLLOW_TOKENS(){return new Set(["on","comma","lParen"])}static get AMBIGUOUS_ALIAS_TOKENS(){return["limit","offset"]}static get MODIFIABLES(){return[ee,_,_l,tr]}reset(){this.sql="",this.errors=[],this.tokens=[],this.index=0,this.curr=void 0,this.next=void 0,this.prev=void 0,this.prevComments=void 0,this.pipeCteCounter=0,this._chunks=[],this._chunkIndex=0}parse(e,t){return this._parse({parseMethod:n(function(){return this.parseStatement()},"parseMethod"),rawTokens:e,sql:t})}_parse(e){let{parseMethod:t,rawTokens:s,sql:r}=e;this.reset(),this.sql=r||"";let i=s.length,o=[[]];for(let p=0;p<s.length;p++){let u=s[p];u.tokenType==="semicolon"?(u.comments.length&&o.push([u]),p<i-1&&o.push([])):o[o.length-1].push(u)}return this._chunks=o,this._chunkIndex=0,this.parseBatchStatements(p=>t.call(p),{sepFirstStatement:!1})}parseIntoTypes(e,t,s){let r=[],i=J(e);for(let p of i){let u=typeof p=="string"?this._constructor.EXPRESSION_PARSERS[p]??this._constructor.EXPRESSION_PARSERS[p.charAt(0).toLowerCase()+p.slice(1)]:this._constructor.EXPRESSION_PARSERS[p.key];if(!u)throw new TypeError(`No parser registered for ${p}`);try{return this._parse({parseMethod:u,rawTokens:t,sql:s})}catch(h){if(h instanceof Ke)h.errors[0].intoExpression=typeof p=="string"?p:p.name,r.push(h);else throw h}}let c=`[${J(e).map(p=>typeof p=="string"?p:p.name).join(", ")}]`;throw new Ke(`Failed to parse '${s||t}' into ${c}`,Wk(r))}findSql(e,t){return this.sql.slice(e?.start??0,(t?.end??0)+1)}isConnected(){return!!(this.prev&&this.curr&&(this.prev.end??0)+1===(this.curr.start??0))}advance(e=1){this.index+=e,this.curr=D(this.tokens,this.index),this.next=D(this.tokens,this.index+1),0<this.index?(this.prev=this.tokens[this.index-1],this.prevComments=this.prev.comments):(this.prev=void 0,this.prevComments=void 0)}retreat(e){e!==this.index&&this.advance(e-this.index)}warnUnsupported(){if(this.tokens.length<=1)return;let e=this.findSql(this.tokens[0],this.tokens[this.tokens.length-1]).slice(0,this.errorMessageContext);console.warn(`'${e}' contains unsupported syntax. Falling back to parsing as a 'Command'.`)}match(e,t={}){let{advance:s=!0,expression:r}=t;return this.curr?.tokenType===e?(s&&this.advance(),this.addComments(r),!0):!1}tryParse(e,t={}){let{retreat:s=!1}=t,r=this.index,i=this.errorLevel;this.errorLevel=3;let o;try{o=e()}catch(c){if(c instanceof Ke)o=void 0;else throw c}finally{(!o||s)&&this.retreat(r),this.errorLevel=i}return o}parseParen(){if(!this.match("lParen"))return;let e=this.prevComments,t=this.parseSelect(),s;t?s=[t]:s=this.parseExpressions();let r=D(s,0);return!r&&this.match("rParen",{advance:!1})?r=this.expression(Ze,{}):r&&Ls.some(i=>r instanceof i)?r=this.parseSubquery(r,{parseAlias:!1}):r instanceof he||r instanceof tr?r=this.parseSubquery(this.parseQueryModifiers(this.parseSetOperations(r)),{parseAlias:!1}):1<s.length||this.prev?.tokenType==="comma"?r=this.expression(Ze,{expressions:s}):r=this.expression(Se,{this:r}),r&&e&&r.addComments(e),this.matchRParen(r),r instanceof Se&&r.args.this instanceof q?this.parseWindow(r):r}parseDrop(e={}){let{exists:t}=e,s=this.prev,r=this.match("temporary")||void 0,i=this.matchTextSeq("MATERIALIZED")||void 0,o=this.matchTextSeq("ICEBERG")||void 0,c=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev?.text.toUpperCase();if(!c||o&&c&&c!=="TABLE")return this.parseAsCommand(s);let p=this.matchTextSeq("CONCURRENTLY")||void 0,u=t||this.parseExists(),h;c==="COLUMN"?h=this.parseColumn():h=this.parseTableParts({schema:!0,isDbReference:c==="SCHEMA"});let g=this.match("on")?this.parseOnProperty():void 0,f;this.match("lParen",{advance:!1})&&(f=this.parseWrappedCsv(()=>this.parseTypes()));let x=(this.matchTexts(["CASCADE","RESTRICT"])||void 0)&&this.prev?.text.toUpperCase();return this.expression(tu,{exists:u,this:h,expressions:f,kind:st(AM,this._dialectConstructor.CREATABLE_KIND_MAPPING[c]||c)??(this._dialectConstructor.CREATABLE_KIND_MAPPING[c]||c),temporary:r,materialized:i,cascade:x==="CASCADE",restrict:x==="RESTRICT",constraints:this.matchTextSeq("CONSTRAINTS"),purge:this.matchTextSeq("PURGE"),cluster:g,concurrently:p,sync:this.matchTextSeq("SYNC"),iceberg:o})}parseExists(e={}){let{not:t}=e;return this.matchTextSeq("IF")&&(!t||this.match("not"))&&this.match("exists")?!0:void 0}parseCreate(){let e=this.prev,t=e?.tokenType==="replace"||this.matchPair("or","replace")||this.matchPair("or","alter"),s=this.matchPair("or","refresh")||void 0,r=this.match("unique")||void 0,i;this.matchTextSeq(["CLUSTERED","COLUMNSTORE"])?i=!0:(this.matchTextSeq(["NONCLUSTERED","COLUMNSTORE"])||this.matchTextSeq("COLUMNSTORE"))&&(i=!1),this.matchPair("table","function",{advance:!1})&&this.advance();let o,c=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev;if(!c&&(o=this.parseProperties(),c=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev,!o||!c))return this.parseAsCommand(e);let p=this.matchTextSeq("CONCURRENTLY")||void 0,u=this.parseExists({not:!0}),h,g,f,x,T,y,C=n(k=>{o&&k?o.args.expressions?.push(...k.args.expressions??[]):k&&(o=k)},"extendProps");if(c.tokenType==="function"||c.tokenType==="procedure"){if(h=this.parseUserDefinedFunction({kind:c.tokenType}),C(this.parseProperties()),g=this.match("alias")&&this.parseHeredoc()||void 0,C(this.parseProperties()),!g)if(this.match("command"))g=this.parseAsCommand(this.prev);else{T=this.match("begin")||void 0;let k=this.matchTextSeq("RETURN")||void 0;this.match("string",{advance:!1})?(g=this.parseString(),C(this.parseProperties())):g=c.tokenType==="function"?this.parseUserDefinedFunctionExpression():this.parseBlock(),k&&(g=this.expression(ou,{this:g}))}}else if(c.tokenType==="constraint"&&this.match("trigger")||c.tokenType==="trigger"){let k=c.tokenType==="constraint";k&&(c=this.prev);let B=this.parseIdVar();if(!B)return this.parseAsCommand(e);let Q=this.parseVarFromOptions(this._constructor.TRIGGER_TIMING,{raiseUnmatched:!1})?.args.this;if(!Q)return this.parseAsCommand(e);let ne=this.parseTriggerEvents();this.match("on")||this.raiseError("Expected ON in trigger definition");let H=this.parseTableParts(),Pe=this.match("from")?this.parseTableParts():void 0,[me,Ot]=this.parseTriggerDeferrable(),gt=this.parseTriggerReferencing(),Cs=this.parseTriggerForEach(),Xe=this.matchTextSeq("WHEN")&&this.parseWrapped(()=>this.parseDisjunction(),{optional:!0}),mt=this.parseTriggerExecute();if(mt===void 0)return this.parseAsCommand(e);let Zt=this.expression(Gn,{table:H,timing:Q,events:ne,execute:mt,constraint:k,referencedTable:Pe,deferrable:me,initially:Ot,referencing:gt,forEach:Cs,when:Xe||void 0});h=B;let ce=new He({expressions:Zt?[Zt]:[]});C(ce)}else if(c.tokenType==="index"){let k,B;this.match("on")?(k=void 0,B=!0):(k=this.parseIdVar(),B=!1),h=this.parseIndex({index:k,anonymous:B})}else if(c.tokenType==="type"){if(h=this.parseTableParts({schema:!0}),!h||!this.match("alias"))return this.parseAsCommand(e);if(this.match("enum"))g=new m({this:"enum",expressions:this.parseWrappedCsv(this.parseString.bind(this))});else if(this.match("lParen",{advance:!1}))g=this.parseSchema();else return this.parseAsCommand(e)}else if(this._constructor.DB_CREATABLES.has(c.tokenType)){let k=this.parseTableParts({schema:!0,isDbReference:c.tokenType==="schema"});this.match("comma"),C(this.parseProperties({before:!0})),h=this.parseSchema({this:k}),C(this.parseProperties());let B=this.match("alias")||void 0;if(this.matchSet(this._constructor.DDL_SELECT_TOKENS,{advance:!1})||C(this.parseProperties()),c.tokenType==="sequence"){g=this.parseTypes();let Q=this.parseProperties();if(Q){let ne=new Br({}),H=[];for(let Pe of Q.args.expressions??[])if(Pe instanceof Br){for(let[me,Ot]of Object.entries(Pe.args))me==="options"?H.push(...Ot):ne.setArgKey(me,Ot);Pe.pop()}0<H.length&&ne.setArgKey("options",H),Q.args.expressions?.push(ne),C(Q)}}else g=this.parseDdlSelect(),!g&&B&&(g=this.tryParse(()=>this.parseTableParts()));if(c.tokenType==="table")for(C(this.parseProperties()),f=[];;){let Q=this.parseIndex();if(C(this.parseProperties()),Q)this.match("comma"),f.push(Q);else break}else c.tokenType==="view"?this.matchTextSeq(["WITH","NO","SCHEMA","BINDING"])&&(x=!0):(c.tokenType==="sink"||c.tokenType==="source")&&C(this.parseProperties());let j=this.matchTextSeq("SHALLOW")||void 0;if(this.matchTexts(this._constructor.CLONE_KEYWORDS)){let Q=this.prev?.text.toLowerCase()==="copy";y=this.expression(uy,{this:this.parseTable({schema:!0}),shallow:j,copy:Q})}}if(this.curr&&!this.matchSet(new Set(["rParen","comma"]),{advance:!1}))return this.parseAsCommand(e);let I=c.text.toUpperCase(),b=this._dialectConstructor.CREATABLE_KIND_MAPPING[I]||I;return this.expression(ss,{this:h,kind:st(eA,b)??b,replace:t,refresh:s,unique:r,expression:g,exists:u,properties:o,indexes:f,noSchemaBinding:x,begin:T,clone:y,concurrently:p,clustered:i})}parseCommand(){return this.warnUnsupported(),this.expression($r,{comments:this.prevComments,this:this.prev?.text.toUpperCase(),expression:this.parseString()})}parseSequenceProperties(){let e=new Br({}),t=[],s=this.index;for(;this.curr;)if(this.match("comma"),this.matchTextSeq("INCREMENT"))this.matchTextSeq("BY"),this.matchTextSeq("="),e.setArgKey("increment",this.parseTerm());else if(this.matchTextSeq("MINVALUE"))e.setArgKey("minvalue",this.parseTerm());else if(this.matchTextSeq("MAXVALUE"))e.setArgKey("maxvalue",this.parseTerm());else if(this.match("startWith")||this.matchTextSeq("START"))this.matchTextSeq("="),e.setArgKey("start",this.parseTerm());else if(this.matchTextSeq("CACHE"))e.setArgKey("cache",this.parseNumber()||!0);else if(this.matchTextSeq(["OWNED","BY"]))e.setArgKey("owned",this.matchTextSeq("NONE")?void 0:this.parseColumn());else{let r=this.parseVarFromOptions(this._constructor.CREATE_SEQUENCE,{raiseUnmatched:!1});if(r)t.push(r);else break}return e.setArgKey("options",0<t.length?t:void 0),this.index===s?void 0:e}parseTriggerEvents(){let e=[];for(;;){let t=this.matchSet(this._constructor.TRIGGER_EVENTS)&&this.prev?.text.toUpperCase();t||this.raiseError("Expected trigger event (INSERT, UPDATE, DELETE, TRUNCATE)");let s=t==="UPDATE"&&this.matchTextSeq("OF")?this.parseCsv(()=>this.parseColumn()):void 0;if(e.push(this.expression(cy,{this:t,columns:s})),!this.match("or"))break}return e}parseTriggerDeferrable(){let t=this.parseVarFromOptions(this._constructor.TRIGGER_DEFERRABLE,{raiseUnmatched:!1})?.args.this,s;return t&&this.matchTextSeq("INITIALLY")&&(s=this.parseVarFromOptions(this._constructor.TRIGGER_INITIALLY_VALUE,{raiseUnmatched:!1})?.args.this,s||this.raiseError("Expected IMMEDIATE or DEFERRED after INITIALLY")),[t,s]}parseTriggerReferencingClause(e){if(this.matchTextSeq(e))return this.matchTextSeq("TABLE")||this.raiseError(`Expected TABLE after ${e} in REFERENCING clause`),this.matchTextSeq("AS"),this.parseIdVar()}parseTriggerReferencing(){if(!this.matchTextSeq("REFERENCING"))return;let e,t;for(;;){let s=this.parseTriggerReferencingClause("OLD");if(s)e!==void 0&&this.raiseError("Duplicate OLD clause in REFERENCING"),e=s;else{let r=this.parseTriggerReferencingClause("NEW");if(r)t!==void 0&&this.raiseError("Duplicate NEW clause in REFERENCING"),t=r;else break}}return e===void 0&&t===void 0&&this.raiseError("REFERENCING clause requires at least OLD TABLE or NEW TABLE"),this.expression(py,{old:e,new:t})}parseTriggerForEach(){if(!this.match("for"))return;this.matchTextSeq("EACH");let e=this.parseVarFromOptions(this._constructor.TRIGGER_FOR_EACH,{raiseUnmatched:!1});if(e)return e.args.this;this.raiseError("Expected ROW or STATEMENT after FOR")}parseTriggerExecute(){if(!this.match("execute"))return;this.matchSet(new Set(["function","procedure"]))||this.raiseError("Expected FUNCTION or PROCEDURE after EXECUTE");let e=this.parseFunction({anonymous:!0,optionalParens:!1});return this.expression(oy,{this:e})}parsePropertyBefore(){this.match("comma");let e={no:this.matchTextSeq("NO")||!1,dual:this.matchTextSeq("DUAL")||!1,before:this.matchTextSeq("BEFORE")||!1,default:this.matchTextSeq("DEFAULT")||!1,local:this.matchTextSeq("LOCAL")&&"LOCAL"||this.matchTextSeq(["NOT","LOCAL"])&&"NOT LOCAL"||!1,after:this.matchTextSeq("AFTER")||!1,minimum:this.matchTexts(["MIN","MINIMUM"])||!1,maximum:this.matchTexts(["MAX","MAXIMUM"])||!1};if(this.matchTexts(Object.keys(this._constructor.PROPERTY_PARSERS))){let t=this._constructor.PROPERTY_PARSERS[(this.prev?.text??"").toUpperCase()];try{let s=Object.fromEntries(Object.entries(e).filter(([,i])=>i));return t.call(this,s)??void 0}catch(s){if(s instanceof Ke)throw s;this.raiseError(`Cannot parse property '${this.prev?.text??""}'`)}}}parseWrappedProperties(){return this.parseWrappedCsv(()=>this.parseProperty())}parseProperty(){if(this.matchTexts(Object.keys(this._constructor.PROPERTY_PARSERS)))return this._constructor.PROPERTY_PARSERS[(this.prev?.text??"").toUpperCase()].call(this)??void 0;if(this.match("default")&&this.matchTexts(Object.keys(this._constructor.PROPERTY_PARSERS)))return this._constructor.PROPERTY_PARSERS[(this.prev?.text??"").toUpperCase()].call(this,{default:!0})??void 0;if(this.matchTextSeq(["COMPOUND","SORTKEY"]))return this.parseSortkey({compound:!0});if(this.matchTextSeq(["PARAMETER","STYLE","PANDAS"]))return this.expression(ia,{this:"PANDAS"});let e=this.index,t=this.parseSequenceProperties();if(t)return t;this.retreat(e);let s=this.parseColumn();if(!this.match("eq")){this.retreat(e);return}s instanceof $&&(s=s.parts&&1<s.parts.length?s.toDot()||Z(s.name):Z(s.name));let r=this.parseBitwise()||this.parseVar({anyToken:!0});return r instanceof $&&(r=Z(r.name)),this.expression(w,{this:s,value:r})}parseStored(){if(this.matchTextSeq("BY"))return this.expression(eh,{this:this.parseVarOrString()});this.match("alias");let e=(this.matchTextSeq("INPUTFORMAT")||void 0)&&this.parseString(),t=(this.matchTextSeq("OUTPUTFORMAT")||void 0)&&this.parseString();return this.expression(ir,{this:e||t?this.expression(Qy,{inputFormat:e,outputFormat:t}):this.parseVarOrString()||this.parseNumber()||this.parseIdVar(),hiveFormat:!0})}parseUnquotedField(){let e=this.parseField();return e instanceof v&&!e.args.quoted?Z(e):e}parsePropertyAssignment(e,t){return this.match("eq"),this.match("alias"),this.expression(e,{this:this.parseUnquotedField(),...t})}parseProperties(e){let t=[];for(;;){let s=e?.before?this.parsePropertyBefore():this.parseProperty();if(s===void 0||Array.isArray(s)&&s.length===0)break;let r=Array.isArray(s)?s:[s];for(let i of r)t.push(i)}if(0<t.length)return this.expression(He,{expressions:t})}parseFallback(e){return this.expression($u,{no:e?.no,protection:this.matchTextSeq("PROTECTION")})}parseSqlSecurity(){return this.expression(Pa,{this:this.matchTexts(this._constructor.SECURITY_PROPERTY_KEYWORDS)&&(this.prev?.text??"").toUpperCase()})}parseSettingsProperty(){return this.expression(Ca,{expressions:this.parseCsv(()=>this.parseAssignment())})}parseVolatileProperty(){let e;return 2<=this.index&&(e=this.tokens[this.index-2]),e&&this._constructor.PRE_VOLATILE_TOKENS.has(e.tokenType)?new qa({}):this.expression(Fs,{this:N.string("VOLATILE")})}parseRetentionPeriod(){let e=this.parseNumber(),t=e?`${e} `:"",s=this.parseVar({anyToken:!0});return Z(`${t}${s}`)}parseSystemVersioningProperty(e={}){let{with:t=!1}=e;this.match("eq");let s=this.expression(sh,{on:!0,with:t});if(this.matchTextSeq("OFF"))return s.setArgKey("on",!1),s;if(this.match("on"),this.match("lParen"))for(;this.curr&&!this.match("rParen");)this.matchTextSeq(["HISTORY_TABLE","="])?s.setArgKey("this",this.parseTableParts()):this.matchTextSeq(["DATA_CONSISTENCY_CHECK","="])?(this.advance(),s.setArgKey("dataConsistency",this.prev?.text.toUpperCase())):this.matchTextSeq(["HISTORY_RETENTION_PERIOD","="])&&s.setArgKey("retentionPeriod",this.parseRetentionPeriod()),this.match("comma");return s}parseDataDeletionProperty(){this.match("eq");let e=this.matchTextSeq("ON")||!this.matchTextSeq("OFF"),t=this.expression(Fu,{on:e});if(this.match("lParen"))for(;this.curr&&!this.match("rParen");)this.matchTextSeq(["FILTER_COLUMN","="])?t.setArgKey("filterColumn",this.parseColumn()):this.matchTextSeq(["RETENTION_PERIOD","="])&&t.setArgKey("retentionPeriod",this.parseRetentionPeriod()),this.match("comma");return t}parseDistributedProperty(){let e="HASH",t;this.matchTextSeq(["BY","HASH"])?t=this.parseWrappedCsv(()=>this.parseIdVar()):this.matchTextSeq(["BY","RANDOM"])&&(e="RANDOM");let s;return this.matchTextSeq("BUCKETS")&&!this.matchTextSeq("AUTO")&&(s=this.parseNumber()),this.expression(ea,{expressions:t,kind:e,buckets:s,order:this.parseOrder()})}parseCompositeKeyProperty(e){this.matchTextSeq("KEY");let t=this.parseWrappedIdVars();return this.expression(e,{expressions:t})}parseWithProperty(){if(this.matchTextSeq(["(","SYSTEM_VERSIONING"])){let e=this.parseSystemVersioningProperty({with:!0});return this.matchRParen(),e}if(this.match("lParen",{advance:!1}))return this.parseWrappedProperties();if(this.matchTextSeq("JOURNAL"))return this.parseWithjournaltable();if(this.matchTexts(Array.from(this._constructor.VIEW_ATTRIBUTES)))return this.expression(Da,{this:this.prev?.text.toUpperCase()});if(this.matchTextSeq("DATA"))return this.parseWithdata({no:!1});if(this.matchTextSeq(["NO","DATA"]))return this.parseWithdata({no:!0});if(this.match("serdeProperties",{advance:!1}))return this.parseSerdeProperties({with:!0});if(this.match("schema"))return this.expression(va,{this:this.parseVarFromOptions(this._constructor.SCHEMA_BINDING_OPTIONS)});if(this.matchTexts(Object.keys(this._constructor.PROCEDURE_OPTIONS),{advance:!1}))return this.expression(Fa,{expressions:this.parseCsv(()=>this.parseProcedureOption())});if(this.next)return this.parseWithIsolatedLoading()}parseProcedureOption(){return this.matchTextSeq(["EXECUTE","AS"])?this.expression(nr,{this:this.parseVarFromOptions(this._constructor.EXECUTE_AS_OPTIONS,{raiseUnmatched:!1})||this.parseString()}):this.parseVarFromOptions(this._constructor.PROCEDURE_OPTIONS)}parseDefiner(){this.match("eq");let e=this.parseIdVar();this.match("parameter");let t=this.parseIdVar()||this.match("mod")&&this.prev?.text;if(!(!e||!t))return new Zn({this:`${e}@${t}`})}parseWithjournaltable(){return this.match("table"),this.match("eq"),this.expression(Ua,{this:this.parseTableParts()})}parseLog(e={}){let{no:t=!1}=e;return this.expression(fa,{no:t})}parseJournal(e){return this.expression(Vu,e)}parseChecksum(){this.match("eq");let e;return this.match("on")?e=!0:this.matchTextSeq("OFF")&&(e=!1),this.expression(Uu,{on:e,default:this.match("default")})}parseCluster(e={}){let{wrapped:t=!1}=e;return this.expression(rr,{expressions:t?this.parseWrappedCsv(()=>this.parseOrdered()):this.parseCsv(()=>this.parseOrdered())})}parseClusteredBy(){this.matchTextSeq("BY"),this.matchLParen();let e=this.parseCsv(()=>this.parseColumn());this.matchRParen();let t;this.matchTextSeq(["SORTED","BY"])&&(this.matchLParen(),t=this.parseCsv(()=>this.parseOrdered()),this.matchRParen()),this.match("into");let s=this.parseNumber();return this.matchTextSeq("BUCKETS"),this.expression(Ea,{expressions:e,sortedBy:t,buckets:s})}parseCopyProperty(){if(!this.matchTextSeq("GRANTS")){this.retreat(this.index-1);return}return this.expression(Qn,{})}parseFreespace(){return this.match("eq"),this.expression(Gu,{this:this.parseNumber(),percent:this.match("percent")})}parseMergeBlockRatio(e={}){let{no:t=!1,default:s=!1}=e;return this.match("eq")?this.expression(qn,{this:this.parseNumber(),percent:this.match("percent")}):this.expression(qn,{no:t,default:s})}parseDataBlocksize(e={}){let{default:t,minimum:s,maximum:r}=e;this.match("eq");let i=this.parseNumber(),o;return this.matchTexts(["BYTES","KBYTES","KILOBYTES"])&&(o=this.prev?.text??""),this.expression(vu,{size:i,units:o,default:t,minimum:s,maximum:r})}parseBlockCompression(){this.match("eq");let e=this.matchTextSeq("ALWAYS")||void 0,t=this.matchTextSeq("MANUAL")||void 0,s=this.matchTextSeq("NEVER")||void 0,r=this.matchTextSeq("DEFAULT")||void 0,i;return this.matchTextSeq("AUTOTEMP")&&(i=this.parseSchema()),this.expression(qu,{always:e,manual:t,never:s,default:r,autotemp:i})}parseWithIsolatedLoading(){let e=this.index,t=this.matchTextSeq("NO")||void 0,s=this.matchTextSeq("CONCURRENT")||void 0;if(!this.matchTextSeq(["ISOLATED","LOADING"])){this.retreat(e);return}let r=this.parseVarFromOptions(this._constructor.ISOLATED_LOADING_OPTIONS,{raiseUnmatched:!1});return this.expression(Yu,{no:t,concurrent:s,target:r})}parseLocking(){let e;this.match("table")?e="TABLE":this.match("view")?e="VIEW":this.match("row")?e="ROW":this.matchTextSeq("DATABASE")&&(e="DATABASE");let t;(e==="DATABASE"||e==="TABLE"||e==="VIEW")&&(t=this.parseTableParts());let s;this.match("for")?s="FOR":this.match("in")&&(s="IN");let r;this.matchTextSeq("ACCESS")?r="ACCESS":this.matchTexts(["EXCL","EXCLUSIVE"])?r="EXCLUSIVE":this.matchTextSeq("SHARE")?r="SHARE":this.matchTextSeq("READ")?r="READ":this.matchTextSeq("WRITE")?r="WRITE":this.matchTextSeq("CHECKSUM")&&(r="CHECKSUM");let i=this.matchTextSeq("OVERRIDE")||void 0;return this.expression(ju,{this:t,kind:e,forOrIn:s,lockType:r,override:i})}parsePartitionBy(){return this.match("partitionBy")?this.parseCsv(()=>this.parseDisjunction()):[]}parsePartitionBoundSpec(){let e=n(()=>this.matchTextSeq("MINVALUE")?Z("MINVALUE"):this.matchTextSeq("MAXVALUE")?Z("MAXVALUE"):this.parseBitwise(),"parsePartitionBoundExpr"),t,s,r,i;return this.match("in")?t=this.parseWrappedCsv(()=>this.parseBitwise()):this.match("from")?(r=this.parseWrappedCsv(e),this.matchTextSeq("TO"),i=this.parseWrappedCsv(e)):this.matchTextSeq(["WITH","(","MODULUS"])?(t=this.parseNumber(),this.matchTextSeq([",","REMAINDER"]),s=this.parseNumber(),this.matchRParen()):this.raiseError("Failed to parse partition bound spec."),this.expression(au,{this:t,expression:s,fromExpressions:r,toExpressions:i})}parsePartitionedOf(){if(!this.matchTextSeq("OF")){this.retreat(this.index-1);return}let e=this.parseTable({schema:!0}),t;return this.match("default")?t=Z("DEFAULT"):this.matchTextSeq(["FOR","VALUES"])?t=this.parsePartitionBoundSpec():(this.raiseError("Expecting either DEFAULT or FOR VALUES clause."),t=Z("DEFAULT")),this.expression(zu,{this:e,expression:t})}parsePartitionedBy(){return this.match("eq"),this.expression(ys,{this:this.parseSchema()||this.parseBracket(this.parseField())})}parseWithdata(e={}){let t;return this.matchTextSeq(["AND","STATISTICS"])?t=!0:this.matchTextSeq(["AND","NO","STATISTICS"])&&(t=!1),this.expression(th,{no:e?.no,statistics:t})}parseContainsProperty(){if(this.matchTextSeq("SQL"))return this.expression(vs,{this:"CONTAINS SQL"})}parseModifiesProperty(){if(this.matchTextSeq(["SQL","DATA"]))return this.expression(vs,{this:"MODIFIES SQL DATA"})}parseNoProperty(){if(this.matchTextSeq(["PRIMARY","INDEX"]))return new Ta({});if(this.matchTextSeq("SQL"))return this.expression(vs,{this:"NO SQL"})}parseOnProperty(){return this.matchTextSeq(["COMMIT","PRESERVE","ROWS"])?new Hr({}):this.matchTextSeq(["COMMIT","DELETE","ROWS"])?new Hr({delete:!0}):this.expression(Vr,{this:this.parseSchema({this:this.parseIdVar()})})}parseReadsProperty(){if(this.matchTextSeq(["SQL","DATA"]))return this.expression(vs,{this:"READS SQL DATA"})}parseDistkey(){return this.expression(Kn,{this:this.parseWrapped(()=>this.parseIdVar())})}parseCreateLike(){let e=this.parseTable({schema:!0}),t=[];for(;this.matchTexts(["INCLUDING","EXCLUDING"]);){let s=(this.prev?.text??"").toUpperCase(),r=this.parseIdVar();if(!r)return;let i=r.args.this;t.push(this.expression(w,{this:s,value:Z(typeof i=="string"?i.toUpperCase():"")}))}return this.expression(Wu,{this:e,expressions:t})}parseSortkey(e={}){let t=this.parseWrappedIdVars(),s=t.length===1?t[0]:this.expression(Ze,{expressions:t});return this.expression(ba,{this:s,compound:e?.compound})}parseCharacterSet(e={}){return this.match("eq"),this.expression(zr,{this:this.parseVarOrString(),default:e?.default??!1})}parseRemoteWithConnection(){return this.matchTextSeq(["WITH","CONNECTION"]),this.expression(Ra,{this:this.parseTableParts()})}parseReturns(){let e,t,s=this.match("table")||void 0;return s?this.match("lt")?(e=this.expression(Rt,{this:"TABLE",expressions:this.parseCsv(()=>this.parseStructTypes())}),this.match("gt")||this.raiseError("Expecting >")):e=this.parseSchema({this:Z("TABLE")}):this.matchTextSeq(["NULL","ON","NULL","INPUT"])?(t=!0,e=void 0):e=this.parseTypes(),this.expression(Kr,{this:e,isTable:s,null:t})}parseDescribe(){let e=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev?.text,t=(this.matchTexts(Array.from(this._constructor.DESCRIBE_STYLES))||void 0)&&this.prev?.text.toUpperCase();this.match("dot")&&(t=void 0,this.retreat(this.index-2));let s=this.match("format",{advance:!1})?this.parseProperty():void 0,r;this.matchSet(new Set(Object.keys(this._constructor.STATEMENT_PARSERS)),{advance:!1})?r=this.parseStatement():r=this.parseTable({schema:!0});let o=this.parseProperties()?.args.expressions,c=this.parsePartition();return this.expression(Ql,{this:r,style:t,kind:e,expressions:o,partition:c,format:s,asJson:this.matchTextSeq(["AS","JSON"])})}parseMultitableInserts(e){let t=(this.prev?.text??"").toUpperCase(),s=[],r=n(()=>{let o;this.match("when")&&(o=this.parseDisjunction(),this.match("then"));let c=this.match("else")||void 0;if(this.match("into"))return this.expression(ky,{this:this.expression(es,{this:this.parseTable({schema:!0}),expression:this.parseDerivedTableValues()}),expression:o,else:c})},"parseConditionalInsert"),i=r();for(;i!==void 0;)s.push(i),i=r();return this.expression(nu,{kind:t,comments:e,expressions:s,source:this.parseTable()})}parseInsert(){let e=[],t=this.parseHint(),s=this.match("overwrite")||void 0,r=this.match("ignore")||void 0,i=this.matchTextSeq("LOCAL")||void 0,o,c,p;if(this.matchTextSeq("DIRECTORY"))p=this.expression(su,{this:this.parseVarOrString(),local:i,rowFormat:this.parseRowFormat({matchRow:!0})});else{if(this.matchSet(new Set(["first","all"])))return e.push(...J(this.prevComments)),this.parseMultitableInserts(e);this.match("or")&&(o=this.matchTexts(Array.from(this._constructor.INSERT_ALTERNATIVES))&&this.prev?.text||void 0),this.match("into"),e.push(...J(this.prevComments)),this.match("table"),c=this.match("function")||void 0,p=c?this.parseFunction():this.parseInsertTable()}let u=this.parseReturning();return this.expression(es,{comments:e,hint:t,isFunction:c,this:p,stored:this.matchTextSeq("STORED")&&this.parseStored(),byName:this.matchTextSeq(["BY","NAME"]),exists:this.parseExists(),where:this.matchPair("replace","where")&&this.parseDisjunction(),partition:this.match("partitionBy")&&this.parsePartitionedBy(),settings:this.matchTextSeq("SETTINGS")&&this.parseSettingsProperty(),default:this.matchTextSeq(["DEFAULT","VALUES"]),expression:this.parseDerivedTableValues()||this.parseDdlSelect(),conflict:this.parseOnConflict(),returning:u||this.parseReturning(),overwrite:s,alternative:o,ignore:r,source:this.match("table")&&this.parseTable()})}parseInsertTable(){let e=this.parseTable({schema:!0,parsePartition:!0});return e instanceof _&&this.match("alias",{advance:!1})&&e.setArgKey("alias",this.parseTableAlias()),e}parseKill(){let e=this.matchTexts(["CONNECTION","QUERY"])?Z(this.prev?.text??""):void 0;return this.expression(gy,{this:this.parsePrimary(),kind:e})}parseOnConflict(){let e=this.matchTextSeq(["ON","CONFLICT"])||void 0,t=this.matchTextSeq(["ON","DUPLICATE","KEY"])||void 0;if(!e&&!t)return;let s,r;e&&(this.matchTextSeq(["ON","CONSTRAINT"])?r=this.parseIdVar():this.match("lParen")&&(s=this.parseCsv(()=>this.parseIdVar()),this.matchRParen()));let i=this.parseWhere(),o=this.parseVarFromOptions(this._constructor.CONFLICT_ACTIONS),c;return this.prev?.tokenType==="update"&&(this.match("set"),c=this.parseCsv(()=>this.parseEquality())),this.expression(Dy,{duplicate:t,expressions:c,action:o,conflictKeys:s,indexPredicate:i,constraint:r,where:this.parseWhere()})}parseReturning(){if(this.match("returning"))return this.expression(FA,{expressions:this.parseCsv(()=>this.parseExpression()),into:this.match("into")&&this.parseTablePart()})}parseRow(){if(this.match("format"))return this.parseRowFormat()}parseSerdeProperties(e={}){let t=this.index,s=e?.with||this.matchTextSeq("WITH");if(!this.match("serdeProperties")){this.retreat(t);return}return this.expression(Ku,{expressions:this.parseWrappedProperties(),with:s})}parseRowFormat(e={}){if(e?.matchRow&&!this.matchPair("row","format"))return;if(this.matchTextSeq("SERDE")){let s=this.parseString(),r=this.parseSerdeProperties();return this.expression(Zu,{this:s,serdeProperties:r})}this.matchTextSeq("DELIMITED");let t={};return this.matchTextSeq(["FIELDS","TERMINATED","BY"])&&(t.fields=this.parseString(),this.matchTextSeq(["ESCAPED","BY"])&&(t.escaped=this.parseString())),this.matchTextSeq(["COLLECTION","ITEMS","TERMINATED","BY"])&&(t.collectionItems=this.parseString()),this.matchTextSeq(["MAP","KEYS","TERMINATED","BY"])&&(t.mapKeys=this.parseString()),this.matchTextSeq(["LINES","TERMINATED","BY"])&&(t.lines=this.parseString()),this.matchTextSeq(["NULL","DEFINED","AS"])&&(t.null=this.parseString()),this.expression(Qu,t)}parseSelect(e={}){let{nested:t=!1,table:s=!1,parseSubqueryAlias:r=!0,parseSetOperation:i=!0,consumePipe:o=!0,from:c}=e,p=this.parseSelectQuery({nested:t,table:s,parseSubqueryAlias:r,parseSetOperation:i});return o&&this.match("pipeGt",{advance:!1})&&(!p&&c&&(p=Ye("*").from(c)),p instanceof ee&&(p=this.parsePipeSyntaxQuery(p),p=p&&s?p.subquery(void 0,{copy:!1}):p)),p}parseSelectQuery(e={}){let{nested:t=!1,table:s=!1,parseSubqueryAlias:r=!0,parseSetOperation:i=!0}=e,o=this.parseWith(),c;if(o){if(c=this.parseStatement(),!c)return this.raiseError("Failed to parse any statement following CTE"),o;for(;c instanceof he&&c.isWrapper;)c=c.args.this;return c?._constructor.availableArgs.has("with")?c.setArgKey("with",o):(this.raiseError(`${c?._constructor.key||"Unknown expression"} does not support CTE`),c=o),c}let p;if(this.match("from",{advance:!1})&&(p=this.parseFrom({joins:!0,consumePipe:!0})),this.match("select")){let u=this.prevComments,h=this.parseHint(),g,f;this.next&&this.next.tokenType!=="dot"&&(g=this.match("all")||void 0,f=this.matchSet(this._constructor.DISTINCT_TOKENS)?new et:void 0);let x=this.match("alias")&&this.matchTexts(["STRUCT","VALUE"])&&this.prev?.text.toUpperCase()||void 0;f&&(f=this.expression(et,{on:this.match("on")?this.parseValue({values:!1}):void 0})),g&&f&&this.raiseError("Cannot specify both ALL and DISTINCT after SELECT");let T=[];for(;this.curr&&this.matchTexts(Array.from(this._constructor.OPERATION_MODIFIERS));)T.push(Z((this.prev?.text??"").toUpperCase()));let y=this.parseLimit(void 0,{top:!0}),[C,I]=this.parseProjections();c=this.expression(se,{kind:x,hint:h,distinct:f,expressions:C,limit:y,exclude:I,operationModifiers:0<T.length?T:void 0}),c.comments=u;let b=this.parseInto();b&&c.setArgKey("into",b),p||(p=this.parseFrom()),p&&c.setArgKey("from",p),c=this.parseQueryModifiers(c)}else if((s||t)&&this.match("lParen")){let u=this.prevComments;return c=this.parseWrappedSelect({table:s}),c&&c.addComments(u,{prepend:!0}),this.matchRParen(),this.parseSubquery(c,{parseAlias:r})}else if(this.match("values",{advance:!1}))c=this.parseDerivedTableValues();else if(p)c=Ye("*").from(p.args.this,{copy:!1}),c=this.parseQueryModifiers(c);else if(this.match("summarize")){let u=this.match("table")||void 0;return c=this.parseSelect()||this.parseString()||this.parseTable(),this.expression(hy,{this:c,table:u})}else{if(this.match("describe"))return this.parseDescribe();c=void 0}return i?this.parseSetOperations(c):c}parseRecursiveWithSearch(){this.matchTextSeq("SEARCH");let e=(this.matchTexts(Array.from(this._constructor.RECURSIVE_CTE_SEARCH_KIND))||void 0)&&this.prev?.text.toUpperCase();if(e)return this.matchTextSeq(["FIRST","BY"]),this.expression(xy,{kind:e,this:this.parseIdVar(),expression:this.matchTextSeq("SET")&&this.parseIdVar(),using:this.matchTextSeq("USING")&&this.parseIdVar()})}parseWith(e={}){let{skipWithToken:t=!1}=e;if(!t&&!this.match("with"))return;let s=this.prevComments,r=this.match("recursive")||void 0,i,o=[];for(;;){let c=this.parseCte();if(c instanceof Ft&&(o.push(c),i&&c.addComments(i)),!this.match("comma")&&!this.match("with"))break;this.match("with"),i=this.prevComments}return this.expression(dt,{comments:s,expressions:o,recursive:r,search:this.parseRecursiveWithSearch()})}parseCte(){let e=this.index,t=this.parseTableAlias({aliasTokens:this._constructor.ID_VAR_TOKENS});(!t||!t.args.this)&&this.raiseError("Expected CTE to have alias");let s=this.matchTextSeq(["USING","KEY"])?this.parseWrappedIdVars():void 0;if(!this.match("alias")&&!this._constructor.OPTIONAL_ALIAS_TOKEN_CTE){this.retreat(e);return}let r=this.prevComments,i;this.matchTextSeq(["NOT","MATERIALIZED"])?i=!1:this.matchTextSeq("MATERIALIZED")&&(i=!0);let o=this.expression(Ft,{this:this.parseWrapped(()=>this.parseStatement()),alias:t,materialized:i,keyExpressions:s,comments:r}),c=o.args.this;return c instanceof tr&&(c.alias?o.setArgKey("this",Ye("*").from(c)):o.setArgKey("this",Ye("*").from(Be(c,"_values",{table:!0})))),o}parseTableAlias(e={}){let{aliasTokens:t}=e;if(this.canParseLimitOrOffset())return;let s=this.match("alias"),r=this.parseIdVar({anyToken:s,tokens:t||this._constructor.TABLE_ALIAS_TOKENS})||this.parseStringAsIdentifier(),i=this.index,o;if(this.match("lParen")?(o=this.parseCsv(()=>this.parseFunctionParameter()),!o||o.length===0?this.retreat(i):this.matchRParen()):o=void 0,!r&&(!o||o.length===0))return;let c=this.expression(pe,{this:r,columns:o});return r instanceof v&&c.addComments(r.popComments()),c}parseSubquery(e,t={}){let{parseAlias:s=!0}=t;if(e)return this.expression(he,{this:e,pivots:this.parsePivots(),alias:s?this.parseTableAlias():void 0,sample:this.parseTableSample()})}implicitUnnestsToExplicit(e){let t=new Set,s=e.args;if("from"in s){let i=s.from?.args.this;if(i){let o=ey(i.copy(),{dialect:this.dialect});t.add(o.aliasOrName||"")}}if("joins"in s){let r=s.joins?Et(s.joins,xe):void 0;if(r)for(let i of r){let o=i.args.this;if(o instanceof _&&!i.args.on){let c=o.copy();c.meta.maybeColumn=!0;let p=ey(c,{dialect:this.dialect}),u=p.parts;if(u&&0<u.length&&t.has(u[0].name||"")){let h=o.toColumn();if(h){let g=new Ee({expressions:[h]});if(o.args.alias instanceof pe&&h.args.this instanceof d){h.replace(h.args.this);let f=o.args.alias?.args.this,x={table:f?typeof f=="string"?[f]:(re(f,v),[f]):void 0,copy:!1};Be(g,void 0,x)}o.replace(g)}}t.add(p.aliasOrName||"")}}}return e}parseQueryModifiers(e){if(e&&this._constructor.MODIFIABLES.some(t=>e instanceof t)){for(let s of this.parseJoins())e.append("joins",s);let t=this.parseLateral();for(;t;)e.append("laterals",t),t=this.parseLateral();for(;;){if(this.matchSet(new Set(Object.keys(this._constructor.QUERY_MODIFIER_PARSERS)),{advance:!1})){let s=this.curr,r=this._constructor.QUERY_MODIFIER_PARSERS[s.tokenType],[i,o]=r?.call(this)||[];if(i!==void 0&&o!==void 0){if(e.getArgKey(i)&&this.raiseError(`Found multiple '${s.text.toUpperCase()}' clauses`,s),e.setArgKey(i,o),i==="limit"){let c=o,p=c.args.offset;if(c.setArgKey("offset",void 0),p){let u=new Cn({expression:p});e.setArgKey("offset",u);let h=o.args.expressions;c.setArgKey("expressions",void 0),u.setArgKey("expressions",h)}}continue}}break}}return this._constructor.SUPPORTS_IMPLICIT_UNNEST&&e&&e.args.from&&(e=this.implicitUnnestsToExplicit(e)),e}parseHintFallbackToString(){let e=this.curr;for(;this.curr;)this.advance();let t=this.tokens[this.index-1];return new Ps({expressions:[this.findSql(e,t)]})}parseHintFunctionCall(){return this.parseFunctionCall()}parseHintBody(){let e=this.index,t=!1,s=[];try{let r=this.parseCsv(()=>this.parseHintFunctionCall()||this.parseVar({upper:!0}));for(;0<r.length;)s.push(...r),r=this.parseCsv(()=>this.parseHintFunctionCall()||this.parseVar({upper:!0}))}catch{t=!0}return t||this.curr?(this.retreat(e),this.parseHintFallbackToString()):this.expression(Ps,{expressions:s})}parseHint(){if(this.match("hint")&&this.prevComments&&0<this.prevComments.length)return W(this.prevComments[0],{into:"hint",dialect:this.dialect})}parseInto(){if(!this.match("into"))return;let e=this.match("temporary")||void 0,t=this.matchTextSeq("UNLOGGED")||void 0;return this.match("table"),this.expression(iu,{this:this.parseTable({schema:!0}),temporary:e,unlogged:t})}parseFrom(e={}){let{joins:t=!1,skipFromToken:s=!1,consumePipe:r=!1}=e;if(!(!s&&!this.match("from")))return this.expression(rt,{comments:this.prevComments,this:this.parseTable({joins:t,consumePipe:r})})}parseMatchRecognizeMeasure(){return this.expression(_y,{windowFrame:this.matchTexts(["FINAL","RUNNING"])&&(this.prev?.text??"").toUpperCase(),this:this.parseExpression()})}parseMatchRecognize(){if(!this.match("matchRecognize"))return;this.matchLParen();let e=this.parsePartitionBy(),t=this.parseOrder(),s=this.matchTextSeq("MEASURES")?this.parseCsv(()=>this.parseMatchRecognizeMeasure()):void 0,r;if(this.matchTextSeq(["ONE","ROW","PER","MATCH"]))r=Z("ONE ROW PER MATCH");else if(this.matchTextSeq(["ALL","ROWS","PER","MATCH"])){let p="ALL ROWS PER MATCH";this.matchTextSeq(["SHOW","EMPTY","MATCHES"])?p+=" SHOW EMPTY MATCHES":this.matchTextSeq(["OMIT","EMPTY","MATCHES"])?p+=" OMIT EMPTY MATCHES":this.matchTextSeq(["WITH","UNMATCHED","ROWS"])&&(p+=" WITH UNMATCHED ROWS"),r=Z(p)}let i;if(this.matchTextSeq(["AFTER","MATCH","SKIP"])){let p="AFTER MATCH SKIP";this.matchTextSeq(["PAST","LAST","ROW"])?p+=" PAST LAST ROW":this.matchTextSeq(["TO","NEXT","ROW"])?p+=" TO NEXT ROW":this.matchTextSeq(["TO","FIRST"])?(this.advance(),p+=` TO FIRST ${this.prev?.text}`):this.matchTextSeq(["TO","LAST"])&&(this.advance(),p+=` TO LAST ${this.prev?.text}`),i=Z(p)}let o;if(this.matchTextSeq("PATTERN")){this.matchLParen(),this.curr||this.raiseError("Expecting )",this.curr);let p=1,u=this.curr,h=this.prev;for(;this.curr&&0<p;)this.curr.tokenType==="lParen"&&p++,this.curr.tokenType==="rParen"&&p--,h=this.prev,this.advance();0<p&&this.raiseError("Expecting )",this.curr),o=Z(this.findSql(u,h))}let c=this.matchTextSeq("DEFINE")?this.parseCsv(()=>this.parseNameAsExpression()):void 0;return this.matchRParen(),this.expression(Wy,{partitionBy:e,order:t,measures:s,rows:r,after:i,pattern:o,define:c,alias:this.parseTableAlias()})}parseLateral(){let e=this.matchPair("cross","apply")||void 0;!e&&this.matchPair("outer","apply")&&(e=!1);let t,s,r;if(e!==void 0)t=this.parseSelect({table:!0}),s=void 0,r=void 0;else if(this.match("lateral"))t=this.parseSelect({table:!0}),s=this.match("view")||void 0,r=this.match("outer")||void 0;else return;if(!t)for(t=this.parseUnnest()||this.parseFunction()||this.parseIdVar({anyToken:!1});this.match("dot");){let c=this.parseFunction()||this.parseIdVar({anyToken:!1});t=new ge({this:t,expression:c})}let i,o;if(s){let c=this.parseIdVar({anyToken:!1}),p=this.match("alias")?this.parseCsv(()=>this.parseIdVar()):[];o=this.expression(pe,{this:c,columns:p})}else(t instanceof he||t instanceof Ee)&&t.alias?o=t.args.alias?.pop():(i=this.matchPair("with","ordinality")||void 0,o=this.parseTableAlias());return this.expression(Ct,{this:t,view:s,outer:r,alias:o,crossApply:e,ordinality:i})}parseStream(){let e=this.index;if(this.match("stream")){let t=this.tryParse(this.parseTable.bind(this));if(t)return this.expression(Eu,{this:t});this.retreat(e)}}parseJoinParts(){return{method:this.matchSet(this._constructor.JOIN_METHODS)?this.prev:void 0,side:this.matchSet(this._constructor.JOIN_SIDES)?this.prev:void 0,kind:this.matchSet(this._constructor.JOIN_KINDS)?this.prev:void 0}}parseUsingIdentifiers(){let e=n(()=>{let t=this.parseColumn();return t instanceof $?t.args.this instanceof d?t.args.this:K(t.args.this):t},"parseColumnAsIdentifier");return this.parseWrappedCsv(e,{optional:!0})}parseJoin(e={}){let{skipJoinToken:t=!1,parseBracket:s=!1}=e;if(this.match("comma")){let C=this.tryParse(this.parseTable.bind(this)),I=C?this.expression(xe,{this:C}):void 0;return I&&this._constructor.JOINS_HAVE_EQUAL_PRECEDENCE&&I.setArgKey("kind","cross"),I}let r=this.index,{method:i,side:o,kind:c}=this.parseJoinParts(),p=this.matchTextSeq("DIRECTED")||void 0,u=(this.matchTexts(this._constructor.JOIN_HINTS)||void 0)&&this.prev?.text,h=this.match("join")||c?.tokenType==="straightJoin",g=this.prevComments;!t&&!h&&(this.retreat(r),c=void 0,i=void 0,o=void 0);let f=this.matchPair("outer","apply",{advance:!1})||void 0,x=this.matchPair("cross","apply",{advance:!1})||void 0;if(!t&&!h&&!f&&!x)return;let T={this:f||x?this.parseLateral():this.parseTable({parseBracket:s})};if(c?.tokenType==="array"&&this.match("comma")&&(T.expressions=this.parseCsv(()=>this.parseTable({parseBracket:s}))),i&&(T.method=i.text.toUpperCase()),o&&(T.side=st(Yt,o.text)),c&&(T.kind=c.tokenType==="straightJoin"?"straightJoin":st(Yt,c.text)),u&&(T.hint=u),this.match("matchCondition")&&(T.matchCondition=this.parseWrapped(()=>this.parseComparison())),this.match("on"))T.on=this.parseDisjunction();else if(this.match("using"))T.using=this.parseUsingIdentifiers();else if(!i&&!(f||x)&&!(T.this instanceof Ee)&&!(c?.tokenType==="cross"||c?.tokenType==="array")){let C=this.index,I=[...this.parseJoins()];0<I.length&&this.match("on")?T.on=this.parseDisjunction():0<I.length&&this.match("using")?T.using=this.parseUsingIdentifiers():this.retreat(C),0<I.length&&(T.on||T.using)&&T.this?.setArgKey("joins",I)}T.pivots=this.parsePivots();let y=[...g||[],...[i,o,c].flatMap(C=>C?.comments||[])];return this._constructor.ADD_JOIN_ON_TRUE&&!T.on&&!T.using&&!T.method&&(!T.kind||T.kind==="inner"||T.kind==="outer")&&(T.on=new at({this:!0})),p&&(T.directed=p),this.expression(xe,{comments:y,...T})}parseOpClass(){let e=this.parseDisjunction();return this.matchTexts(Array.from(this._constructor.OPCLASS_FOLLOW_KEYWORDS),{advance:!1})||this.matchSet(this._constructor.OPTYPE_FOLLOW_TOKENS,{advance:!1})?e:this.expression(Ly,{this:e,expression:this.parseTableParts()})}parseIndexParams(){let e=this.match("using")?this.parseVar({anyToken:!0}):void 0,t=this.match("lParen",{advance:!1})?this.parseWrappedCsv(()=>this.parseWithOperator()):void 0,s=this.matchTextSeq("INCLUDE")?this.parseWrappedIdVars():void 0,r=this.parsePartitionBy(),i=(this.match("with")||void 0)&&this.parseWrappedProperties(),o=this.matchTextSeq(["USING","INDEX","TABLESPACE"])?this.parseVar({anyToken:!0}):void 0,c=this.parseWhere(),p=this.match("on")?this.parseField():void 0;return this.expression(My,{using:e,columns:t,include:s,partitionBy:r,where:c,withStorage:i,tablespace:o,on:p})}parseIndex(e={}){let{anonymous:t=!1,index:s}=e,r=s,i,o,c,p;if(r||t)i=void 0,o=void 0,c=void 0,this.match("on"),this.match("table"),p=this.parseTableParts({schema:!0});else{if(i=this.match("unique")||void 0,o=this.matchTextSeq("PRIMARY")||void 0,c=this.matchTextSeq("AMP")||void 0,!this.match("index"))return;r=this.parseIdVar(),p=void 0}let u=this.parseIndexParams();return this.expression(wy,{this:r,table:p,unique:i,primary:o,amp:c,params:u})}parseTableHints(){let e=[];if(this.matchPair("with","lParen"))e.push(this.expression(cu,{expressions:this.parseCsv(()=>this.parseFunction()||this.parseVar({anyToken:!0}))})),this.matchRParen();else for(;this.matchSet(this._constructor.TABLE_INDEX_HINT_TOKENS);){let t=new Ky({this:(this.prev?.text??"").toUpperCase()});this.matchSet(new Set(["index","key"])),this.match("for")&&(this.advanceAny(),t.setArgKey("target",(this.prev?.text??"").toUpperCase())),t.setArgKey("expressions",this.parseWrappedIdVars()),e.push(t)}return 0<e.length?e:void 0}parseTablePart(e={}){let{schema:t=!1}=e;return!t&&this.parseFunction({optionalParens:!1})||this.parseIdVar({anyToken:!1})||this.parseStringAsIdentifier()||this.parsePlaceholder()}parseTablePartsFast(){let e=this.index,t,s;for(;this.matchSet(this._constructor.FAST_COLUMN_TOKENS);){let o=this.prev,c=this.prevComments,p=this.match("dot"),u=this.curr?.tokenType;if(p){if(u===void 0||!this._constructor.FAST_COLUMN_TOKENS.has(u)){this.retreat(e);return}}else if(u!==void 0&&this._constructor.TABLE_POSTFIX_TOKENS.has(u)){this.retreat(e);return}if(t||(t=[]),c?.length&&(s||(s=[]),s.push(...c),this.prevComments=void 0),t.push(this.expression(v,{this:o.text,quoted:o.tokenType==="identifier",token:o})),!p)break}if(!t)return;let r=t.length,i;if(r===1)i=new _({this:t[0]});else if(r===2)i=new _({this:t[1],db:t[0]});else{let o=t[2];for(let c=3;c<r;c++)o=new ge({this:o,expression:t[c]});i=new _({this:o,db:t[1],catalog:t[0]})}return s&&i.addComments(s),i}parseTableParts(e={}){let{schema:t=!1,isDbReference:s=!1,wildcard:r=!1,fast:i=!1}=e;if(i)return this.parseTablePartsFast();let o,c,p=this.parseTablePart({schema:t});for(;this.match("dot");)o?p=this.expression(ge,{this:p,expression:this.parseTablePart({schema:t})}):(o=c,c=p,p=this.parseTablePart({schema:t})||"");r&&this.isConnected()&&(p instanceof v||!p)&&this.match("star")&&(p instanceof v?p.args.this+="*":p=new v({this:"*"}));let u=p instanceof d?p.popComments():void 0;s&&(o=c,c=p,p=void 0),!p&&!s&&this.raiseError(`Expected table name but got ${this.curr}`,this.curr),!c&&s&&this.raiseError(`Expected database name but got ${this.curr}`,this.curr);let h=this.expression(_,{comments:u,this:p,db:c,catalog:o}),g=this.parseChanges();g&&h.setArgKey("changes",g);let f=this.parseHistoricalData();f&&h.setArgKey("when",f);let x=this.parsePivots();return x&&h.setArgKey("pivots",x),h}parseTable(e={}){let{schema:t=!1,joins:s=!1,aliasTokens:r,parseBracket:i=!1,isDbReference:o=!1,parsePartition:c=!1,consumePipe:p=!1}=e;if(!t&&!o&&!p&&!s){let B=this.index,j=this.parseTableParts({fast:!0});if(j){let Q=this.curr?.tokenType,ne=this.next?.tokenType,H=this._constructor.TABLE_FAST_TERMINATORS;if(Q!==void 0&&H.has(Q)&&ne!=="matchCondition")return j;let Pe=this._constructor.TABLE_POSTFIX_TOKENS;if((Q===void 0||!Pe.has(Q))&&(ne===void 0||!Pe.has(ne))){let me=this.parseTableAlias({aliasTokens:r||this._constructor.TABLE_ALIAS_TOKENS});if(me&&j.setArgKey("alias",me),this.curr?.tokenType!==void 0&&H.has(this.curr.tokenType))return j}this.retreat(B)}}let u=this.parseStream();if(u)return u;let h=this.parseLateral();if(h)return h;let g=this.parseUnnest();if(g)return g;let f=this.parseDerivedTableValues();if(f)return f;let x=this.parseSelect({table:!0,consumePipe:p});if(x)return x.args.pivots||x.setArgKey("pivots",this.parsePivots()),x;let T=i&&this.parseBracket(void 0);T=T?this.expression(_,{this:T}):void 0;let y=(this.matchTextSeq(["ROWS","FROM"])||void 0)&&this.parseWrappedCsv(()=>this.parseTable());y=y?this.expression(_,{rowsFrom:y}):void 0;let C=this.match("only")||void 0,I=T||y||this.parseBracket(this.parseTableParts({schema:t,isDbReference:o}));if(C&&I?.setArgKey("only",C),this.match("star"),(c||this._constructor.SUPPORTS_PARTITION_SELECTION)&&this.match("partition",{advance:!1})&&I?.setArgKey("partition",this.parsePartition()),t)return this.parseSchema({this:I});this._dialectConstructor.ALIAS_POST_VERSION&&I?.setArgKey("version",this.parseVersion()),this._dialectConstructor.ALIAS_POST_TABLESAMPLE&&I?.setArgKey("sample",this.parseTableSample());let k=this.parseTableAlias({aliasTokens:r||this._constructor.TABLE_ALIAS_TOKENS});if(k&&I?.setArgKey("alias",k),this.match("indexedBy")?I?.setArgKey("indexed",this.parseTableParts()):this.matchTextSeq(["NOT","INDEXED"])&&I?.setArgKey("indexed",!1),I instanceof _&&this.matchTextSeq("AT"))return this.expression(fC,{this:I.toColumn?.({copy:!1}),expression:this.parseIdVar()});if(I?.setArgKey("hints",this.parseTableHints()),I?.args.pivots||I?.setArgKey("pivots",this.parsePivots()),this._dialectConstructor.ALIAS_POST_TABLESAMPLE||I?.setArgKey("sample",this.parseTableSample()),this._dialectConstructor.ALIAS_POST_VERSION||I?.setArgKey("version",this.parseVersion()),s)for(let B of this.parseJoins())I?.append("joins",B);return this.matchPair("with","ordinality")&&(I?.setArgKey("ordinality",!0),I?.setArgKey("alias",this.parseTableAlias())),I}parseVersion(){let e;if(this.match("timestampSnapshot"))e="TIMESTAMP";else if(this.match("versionSnapshot"))e="VERSION";else return;let t,s;if(this.matchSet(new Set(["from","between"]))){t=(this.prev?.text??"").toUpperCase();let r=this.parseBitwise();this.matchTexts(["TO","AND"]);let i=this.parseBitwise();s=this.expression(Ze,{expressions:[r,i]})}else this.matchTextSeq(["CONTAINED","IN"])?(t="CONTAINED IN",s=this.expression(Ze,{expressions:this.parseWrappedCsv(()=>this.parseBitwise())})):this.match("all")?(t="ALL",s=void 0):(this.matchTextSeq(["AS","OF"]),t="AS OF",s=this.parseType());return this.expression(tC,{this:e,expression:s,kind:t})}parseHistoricalData(){let e=this.index,t;if(this.matchTexts(Array.from(this._constructor.HISTORICAL_DATA_PREFIX))){let s=(this.prev?.text??"").toUpperCase(),r=this.match("lParen")&&this.matchTexts(Array.from(this._constructor.HISTORICAL_DATA_KIND))&&(this.prev?.text??"").toUpperCase(),i=(this.match("farrow")||void 0)&&this.parseBitwise();i?(this.matchRParen(),t=this.expression(eC,{this:s,kind:r,expression:i})):this.retreat(e)}return t}parseChanges(){if(!this.matchTextSeq(["CHANGES","(","INFORMATION","=>"]))return;let e=this.parseVar({anyToken:!0});return this.matchRParen(),this.expression(Ny,{information:e,atBefore:this.parseHistoricalData(),end:this.parseHistoricalData()})}parseUnnest(e={}){let{withAlias:t=!0}=e;if(!this.matchPair("unnest","lParen",{advance:!1}))return;this.advance();let s=this.parseWrappedCsv(()=>this.parseEquality()),r=this.matchPair("with","ordinality")||void 0,i=t?this.parseTableAlias():void 0;if(i){this._dialectConstructor.UNNEST_COLUMN_ONLY&&(i.args.columns&&this.raiseError("Unexpected extra column alias in unnest."),i.setArgKey("columns",[i.args.this]),i.setArgKey("this",void 0));let o=i.args.columns;r&&o&&s.length<o.length&&(r=o.pop())}return!r&&this.matchPair("with","offset")&&(this.match("alias"),r=this.parseIdVar({anyToken:!1,tokens:this._constructor.UNNEST_OFFSET_ALIAS_TOKENS})||K("offset")),this.expression(Ee,{expressions:s,alias:i,offset:r})}parseDerivedTableValues(){let e=this.matchPair("lParen","values")||void 0;if(!e&&!(this.matchTextSeq("VALUES")||this.matchTextSeq(["FORMAT","VALUES"])))return;let t=this.parseCsv(()=>this.parseValue()),s=this.parseTableAlias();return e&&this.matchRParen(),this.expression(tr,{expressions:t,alias:s||this.parseTableAlias()})}parseTableSample(e={}){let{asModifier:t=!1}=e;if(!this.match("tableSample")&&!(t&&this.matchTextSeq(["USING","SAMPLE"])))return;let s,r,i,o,c,p,u=this.parseVar({tokens:new Set(["row"]),upper:!0}),h=this.match("lParen")||void 0,g,f;return this._constructor.TABLESAMPLE_CSV?(f=void 0,g=this.parseCsv(()=>this.parsePrimary())):(g=void 0,f=this.match("number",{advance:!1})?this.parseFactor():this.parsePrimary()||this.parsePlaceholder()),this.matchTextSeq("BUCKET")?(s=this.parseNumber(),this.matchTextSeq(["OUT","OF"]),r=this.parseNumber(),this.match("on"),i=this.parseField()):this.matchSet(new Set(["percent","mod"]))?o=f:this.match("rows")||!this._dialectConstructor.TABLESAMPLE_SIZE_IS_PERCENT?c=f:o=f,h&&this.matchRParen(),this.match("lParen")?(u=this.parseVar({upper:!0}),p=(this.match("comma")||void 0)&&this.parseNumber(),this.matchRParen()):this.matchTexts(["SEED","REPEATABLE"])&&(p=this.parseWrapped(()=>this.parseNumber())),!u&&this._constructor.DEFAULT_SAMPLING_METHOD&&(u=Z(this._constructor.DEFAULT_SAMPLING_METHOD)),this.expression(sC,{expressions:g,method:u,bucketNumerator:s,bucketDenominator:r,bucketField:i,percent:o,size:c,seed:p})}parsePivots(){let e=[],t=this.parsePivot();for(;t;)e.push(t),t=this.parsePivot();return 0<e.length?e:void 0}parseJoins(){let e=[],t=this.parseJoin();for(;t;)e.push(t),t=this.parseJoin();return e}parseUnpivotColumns(){if(this.match("into"))return this.expression(rC,{this:this.matchTextSeq("NAME")&&this.parseColumn(),expressions:this.matchTextSeq("VALUE")&&this.parseCsv(()=>this.parseColumn())})}parseSimplifiedPivot(e={}){let{isUnpivot:t}=e,s=n(()=>{let u=this.parseBitwise();return this.match("in")?this.parseIn(u):this.match("alias",{advance:!1})?this.parseAlias(u):u},"parseOn"),r=this.parseTable(),i=(this.match("on")||void 0)&&this.parseCsv(s),o=this.parseUnpivotColumns(),c=(this.match("using")||void 0)&&this.parseCsv(()=>this.parseAlias(this.parseColumn())),p=this.parseGroup();return this.expression(Ln,{this:r,expressions:i,using:c,group:p,unpivot:t,into:o})}parsePivotIn(){let e=n(()=>{let i=this.parseSelectOrExpression();this.match("alias");let o=this.parseBitwise();if(o){let c=o;return o instanceof $&&!o.args.db&&(re(o.args.this,d),c=o.args.this),this.expression(WC,{this:i,alias:c})}return i},"parseAliasedExpression"),t=this.parseColumn();this.match("in")||this.raiseError("Expecting IN",this.curr);let s;if(this.match("lParen"))return this.match("any")?s=[...J(new wn({this:this.parseOrder()}))]:s=this.parseCsv(e),this.matchRParen(),this.expression(lt,{this:t,expressions:s});let r=this.parseIdVar();return this.expression(lt,{this:t,field:r})}parsePivotAggregation(){let e=this.parseFunction();if(!e){if(this.prev&&this.prev.tokenType==="comma")return;this.raiseError("Expecting an aggregation function in PIVOT",this.curr)}return this.parseAlias(e)}parsePivot(){let e=this.index,t,s;if(this.match("pivot"))s=!1;else if(this.match("unpivot"))s=!0,this.matchTextSeq(["INCLUDE","NULLS"])?t=!0:this.matchTextSeq(["EXCLUDE","NULLS"])&&(t=!1);else return;if(!this.match("lParen")){this.retreat(e);return}let r;s?r=this.parseCsv(()=>this.parseColumn()):r=this.parseCsv(()=>this.parsePivotAggregation()),r.length===0&&this.raiseError("Failed to parse PIVOT's aggregation list",this.curr),this.match("for")||this.raiseError("Expecting FOR",this.curr);let i=[];for(;;){let u=this.tryParse(()=>this.parsePivotIn());if(!u)break;i.push(u)}let o=(this.matchTextSeq(["DEFAULT","ON","NULL"])||void 0)&&this.parseWrapped(()=>this.parseBitwise()),c=this.parseGroup();this.matchRParen();let p=this.expression(Ln,{expressions:r,fields:i,unpivot:s,includeNulls:t,defaultOnNull:o,group:c});if(this.matchSet(new Set(["pivot","unpivot"]),{advance:!1})||p.setArgKey("alias",this.parseTableAlias()),!s){let u=this.pivotColumnNames(r),h=[],g=[];for(let f of p.args.fields){let x=f.args.expressions;x?.[0]instanceof wn||x&&g.push(x.map(T=>this._constructor.IDENTIFY_PIVOT_STRINGS?T.sql():T.aliasOrName||""))}if(0<g.length){0<u.length&&g.push(u);for(let f of this.product(g)){let x=[...f];0<u.length&&this._constructor.PREFIXED_PIVOT_COLUMNS&&x.unshift(x.pop()),h.push(K(x.join("_")))}}p.setArgKey("columns",h)}return p}pivotColumnNames(e){return e.map(t=>t.alias).filter(t=>t)}product(e){if(e.length===0)return[[]];if(e.length===1)return e[0].map(o=>[o]);let t=[],[s,...r]=e,i=this.product(r);for(let o of s)for(let c of i)t.push([o,...c]);return t}parsePrewhere(e={}){let{skipWhereToken:t=!1}=e;if(!(!t&&!this.match("prewhere")))return this.expression(iC,{comments:this.prevComments,this:this.parseDisjunction()})}parseWhere(e={}){let{skipWhereToken:t=!1}=e;if(!(!t&&!this.match("where")))return this.expression(St,{comments:this.prevComments,this:this.parseDisjunction()})}parseGroup(e={}){let{skipGroupByToken:t=!1}=e;if(!t&&!this.match("groupBy"))return;let s=this.prevComments,r={expressions:[],rollup:[],cube:[],groupingSets:[]};if(this.match("all")?r.all=!0:this.match("distinct")&&(r.all=!1),this.matchSet(this._constructor.QUERY_MODIFIER_TOKENS,{advance:!1}))return this.expression(Yr,{comments:s,...r});for(;;){let i=this.index;r.expressions.push(...this.parseCsv(()=>this.matchSet(new Set(["cube","rollup"]),{advance:!1})?void 0:this.parseDisjunction()));let o=this.index,c=this.match("with")||void 0,p=this.parseCubeOrRollup({withPrefix:c});if(p){let u=p instanceof OA?"rollup":"cube";r[u].push(p)}else{let u=this.parseGroupingSets();u?r.groupingSets.push(u):this.matchTextSeq("TOTALS")&&(r.totals=!0)}if(o<=this.index&&this.index<=o+1){this.retreat(o);break}if(i===this.index)break}return this.expression(Yr,{comments:s,...r})}parseCubeOrRollup(e={}){let{withPrefix:t=!1}=e,s;if(this.match("cube"))s=Yy;else if(this.match("rollup"))s=OA;else return;return this.expression(s,{expressions:t?[]:this.parseWrappedCsv(()=>this.parseBitwise())})}parseGroupingSets(){if(this.match("groupingSets"))return this.expression(Vy,{expressions:this.parseWrappedCsv(()=>this.parseGroupingSet())})}parseGroupingSet(){return this.parseGroupingSets()||this.parseCubeOrRollup()||this.parseBitwise()}parseHaving(e={}){let{skipHavingToken:t=!1}=e;if(!(!t&&!this.match("having")))return this.expression(ds,{comments:this.prevComments,this:this.parseDisjunction()})}parseQualify(){if(this.match("qualify"))return this.expression(Xs,{this:this.parseDisjunction()})}parseConnectWithPrior(){this._constructor.NO_PAREN_FUNCTION_PARSERS.PRIOR=function(){return this.expression(by,{this:this.parseBitwise()})};let e=this.parseDisjunction();return delete this._constructor.NO_PAREN_FUNCTION_PARSERS.PRIOR,e}parseConnect(e={}){let{skipStartToken:t=!1}=e,s;if(t)s=void 0;else if(this.match("startWith"))s=this.parseDisjunction();else return;this.match("connectBy");let r=this.matchTextSeq("NOCYCLE")||void 0,i=this.parseConnectWithPrior();return!s&&this.match("startWith")&&(s=this.parseDisjunction()),this.expression(Iy,{start:s,connect:i,nocycle:r})}parseNameAsExpression(){let e=this.parseIdVar({anyToken:!0});return this.match("alias")&&(e=this.expression(Re,{alias:e,this:this.parseDisjunction()})),e}parseInterpolate(){if(this.matchTextSeq("INTERPOLATE"))return this.parseWrappedCsv(()=>this.parseNameAsExpression())}parseOrder(e={}){let{thisExpr:t,skipOrderToken:s=!1}=e,r;if(!s&&!this.match("orderBy")){if(!this.match("orderSiblingsBy"))return t;r=!0}return this.expression(Ie,{comments:this.prevComments,this:t,expressions:this.parseCsv(()=>this.parseOrdered()),siblings:r})}parseSort(e,t){if(this.match(t))return this.expression(e,{expressions:this.parseCsv(()=>this.parseOrdered())})}parseOrdered(e){let t=e?e():this.parseDisjunction();if(!t)return;let s=t;t.name?.toUpperCase()==="ALL"&&this._dialectConstructor.SUPPORTS_ORDER_BY_ALL&&(s=Z("ALL"));let r=this.match("asc")||void 0,i=this.match("desc")||void 0||r&&!1,o=this.matchTextSeq(["NULLS","FIRST"])||void 0,c=this.matchTextSeq(["NULLS","LAST"])||void 0,p=o||!1;!(o||c)&&(!i&&this._dialectConstructor.NULL_ORDERING==="nulls_are_small"||i&&this._dialectConstructor.NULL_ORDERING!=="nulls_are_small")&&this._dialectConstructor.NULL_ORDERING!=="nulls_are_last"&&(p=!0);let h;return this.matchTextSeq(["WITH","FILL"])&&(h=this.expression(jy,{from:this.match("from")&&this.parseBitwise(),to:this.matchTextSeq("TO")&&this.parseBitwise(),step:this.matchTextSeq("STEP")&&this.parseBitwise(),interpolate:this.parseInterpolate()})),this.expression(hs,{this:s,desc:i,nullsFirst:p,withFill:h})}parseLimitOptions(){let e=this.matchSet(new Set(["percent","mod"]))||void 0,t=this.matchSet(new Set(["row","rows"]))||void 0;this.matchTextSeq("ONLY");let s=this.matchTextSeq(["WITH","TIES"])||void 0;if(e||t||s)return this.expression(Hy,{percent:e,rows:t,withTies:s})}parseLimit(e,t={}){let{top:s=!1,skipLimitToken:r=!1}=t;if(r||this.match(s?"top":"limit")){let i=this.prevComments,o;if(s){let h=this.match("lParen")||void 0;o=h?this.parseTerm():this.parseNumber(),h&&this.matchRParen()}else{let h=this.index;o=this.tryParse(()=>this.parseTerm()),o instanceof jr?(this.retreat(h),o=this.parseFactor()):o||(o=this.parseFactor())}let c=this.parseLimitOptions(),p;return this.match("comma")&&(p=o,o=this.parseTerm()),this.expression(kt,{this:e,expression:o,offset:p,comments:i,limitOptions:c,expressions:this.parseLimitBy()})}if(this.match("fetch")){let o=this.matchSet(new Set(["first","next"]))||void 0?(this.prev?.text??"").toUpperCase():"FIRST",c=this.parseField({tokens:this._constructor.FETCH_TOKENS});return this.expression(hr,{direction:o,count:c,limitOptions:this.parseLimitOptions()})}return e}parseOffset(e){if(!this.match("offset"))return e;let t=this.parseTerm();return this.matchSet(new Set(["row","rows"])),this.expression(Cn,{this:e,expression:t,expressions:this.parseLimitBy()})}canParseLimitOrOffset(){if(!this.matchSet(new Set(this._constructor.AMBIGUOUS_ALIAS_TOKENS),{advance:!1}))return!1;let e=this.index,t=!!(this.tryParse(()=>this.parseLimit(),{retreat:!0})||this.tryParse(()=>this.parseOffset(),{retreat:!0}));return this.retreat(e),this.next&&this.next.tokenType==="matchCondition"?!1:t}parseLimitBy(){return this.matchTextSeq("BY")?this.parseCsv(()=>this.parseBitwise()):void 0}parseLocks(){let e=[];for(;;){let t,s;if(this.matchTextSeq(["FOR","UPDATE"]))t=!0;else if(this.matchTextSeq(["FOR","SHARE"])||this.matchTextSeq(["LOCK","IN","SHARE","MODE"]))t=!1;else if(this.matchTextSeq(["FOR","KEY","SHARE"]))t=!1,s=!0;else if(this.matchTextSeq(["FOR","NO","KEY","UPDATE"]))t=!0,s=!0;else break;let r;this.matchTextSeq("OF")&&(r=this.parseCsv(()=>this.parseTable({schema:!0})));let i;this.matchTextSeq("NOWAIT")?i=!0:this.matchTextSeq("WAIT")?i=this.parsePrimary():this.matchTextSeq(["SKIP","LOCKED"])&&(i=!1),e.push(this.expression(BA,{update:t,expressions:r,wait:i,key:s}))}return e}parseSetOperation(e,t={}){let{consumePipe:s=!1}=t,r=this.index,{side:i,kind:o}=this.parseJoinParts(),c=st(Yt,i?.text),p=st(dM,o?.text);if(!this.matchSet(this._constructor.SET_OPERATIONS)){this.retreat(r);return}let u=this.prev?.tokenType,h;u==="union"?h=or:u==="except"?h=cr:h=ei;let g=this.prev?.comments,f;this.match("distinct")?f=!0:this.match("all")?f=!1:(f=this._dialectConstructor.SET_OP_DISTINCT_BY_DEFAULT[h.key],f===void 0&&this.raiseError(`Expected DISTINCT or ALL for ${h.name}`,this.curr));let x=this.matchTextSeq(["BY","NAME"])||this.matchTextSeq(["STRICT","CORRESPONDING"])||void 0;this.matchTextSeq("CORRESPONDING")&&(x=!0,!c&&!p&&(p="inner"));let T;x&&this.matchTexts(["ON","BY"])&&(T=this.parseWrappedCsv(()=>this.parseColumn()));let y=this.parseSelect({nested:!0,parseSetOperation:!1,consumePipe:s});return this.expression(h,{comments:g,this:e,distinct:f,byName:x,expression:y,side:c,kind:p,on:T})}parseSetOperations(e){let t=e;for(;t;){let s=this.parseSetOperation(t);if(!s)break;t=s}if(t instanceof Ge&&this._constructor.MODIFIERS_ATTACHED_TO_SET_OP){let s=t.args.expression;if(s)for(let r of this._constructor.SET_OP_MODIFIERS){let i=s.args[r];i instanceof d&&t.setArgKey(r,i.pop())}}return t}parseExpression(){return this.parseAlias(this.parseAssignment())}parseAssignment(){let e=this.parseDisjunction();if(!e&&this.next&&this.next.tokenType in this._constructor.ASSIGNMENT){let s=this.advanceAny({ignoreReserved:!0});e=$n({col:s&&this.prev?.text})}let t=Object.keys(this._constructor.ASSIGNMENT);for(;this.matchSet(t);)e instanceof $&&e.parts.length===1&&(e=e.args.this),e=this.expression(this._constructor.ASSIGNMENT[this.prev.tokenType],{this:e,comments:this.prevComments,expression:this.parseAssignment()});return e}parseDisjunction(){let e=this.parseConjunction();for(;this.matchSet(Object.keys(this._constructor.DISJUNCTION));){let t=this.prevComments,s=this._constructor.DISJUNCTION[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseConjunction(),comments:t}))}return e}parseConjunction(){let e=this.parseEquality();for(;this.matchSet(Object.keys(this._constructor.CONJUNCTION));){let t=this.prevComments,s=this._constructor.CONJUNCTION[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseEquality(),comments:t}))}return e}parseEquality(){let e=this.parseComparison();for(;this.matchSet(Object.keys(this._constructor.EQUALITY));){let t=this.prevComments,s=this._constructor.EQUALITY[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseComparison(),comments:t}))}return e}parseComparison(){let e=this.parseRange();for(;this.matchSet(Object.keys(this._constructor.COMPARISON));){let t=this.prevComments,s=this._constructor.COMPARISON[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseRange(),comments:t}))}return e}parseRange(e){let t=e||this.parseBitwise(),s=this.match("not")||void 0;if(this.matchSet(Object.keys(this._constructor.RANGE_PARSERS))){let r=this._constructor.RANGE_PARSERS[this.prev?.tokenType??"unknown"];if(r&&t){let i=r.call(this,t);if(!i)return t;t=i}}else(this.match("isnull")||s&&this.match("null"))&&(t=this.expression(ze,{this:t,expression:le()}));return this.match("notnull")&&(t=this.expression(ze,{this:t,expression:le()}),t=this.expression(Le,{this:t})),s&&(t=this.negateRange(t)),this.match("is")&&(t=this.parseIs(t)),t}negateRange(e){return e&&this.expression(Le,{this:e})}parseIs(e){let t=this.index-1,s=this.match("not")||void 0;if(this.matchTextSeq(["DISTINCT","FROM"])){let o=s?Ks:Ur;return this.expression(o,{this:e,expression:this.parseBitwise()})}let r;if(this.match("json")){let o=(this.matchTexts(Array.from(this._constructor.IS_JSON_PREDICATE_KIND))||void 0)&&(this.prev?.text??"").toUpperCase(),c;this.matchTextSeq("WITH")?c=!0:this.matchTextSeq("WITHOUT")&&(c=!1);let p=this.match("unique")||void 0;this.matchTextSeq("KEYS"),r=this.expression(TC,{this:o,with:c,unique:p})}else if(r=this.parseNull()||this.parseBitwise(),!r){this.retreat(t);return}let i=this.expression(ze,{this:e,expression:r});return s?this.expression(Le,{this:i}):this.parseColumnOps(i)}parseIn(e,t={}){let{alias:s=!1}=t,r=this.parseUnnest({withAlias:!1}),i;if(r)i=this.expression(lt,{this:e,unnest:r});else if(this.matchSet(new Set(["lParen","lBracket"]))){let o=this.prev?.tokenType==="lParen",c=this.parseCsv(()=>this.parseSelectOrExpression({alias:s}));if(c.length===1&&c[0]instanceof ee){let p=c[0],h=this.parseQueryModifiers(p).subquery(void 0,{copy:!1});i=this.expression(lt,{this:e,query:h})}else i=this.expression(lt,{this:e,expressions:c});o?this.matchRParen(i):this.match("rBracket",{expression:i})||this.raiseError("Expecting ]",this.curr)}else i=this.expression(lt,{this:e,field:this.parseColumn()});return i}parseBetween(e){let t;this.matchTextSeq("SYMMETRIC")?t=!0:this.matchTextSeq("ASYMMETRIC")&&(t=!1);let s=this.parseBitwise();this.match("and");let r=this.parseBitwise();return this.expression(Ts,{this:e,low:s,high:r,symmetric:t})}parseEscape(e){return this.match("escape")?this.expression(Ba,{this:e,expression:this.parseString()||this.parseNull()}):e}parseIntervalSpan(e){let t;if(e&&e.isString&&this._constructor.SUPPORTS_OMITTED_INTERVAL_SPAN_UNIT&&e.name?.match?.(yD)){let i=this.index,o=this.parseVar({anyToken:!0,upper:!0}),c;o&&this.matchTextSeq("TO")&&(c=this.parseVar({anyToken:!0,upper:!0})),t=!(o&&c),this.retreat(i)}let s=t?void 0:this.parseFunction()||!this.matchSet(["alias","dcolon"],{advance:!1})&&this.parseVar({anyToken:!0,upper:!0})||void 0,r=e;if(e&&e.isNumber)r=N.string(e.toValue()||e.sql());else if(e&&e.isString){let i=Array.from(e.name?.matchAll(new RegExp(ID,"g"))||[]);0<i.length&&s&&(s=void 0,this.retreat(this.index-1)),i.length===1&&(r=N.string(i[0][1]),s=this.expression(Ve,{this:i[0][2].toUpperCase()}))}return this._constructor.INTERVAL_SPANS&&this.matchTextSeq("TO")&&(s=this.expression(Wr,{this:s,expression:this.parseFunction()||this.parseVar({anyToken:!0,upper:!0})})),this.expression(qe,{this:r,unit:s})}parseInterval(e={}){let{matchInterval:t=!0}=e,s=this.index;if(!this.match("interval")&&t)return;let r;if(this.match("string",{advance:!1})?r=this.parsePrimary():r=this.parseTerm(),!r||r instanceof $&&!r.args.table&&r.args.this instanceof v&&!r.args.this.args.quoted&&this.curr&&!this._dialectConstructor.VALID_INTERVAL_UNITS.has(this.curr.text.toUpperCase())){this.retreat(s);return}let i=this.parseIntervalSpan(r),o=this.index;return this.match("plus"),this.matchSet(new Set(["string","number"]),{advance:!1})?this.expression(we,{this:i,expression:this.parseInterval({matchInterval:!1})}):(this.retreat(o),i)}parseBitwise(){let e=this.parseTerm(),t=Object.keys(this._constructor.BITWISE);for(;;)if(this.matchSet(t)){let s=this._constructor.BITWISE[this.prev?.tokenType??"unknown"];s&&(e=this.expression(s,{this:e,expression:this.parseTerm()}))}else if(this._dialectConstructor.DPIPE_IS_STRING_CONCAT&&this.match("dpipe"))e=this.expression(Wt,{this:e,expression:this.parseTerm(),safe:!this._dialectConstructor.STRICT_STRING_CONCAT});else if(this.match("dqmark"))e=this.expression(tt,{this:e,expressions:J(this.parseTerm())});else if(this.matchPair("lt","lt"))e=this.expression(jC,{this:e,expression:this.parseTerm()});else if(this.matchPair("gt","gt"))e=this.expression(ih,{this:e,expression:this.parseTerm()});else break;return e}parseTerm(){let e=this.parseFactor(),t=Object.keys(this._constructor.TERM);for(;this.matchSet(t);){let s=this._constructor.TERM[this.prev?.tokenType??"unknown"],r=this.prevComments,i=this.parseFactor();if(s&&(e=this.expression(s,{this:e,comments:r,expression:i}),e instanceof MA)){let o=e.args.expression;if(o instanceof $&&o.parts.length===1){let c=o.args.this;c instanceof v&&e.setArgKey("expression",c.args.quoted?c:Z(c.name))}}}return e}parseFactor(){let e=this._constructor.EXPONENT?()=>this.parseExponent():()=>this.parseUnary(),t=this.parseAtTimeZone(e()),s=Object.keys(this._constructor.FACTOR);for(;this.matchSet(s);){let r=this._constructor.FACTOR[this.prev?.tokenType??"unknown"],i=this.prevComments,o=e();if(!o&&r===Un&&/^[a-zA-Z]/.test(this.prev?.text??""))return this.retreat(this.index-1),t;r&&(t=this.expression(r,{this:t,comments:i,expression:o}),t instanceof wt&&(t.setArgKey("typed",this._dialectConstructor.TYPED_DIVISION),t.setArgKey("safe",this._dialectConstructor.SAFE_DIVISION)))}return t}parseExponent(){let e=this.parseUnary();for(;this.matchSet(Object.keys(this._constructor.EXPONENT));){let t=this.prevComments,s=this._constructor.EXPONENT[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseUnary(),comments:t}))}return e}parseUnary(){if(this.matchSet(Object.keys(this._constructor.UNARY_PARSERS))){let e=this._constructor.UNARY_PARSERS[this.prev?.tokenType??"unknown"];return e?e.call(this):void 0}return this.parseType()}parseType(e={}){let{parseInterval:t=!0,fallbackToIdentifier:s=!1}=e;if(!s){let c=this.parseAtom();if(c!==void 0)return c}let r=t&&this.parseInterval();if(r)return this.parseColumnOps(r);let i=this.index,o=this.parseTypes({checkFunc:!0,allowIdentifiers:!1});if(o instanceof z)return this.parseColumnOps(o);if(o){let c=this.index,p=this.parsePrimary();if(p instanceof N){let u=p.name,h=this.parseColumnOps(p),g=typeof o.args.this=="string"?this._constructor.TYPE_LITERAL_PARSERS[o.args.this]:void 0;return g?g.call(this,h,o):(this._constructor.ZONE_AWARE_TIMESTAMP_CONSTRUCTOR&&o.isType?.(["timestamp"])&&JW.test(u)&&o.setArgKey("this","timestamptz"),this.expression(z,{this:h,to:o}))}if(o.args.expressions&&1<c-i)return this.retreat(c),this.parseColumnOps(o);this.retreat(i)}return s?this.parseIdVar():this.parseColumn()}parseTypeSize(){let e=this.parseType();if(e)return e instanceof $&&!e.args.table&&(e=Z(e.name.toUpperCase())),this.expression(Jr,{this:e,expression:this.parseVar({anyToken:!0})})}parseUserDefinedType(e){let t=e.name;for(;this.match("dot");)this.advanceAny(),t=`${t}.${this.prev?.text??""}`;return m.build(t,{dialect:this.dialect,udt:!0})}parseTypes(e={}){let{checkFunc:t=!1,schema:s=!1,allowIdentifiers:r=!0}=e,i=this.index,o,c=this.matchTextSeq(["SYSUDTLIB","."])||void 0,p,u;if(this.matchSet(this._constructor.TYPE_TOKENS))p=this.prev?.tokenType,u=this.prev?.text;else{let b=r&&this.parseIdVar({anyToken:!1,tokens:new Set(["var"])});if(b instanceof v){let k;try{k=this.dialect.tokenize?.(b.name)}catch{k=void 0}if(k&&this._constructor.TYPE_TOKENS.has(k[0].tokenType)){if(1<k.length)return m.build(b.name,{dialect:this.dialect});p=k[0].tokenType,u=k[0].text}else if(this._dialectConstructor.SUPPORTS_USER_DEFINED_TYPES)o=this.parseUserDefinedType(b);else{this.retreat(this.index-1);return}}else return}if(p==="pseudoType")return this.expression(HC,{this:(this.prev?.text??"").toUpperCase()});if(p==="objectIdentifier")return this.expression(_C,{this:(this.prev?.text??"").toUpperCase()});if(p==="map"&&this.match("lBracket")){let b=this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r});if(!this.match("farrow")){this.retreat(i);return}let k=this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r});if(!this.match("rBracket")){this.retreat(i);return}return new m({this:"map",expressions:[b,k],nested:!0,prefix:c})}let h=p&&this._constructor.NESTED_TYPE_TOKENS.has(p),g=p&&this._constructor.STRUCT_TYPE_TOKENS.has(p),f=p&&this._constructor.AGGREGATE_TYPE_TOKENS.has(p),x,T=!1;if(this.match("lParen")){if(g)x=this.parseCsv(()=>this.parseStructTypes({typeRequired:!0}));else if(h){if(x=this.parseCsv(()=>this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r})),p==="nullable"&&x.length===1)return o=x[0],o.setArgKey("nullable",!0),this.matchRParen(),o}else if(p&&this._constructor.ENUM_TYPE_TOKENS.has(p))x=this.parseCsv(()=>this.parseEquality());else if(p==="json")x=this.parseCsv(()=>this.parseJsonTypeArg());else if(f){let b=this.parseFunction({anonymous:!0})||this.parseIdVar({anyToken:!1,tokens:new Set(["var","any"])});if(!b)return;x=[b],this.match("comma")&&x.push(...this.parseCsv(()=>this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r})))}else x=this.parseCsv(()=>this.parseTypeSize()),p==="vector"&&x.length===2&&(x=this.parseVectorExpressions(x));if(!this.match("rParen")){this.retreat(i);return}T=!0}let y;if(h&&this.match("lt")&&(g?x=this.parseCsv(()=>this.parseStructTypes({typeRequired:!0})):x=this.parseCsv(()=>this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r})),this.match("gt")||this.raiseError("Expecting >",this.curr),this.matchSet(new Set(["lBracket","lParen"]))&&(y=this.parseCsv(()=>this.parseDisjunction()),!y&&g?(y=void 0,this.retreat(this.index-1)):this.matchSet(new Set(["rBracket","rParen"])))),p&&this._constructor.TIMESTAMPS.has(p))if(this.matchTextSeq(["WITH","TIME","ZONE"])){T=!1;let b=this._constructor.TIMES.has(p)?"timetz":"timestamptz";o=new m({this:b,expressions:x})}else this.matchTextSeq(["WITH","LOCAL","TIME","ZONE"])?(T=!1,o=new m({this:"timestampltz",expressions:x})):this.matchTextSeq(["WITHOUT","TIME","ZONE"])&&(T=!1);else if(p==="interval")if(this.curr&&this._dialectConstructor.VALID_INTERVAL_UNITS.has(this.curr.text.toUpperCase())){let b=this.parseVar({upper:!0});this.matchTextSeq("TO")&&(b=new Wr({this:b,expression:this.parseVar({upper:!0})})),o=this.expression(m,{this:new qe({unit:b})})}else o=this.expression(m,{this:"interval"});else p==="void"&&(o=new m({this:"null"}));if(T&&t){let b=this.index;if(!this.parseString()){this.retreat(i);return}this.retreat(b)}if(o)x&&o.setArgKey("expressions",x);else{if(this.matchTextSeq("UNSIGNED")){let b=p&&this._constructor.SIGNED_TO_UNSIGNED_TYPE_TOKEN[p];b||this.raiseError(`Cannot convert ${p?.valueOf()} to unsigned.`,this.curr),p=b||p}if(p==="nullable"&&!x){this.retreat(i);return}if(p&&(o=new m({this:At[bM(p)],expressions:x,nested:h,prefix:c}),y!==void 0)){let b=g?Es:ue;o=X(new b({expressions:y}),o,{copy:!1})}}for(;this.match("list");)o=new m({this:"list",expressions:[o],nested:!0});let C=this.index,I=this.match("array")||!1;for(;this.curr;){let b=this.prev?.tokenType;if(!(this.match("lBracket")||void 0)&&!I||b==="array"&&this.match("rBracket"))break;I=!1;let B=this.parseCsv(()=>this.parseDisjunction());if(0<B.length&&!s&&(!this._dialectConstructor.SUPPORTS_FIXED_SIZE_ARRAYS||b==="array"||!this.match("rBracket",{advance:!1}))){this.retreat(C);break}o=new m({this:"array",expressions:[o],values:B,nested:!0}),this.match("rBracket")}if(o&&this._constructor.TYPE_CONVERTERS&&typeof o.args.this=="string"){let b=this._constructor.TYPE_CONVERTERS[o.args.this];b&&(o=b(o))}return o}parseJsonTypeArg(){if(this.matchTextSeq("SKIP")){let r=this.match("rlike"),i=this.parseColumn();return i instanceof $&&(i=i.toDot?.()??i),this.expression(Xy,{regexp:r,expression:i})}let e=this.parseColumn();if(!(e instanceof $))return;if(e.parts.length===1&&this.match("eq")){let r=e.name,i=this.parsePrimary();return this.expression(Me,{this:Z(r),expression:i})}let t=e.toDot?.()??e,s=this.parseTypes({checkFunc:!1,allowIdentifiers:!1});return this.expression(be,{this:t,kind:s})}parseVectorExpressions(e){let t=m.build(e[0].name,{dialect:this.dialect});return[...t?[t]:[],...e.slice(1)]}parseStructTypes(e={}){let{typeRequired:t=!1}=e,s=this.index,r;return this.curr&&this.next&&this._constructor.TYPE_TOKENS.has(this.curr.tokenType)&&this._constructor.TYPE_TOKENS.has(this.next.tokenType)?r=this.parseIdVar():r=this.parseType({parseInterval:!1,fallbackToIdentifier:!0})||this.parseIdVar(),this.match("colon"),t&&!(r instanceof m)&&!this.matchSet(this._constructor.TYPE_TOKENS,{advance:!1})?(this.retreat(s),this.parseTypes()):this.parseColumnDef(r)}parseAtTimeZone(e){return this.matchTextSeq(["AT","TIME","ZONE"])?this.parseAtTimeZone(this.expression(gs,{this:e,zone:this.parseUnary()})):e}parseAtom(){if(!this.curr)return;if(this.curr.tokenType in this._constructor.FAST_COLUMN_TOKENS){let i=this.parseColumn();if(i!==void 0)return i}let e=this.curr,t=e.tokenType,s=this._constructor.PRIMARY_PARSERS[t];if(!s)return;let r=this.next?.tokenType;if(!(r!==void 0&&(r in this._constructor.COLUMN_OPERATORS||this._constructor.COLUMN_POSTFIX_TOKENS.has(r)||t==="string"&&r==="string")))return this.advance(),s.call(this,e)}parseColumn(){let e=this.parseColumnFastPath();if(e===void 0){let t=this.parseColumnReference();t||(t=this.parseBracket(t)),e=t&&this.parseColumnOps(t)}return e&&(this._dialectConstructor.SUPPORTS_COLUMN_JOIN_MARKS&&e.setArgKey("joinMark",this.match("joinMarker")),this._constructor.COLON_IS_VARIANT_EXTRACT&&(e=this.parseColonAsVariantExtract(e))),e}parseColumnFastPath(){let e=this.index,t,s;for(;this.matchSet(this._constructor.FAST_COLUMN_TOKENS);){let o=this.prev,c=this.prevComments;if(t===void 0&&o.text.toUpperCase()in this._constructor.NO_PAREN_FUNCTION_PARSERS){this.retreat(e);return}let p=this.match("dot"),u=this.curr?.tokenType;if(p){if(u===void 0||!this._constructor.FAST_COLUMN_TOKENS.has(u)){this.retreat(e);return}}else if(u!==void 0&&(u in this._constructor.COLUMN_OPERATORS||this._constructor.COLUMN_POSTFIX_TOKENS.has(u))){this.retreat(e);return}t===void 0&&(t=[]),c&&0<c.length&&(s===void 0&&(s=[]),s.push(...c),this.prevComments=[]);let h=new v({this:o.text,quoted:o.tokenType==="identifier"});if(h.updatePositions(o),t.push(h),!p)break}if(t===void 0)return;let r=t.length,i;if(r===1)i=new $({this:t[0]});else if(r===2)i=new $({this:t[1],table:t[0]});else if(r===3)i=new $({this:t[2],table:t[1],db:t[0]});else{i=new $({this:t[3],table:t[2],db:t[1],catalog:t[0]});for(let o=4;o<r;o++)i=new ge({this:i,expression:t[o]})}return s&&i.addComments(s),i}parseColumnReference(){let e=this.parseField();return!e&&this.match("values",{advance:!1})&&this._constructor.VALUES_FOLLOWED_BY_PAREN&&(!this.next||this.next.tokenType!=="lParen")&&(e=this.parseIdVar()),e instanceof v&&(e=this.expression($,{comments:e.popComments(),this:e})),e}buildJsonExtract(e,t,s){return 1<t.length&&(e=this.expression(ms,{this:e,expression:new Er({expressions:t,escape:s}),variantExtract:!0,requiresJson:this._constructor.JSON_EXTRACT_REQUIRES_JSON_EXPRESSION}),t=[new zt]),[e,t]}parseColonAsVariantExtract(e){let t=[new zt],s;for(;this.match("colon");){let r=this.parseIdVar({anyToken:!0,tokens:new Set(["select"])});for(r&&(r instanceof v&&r.args.quoted&&(s=!0),t.push(new Mt({this:r.name})));;)if(this.match("dot")){let i=this.parseIdVar({anyToken:!0,tokens:new Set(["select"])});i&&(i instanceof v&&i.args.quoted&&(s=!0),t.push(new Mt({this:i.name})))}else if(this.match("lBracket")){let i=this.parseBracketKeyValue();this.match("rBracket")||this.raiseError("Expected ]"),i&&(i.isString?(t.push(new Mt({this:i.name})),s=!0):i.isStar?t.push(new ts({this:new Dt})):i.isNumber?t.push(new ts({this:i.toValue()})):([e,t]=this.buildJsonExtract(e,t,s),s=void 0,e=this.expression(Lt,{this:e,expressions:[i],jsonAccess:!0})))}else if(this.match("dcolon")){[e,t]=this.buildJsonExtract(e,t,s),s=void 0;let i=this.parseTypes();i?e=this.expression(z,{this:e,to:i}):this.raiseError("Expected type after '::'")}else break}return[e]=this.buildJsonExtract(e,t,s),e}parseDcolon(){return this.parseTypes()}parseColumnOps(e){let t=e;for(;this.curr&&this._constructor.BRACKETS.has(this.curr.tokenType);)t=this.parseBracket(t);for(;this.matchSet(Object.keys(this._constructor.COLUMN_OPERATORS));){let s=this.prev?.tokenType??"unknown",r=this._constructor.COLUMN_OPERATORS[s],i;if(this._constructor.CAST_COLUMN_OPERATORS.has(s)?(i=this.parseDcolon(),i||this.raiseError("Expected type",this.curr)):r&&this.curr?(i=this.parseColumnReference()||this.parseBitwise(),i instanceof $&&this.match("dot",{advance:!1})&&(i=this.parseColumnOps(i))):i=this.parseField({anyToken:!0,anonymousFunc:!0}),(i instanceof E||i instanceof Ue)&&t&&(t=t.transform(o=>o instanceof $&&o.toDot?.({includeDots:!1})||o)),r)t=r.call(this,t,i);else if(t instanceof $&&!t.args.catalog)t=this.expression($,{comments:t.comments,this:i,table:t.args.this,db:t.args.table,catalog:t.args.db});else if(i instanceof Ue){let o=this.expression(ge,{this:t,expression:i.args.this});i.setArgKey("this",o),t=i}else t=this.expression(ge,{this:t,expression:i});i?.comments&&t?.addComments?.(i.popComments()),t=this.parseBracket(t)}return t}parseComment(e={}){let{allowExists:t=!0}=e,s=this.prev,r=t?this.parseExists():void 0;this.match("on");let i=this.matchTextSeq("MATERIALIZED")||void 0,o=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev;if(!o)return this.parseAsCommand(s);let c;return o.tokenType==="function"||o.tokenType==="procedure"?c=this.parseUserDefinedFunction({kind:o.tokenType}):o.tokenType==="table"?c=this.parseTable({aliasTokens:this._constructor.COMMENT_TABLE_ALIAS_TOKENS}):o.tokenType==="column"?c=this.parseColumn():c=this.parseIdVar(),this.match("is"),this.expression(Ry,{this:c,kind:o.text,expression:this.parseString(),exists:r,materialized:i})}parseToTable(){let e=this.parseTableParts({schema:!0});return this.expression(aa,{this:e})}parseTtl(){let e=n(()=>{let o=this.parseBitwise();return this.matchTextSeq("DELETE")?this.expression(In,{this:o,delete:!0}):this.matchTextSeq("RECOMPRESS")?this.expression(In,{this:o,recompress:this.parseBitwise()}):this.matchTextSeq(["TO","DISK"])?this.expression(In,{this:o,toDisk:this.parseString()}):this.matchTextSeq(["TO","VOLUME"])?this.expression(In,{this:o,toVolume:this.parseString()}):o},"parseTtlAction"),t=this.parseCsv(e),s=this.parseWhere(),r=this.parseGroup(),i;return r&&this.match("set")&&(i=this.parseCsv(this.parseSetItem.bind(this))),this.expression(Pn,{expressions:t,where:s,group:r,aggregates:i})}parseCondition(){return this.parseWrapped(()=>this.parseExpression(),{optional:!0})}parseBlock(){return this.expression($A,{expressions:this.parseBatchStatements(e=>e.parseStatement())})}parseWhileBlock(){return this.expression(PC,{this:this.parseCondition(),body:this.parseBlock()})}parseBatchStatements(e,t={}){let{sepFirstStatement:s=!0}=t,r=[];s&&(this.match("begin"),r.push(e(this)));let i=this._chunks.length;for(;this._chunkIndex<i;){if(this.advanceChunk(),this.match("else",{advance:!1}))return r;if(r.length&&!this.next&&this.match("end")){r.push(new du);continue}r.push(e(this)),this.index<this.tokens.length&&this.raiseError("Invalid expression / Unexpected token"),this.checkErrors()}return r}advanceChunk(){this.index=-1,this.tokens=this._chunks[this._chunkIndex],this._chunkIndex+=1,this.advance()}parseStatement(){if(this.curr===void 0)return;let e=Object.keys(this._constructor.STATEMENT_PARSERS);if(this.matchSet(e)){let s=this.prevComments,r=this._constructor.STATEMENT_PARSERS[this.prev?.tokenType??"unknown"]?.call(this);return r?.addComments(s,{prepend:!0}),r}if(this.matchSet(this._dialectConstructor.tokenizerClass.COMMANDS))return this.parseCommand();if(this.matchTextSeq("WHILE"))return this.parseWhileBlock();let t=this.parseExpression();return t=t?this.parseSetOperations(t):this.parseSelect(),t instanceof he&&this.match("pipeGt",{advance:!1})&&(t=this.parsePipeSyntaxQuery(t)),this.parseQueryModifiers(t)}parsePartitionedByBucketOrTruncate(){if(this.curr?.tokenType!=="lParen"){this.retreat(this.index-1);return}let e=this.prev?.text.toUpperCase()==="BUCKET"?Xu:Ju,t=this.parseWrappedCsv(()=>this.parsePrimary()||this.parseColumn()),s=D(t,0),r=D(t,1);return s instanceof N&&([s,r]=[r,s]),this.expression(e,{this:s,expression:r})}raiseError(e,t){let s=t||this.curr||this.prev||KI.string(""),{formattedSql:r,startContext:i,highlight:o,endContext:c}=aG({sql:this.sql,positions:[[s.start??0,s.end??0]],contextLength:this.errorMessageContext}),p=`${e}. Line ${s.line}, Col: ${s.col}.
|
|
5
|
-
${r}`,u=new Ke(p,[{description:e,line:s.line,col:s.col,startContext:i,highlight:o,endContext:c}]);if(this.errorLevel===3)throw u;this.errors.push(u)}checkErrors(){if(this.errorLevel===1)for(let e of this.errors)console.error(e.toString());else if(this.errorLevel===2&&0<this.errors.length)throw new Ke(gM(this.errors,this.maxErrors),Wk(this.errors))}expression(e,t={}){let{token:s,comments:r,...i}=t,o;return s?(o=new e({this:s.text,...i}),o.updatePositions(s)):o=new e(i),r?.length?o.addComments(r):this.addComments(o),this.validateExpression(o)}addComments(e){e&&this.prevComments?.length&&(e.addComments(this.prevComments),this.prevComments=void 0)}parseIdVar(e={}){let{anyToken:t=!0,tokens:s}=e,r=this.parseIdentifier();if(!r&&(t&&this.advanceAny()||this.matchSet(s||this._constructor.ID_VAR_TOKENS))){let i=this.prev?.tokenType==="string";r=this.identifierExpression(void 0,{quoted:i})}return r}parseGrantPrincipal(){let e=(this.matchTexts(["ROLE","GROUP"])||void 0)&&this.prev?.text.toUpperCase(),t=this.parseIdVar();if(t)return this.expression(zy,{this:t,kind:e})}parseGrantPrivilege(){let e=[];for(;this.curr&&!this.matchSet(this._constructor.PRIVILEGE_FOLLOW_TOKENS,{advance:!1});)e.push(this.curr.text.toUpperCase()),this.advance();let t=this.expression(Ve,{this:e.join(" ")}),s=this.match("lParen",{advance:!1})?this.parseWrappedCsv(()=>this.parseColumn()):void 0;return this.expression(Jy,{this:t,expressions:s})}matchTexts(e,t={}){let{advance:s=!0}=t,r=Array.from(e instanceof Set?e:J(e));return this.curr&&this.curr.tokenType!=="string"&&r.includes(this.curr.text.toUpperCase())?(s&&this.advance(),!0):!1}matchSet(e,t={}){let{advance:s=!0}=t;return this.curr&&(Array.isArray(e)?e.includes(this.curr.tokenType):e.has(this.curr.tokenType))?(s&&this.advance(),!0):!1}matchPair(e,t,s={}){let{advance:r=!0}=s;return!this.curr||!this.next?!1:this.curr.tokenType===e&&this.next.tokenType===t?(r&&this.advance(2),!0):!1}matchLParen(e){this.match("lParen",{advance:!0,expression:e})||this.raiseError("Expecting (")}matchRParen(e){this.match("rParen",{advance:!0,expression:e})||this.raiseError("Expecting )")}matchTextSeq(e,t={}){let{advance:s=!0}=t,r=J(e),i=this.index;for(let o of r)if(this.curr&&this.curr.tokenType!=="string"&&this.curr.text.toUpperCase()===o)this.advance();else return this.retreat(i),!1;return s||this.retreat(i),!0}replaceLambda(e,t){if(!e)return e;let s={};for(let r of t)s[r.name]=r.args.to||!1;for(let r of e.findAll($)){let i=s[r.parts[0]?.name||""];if(i!==void 0){let o=r.args.this;re(o,v);let c=r.table?r.toDot():o;i&&(c=this.expression(z,{this:c,to:i}));let p=r.parent;for(;p instanceof ge;){if(!(p.parent instanceof ge)){p.replace(c);break}p=p.parent}(!p||!(p instanceof ge))&&(r===e?e=c:r.replace(c))}}return e}parseTruncateTable(){let e=this.prev;if(this.match("lParen"))return this.retreat(this.index-2),this.parseFunction();let t=this.match("database")||void 0;this.match("table");let s=this.parseExists({not:!1}),r=this.parseCsv(()=>this.parseTable({schema:!0,isDbReference:t})),i=this.match("on")?this.parseOnProperty():void 0,o;this.matchTextSeq(["RESTART","IDENTITY"])?o="RESTART":this.matchTextSeq(["CONTINUE","IDENTITY"])?o="CONTINUE":o=void 0;let c;this.matchTextSeq("CASCADE")||this.matchTextSeq("RESTRICT")?c=this.prev?.text:c=void 0;let p=this.parsePartition();return this.curr?this.parseAsCommand(e):this.expression(ly,{expressions:r,isDatabase:t,exists:s,cluster:i,identity:o,option:c,partition:p})}parseWithOperator(){let e=this.parseOrdered(()=>this.parseOpClass());if(!this.match("with"))return e;let t=this.parseVar({anyToken:!0,tokens:this._constructor.RESERVED_TOKENS});return this.expression(eu,{this:e,op:t})}parseWrappedOptions(){this.match("eq"),this.match("lParen");let e=[],t;for(;this.curr&&!this.match("rParen");){if(this.matchTextSeq(["FORMAT_NAME","="])?t=this.parseFormatName():t=this.parseProperty(),t===void 0){this.raiseError("Unable to parse option");break}e.push(...Array.isArray(t)?t:[t])}return e}parseCopyParameters(){let e=this._dialectConstructor.COPY_PARAMS_ARE_CSV?"comma":void 0,t=[];for(;this.curr&&!this.match("rParen",{advance:!1});){let s=this.parseVar({anyToken:!0}),r=this.prev?.text.toUpperCase();this.match("eq"),this.match("alias");let i=this.expression(yy,{this:s});r&&this._constructor.COPY_INTO_VARLEN_OPTIONS.has(r)&&this.match("lParen",{advance:!1})?i.setArgKey("expressions",this.parseWrappedOptions()):r==="FILE_FORMAT"?i.setArgKey("expression",this.parseField()):r==="FORMAT"&&this.prev?.tokenType==="alias"&&this.matchTexts(["AVRO","JSON"])?(i.setArgKey("this",this.expression(Ve,{this:`FORMAT AS ${this.prev?.text.toUpperCase()}`})),i.setArgKey("expression",this.parseField())):i.setArgKey("expression",this.parseUnquotedField()||this.parseBracket()),t.push(i),e&&this.match(e)}return t}parseCredentials(){let e=this.expression(Cy,{});if(this.matchTextSeq(["STORAGE_INTEGRATION","="])&&e.setArgKey("storage",this.parseField()),this.matchTextSeq("CREDENTIALS")){let t=this.match("eq")?this.parseWrappedOptions():this.parseField();e.setArgKey("credentials",t)}return this.matchTextSeq("ENCRYPTION")&&e.setArgKey("encryption",this.parseWrappedOptions()),this.matchTextSeq("IAM_ROLE")&&e.setArgKey("iamRole",this.match("default")?this.expression(Ve,{this:this.prev?.text}):this.parseField()),this.matchTextSeq("REGION")&&e.setArgKey("region",this.parseField()),e}parseFileLocation(){return this.parseField()}parseCopy(){let e=this.prev;this.match("into");let t=this.match("lParen",{advance:!1})?this.parseSelect({nested:!0,parseSubqueryAlias:!1}):this.parseTable({schema:!0}),s=this.match("from")||!this.matchTextSeq("TO"),r=this.parseCsv(()=>this.parseFileLocation());this.match("eq",{advance:!1})&&(this.advance(-1),r=[]);let i=this.parseCredentials();this.matchTextSeq("WITH");let o=this.parseWrapped(()=>this.parseCopyParameters(),{optional:!0});return this.curr?this.parseAsCommand(e):this.expression(BC,{this:t,kind:s,credentials:i,files:r,params:o})}parseNormalize(){return this.expression(fb,{this:this.parseBitwise(),form:this.match("comma")&&this.parseVar()})}parseCeilFloor(e){let t=this.parseCsv(()=>this.parseLambda()),s=D(t,0),r=D(t,1);return new e({this:s,decimals:r,to:this.matchTextSeq("TO")&&this.parseVar()})}parseStarOps(){let e=this.prev;if(this.matchTextSeq(["COLUMNS","("],{advance:!1})){let t=this.parseFunction();return t instanceof tb&&t.setArgKey("unpack",!0),t}return this.expression(Ne,{except:this.parseStarOp("EXCEPT")||this.parseStarOp("EXCLUDE"),replace:this.parseStarOp("REPLACE"),rename:this.parseStarOp("RENAME")}).updatePositions(e)}parseGrantRevokeCommon(){let e=this.parseCsv(()=>this.parseGrantPrivilege());this.match("on");let t=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev?.text.toUpperCase(),s=this.tryParse(()=>this.parseTableParts());return{privileges:e,kind:t,securable:s}}parseGrant(){let e=this.prev,{privileges:t,kind:s,securable:r}=this.parseGrantRevokeCommon();if(!r||!this.matchTextSeq("TO"))return this.parseAsCommand(e);let i=this.parseCsv(()=>this.parseGrantPrincipal()),o=this.matchTextSeq(["WITH","GRANT","OPTION"])||void 0;return this.curr?this.parseAsCommand(e):this.expression($y,{privileges:t,kind:s,securable:r,principals:i,grantOption:o})}parseRevoke(){let e=this.prev,t=this.matchTextSeq(["GRANT","OPTION","FOR"])||void 0,{privileges:s,kind:r,securable:i}=this.parseGrantRevokeCommon();if(!i||!this.matchTextSeq("FROM"))return this.parseAsCommand(e);let o=this.parseCsv(()=>this.parseGrantPrincipal()),c;return this.matchTexts(["CASCADE","RESTRICT"])&&(c=this.prev?.text.toUpperCase()),this.curr?this.parseAsCommand(e):this.expression(Gy,{privileges:s,kind:r,securable:i,principals:o,grantOption:t,cascade:c})}parseOverlay(){let e=n(t=>(this.match("comma")||this.matchTextSeq(t)||void 0)&&this.parseBitwise(),"parseOverlayArg");return this.expression(xb,{this:this.parseBitwise(),expression:e("PLACING"),from:e("FROM"),for:e("FOR")})}parseFormatName(){return this.expression(w,{this:this.expression(Ve,{this:"FORMAT_NAME"}),value:this.parseString()||this.parseTableParts()})}parseMaxMinBy(e){let t=[];return this.match("distinct")&&(t.push(this.expression(et,{expressions:[this.parseLambda()]})),this.match("comma")),t.push(...this.parseFunctionArgs()),this.expression(e,{this:D(t,0),expression:D(t,1),count:D(t,2)})}identifierExpression(e,t){return this.expression(v,{token:e||this.prev,...t})}parseWrappedIdVars(e={}){let{optional:t=!1}=e;return this.parseWrappedCsv(()=>this.parseIdVar(),{optional:t})}parseWrappedCsv(e,t={}){let{sep:s="comma",optional:r=!1}=t;return this.parseWrapped(()=>this.parseCsv(e,{sep:s}),{optional:r})}parseWrapped(e,t={}){let{optional:s=!1}=t,r=this.match("lParen")||void 0;!r&&!s&&this.raiseError("Expecting (");let i=e();return r&&this.matchRParen(),i}parseExpressions(){return this.parseCsv(()=>this.parseExpression())}parseSelectOrExpression(e={}){let{alias:t=!1}=e;return this.parseSetOperations(t?this.parseAlias(this.parseAssignment(),{explicit:!0}):this.parseAssignment())||this.parseSelect()}parseDdlSelect(){return this.parseQueryModifiers(this.parseSetOperations(this.parseSelect({nested:!0,parseSubqueryAlias:!1})))}parseTransaction(){let e;this.matchTexts(this._constructor.TRANSACTION_KIND)&&(e=this.prev?.text),this.matchTexts(["TRANSACTION","WORK"]);let t=[];for(;;){let s=[];for(;this.match("var")||this.match("not");)s.push(this.prev?.text??"");if(0<s.length&&t.push(s.join(" ")),!this.match("comma"))break}return this.expression(nC,{this:e,modes:t})}parseStar(){return this.match("star")?this._constructor.PRIMARY_PARSERS.star?.call(this,this.prev):this.parsePlaceholder()}parseParameter(){let e=this.parseIdentifier()||this.parsePrimaryOrVar();return this.expression(YC,{this:e})}parsePlaceholder(){if(this.matchSet(new Set(Object.keys(this._constructor.PLACEHOLDER_PARSERS)))){let e=this._constructor.PLACEHOLDER_PARSERS[this.prev?.tokenType??"unknown"]?.call(this);if(e)return e;this.advance(-1)}}parseStarOp(...e){if(!this.matchTexts(e))return;if(this.match("lParen",{advance:!1}))return this.parseWrappedCsv(()=>this.parseExpression());let t=this.parseAlias(this.parseDisjunction(),{explicit:!0});return t?[t]:void 0}parseCsv(e,t={}){let{sep:s="comma"}=t,r=e(),i=r!==void 0?[r]:[];for(;this.match(s);)r instanceof d&&this.addComments(r),r=e(),r!==void 0&&i.push(r);return i}parseIdentifier(){return this.match("identifier")?this.identifierExpression(void 0,{quoted:!0}):this.parsePlaceholder()}parseVar(e={}){let{anyToken:t=!1,tokens:s,upper:r=!1}=e;if(t&&this.advanceAny()||this.match("var")||s&&this.matchSet(s)){let i=r?(this.prev?.text??"").toUpperCase():this.prev?.text??"";return this.expression(Ve,{this:i})}return this.parsePlaceholder()}advanceAny(e={}){let{ignoreReserved:t=!1}=e;if(this.curr&&(t||!this._constructor.RESERVED_TOKENS.has(this.curr.tokenType)))return this.advance(),this.prev}parseVarOrString(e={}){let{upper:t=!1}=e;return this.parseString()||this.parseVar({anyToken:!0,upper:t})}parsePrimaryOrVar(){return this.parsePrimary()||this.parseVar({anyToken:!0})}parseNull(){return this.matchSet(new Set(["null","unknown"]))?this._constructor.PRIMARY_PARSERS.null?.call(this,this.prev):this.parsePlaceholder()}parseBoolean(){return this.match("true")?this._constructor.PRIMARY_PARSERS.true?.call(this,this.prev):this.match("false")?this._constructor.PRIMARY_PARSERS.false?.call(this,this.prev):this.parsePlaceholder()}parseString(){return this.matchSet(new Set(Object.keys(this._constructor.STRING_PARSERS)))?this._constructor.STRING_PARSERS[this.prev?.tokenType??"unknown"]?.call(this,this.prev):this.parsePlaceholder()}parseStringAsIdentifier(){let e=(this.match("string")||void 0)&&this.prev?.text,t=e===void 0?void 0:K(e,{quoted:!0});return t&&this.prev&&t.updatePositions(this.prev),t}parseNumber(){return this.matchSet(new Set(Object.keys(this._constructor.NUMERIC_PARSERS)))?this._constructor.NUMERIC_PARSERS[this.prev?.tokenType??"unknown"]?.call(this,this.prev):this.parsePlaceholder()}parseHavingMax(e){if(this.match("having")){this.matchTexts(["MAX","MIN"]);let t=this.prev?.text.toUpperCase()!=="MIN";return this.expression(gr,{this:e,expression:this.parseColumn(),max:t})}return e}parseWindow(e,t={}){let{alias:s=!1}=t,r=e,i=r instanceof d?r.comments:void 0;if(this.matchTextSeq(["WITHIN","GROUP"])){let T=this.parseWrapped(()=>this.parseOrder());e=this.expression(ns,{this:e,expression:T})}if(this.matchPair("filter","lParen")&&(this.match("where"),e=this.expression(Xr,{this:e,expression:this.parseWhere({skipWhereToken:!0})}),this.matchRParen()),e instanceof q){let T=e.find([IA,yA]);T&&T!==e&&(T.replace(T.args.this),e=this.expression(T._constructor,{this:e}))}e=this.parseRespectOrIgnoreNulls(e);let o;if(s)o=void 0,this.match("alias");else if(this.matchSet(this._constructor.WINDOW_BEFORE_PAREN_TOKENS))o=this.prev?.text.toUpperCase();else return e;if(i&&r instanceof d&&r.popComments(),!this.match("lParen"))return this.expression(Ue,{comments:i,this:e,alias:this.parseIdVar({anyToken:!1}),over:o});let c=this.parseIdVar({anyToken:!1,tokens:this._constructor.WINDOW_ALIAS_TOKENS}),p=this.match("first")||void 0;this.matchTextSeq("LAST")&&(p=!1);let[u,h]=this.parsePartitionAndOrder(),g=(this.matchSet(new Set(["rows","range"]))||this.matchTextSeq("GROUPS")||void 0)&&this.prev?.text,f;if(g){this.match("between");let T=this.parseWindowSpec(),y=this.match("and")?this.parseWindowSpec():{},C=this.matchTextSeq("EXCLUDE")?this.parseVarFromOptions(this._constructor.WINDOW_EXCLUDE_OPTIONS):void 0;f=this.expression(pu,{kind:g,start:T.value,startSide:T.side,end:y.value,endSide:y.side,exclude:C})}else f=void 0;this.matchRParen();let x=this.expression(Ue,{comments:i,this:e,partitionBy:u,order:h,spec:f,alias:c,over:o,first:p});return this.matchSet(this._constructor.WINDOW_BEFORE_PAREN_TOKENS,{advance:!1})?this.parseWindow(x,{alias:s}):x}parsePartitionAndOrder(){return[this.parsePartitionBy(),this.parseOrder()]}parseWindowSpec(){return this.match("between"),{value:this.matchTextSeq("UNBOUNDED")&&"UNBOUNDED"||this.matchTextSeq(["CURRENT","ROW"])&&"CURRENT ROW"||this.parseBitwise()||void 0,side:(this.matchTexts(this._constructor.WINDOW_SIDES)||void 0)&&this.prev?.text}}parseAlias(e,t={}){let{explicit:s=!1}=t;if(this.canParseLimitOrOffset())return e;let r=this.match("alias"),i=this.prevComments??[];if(s&&!r)return e;if(this.match("lParen")){let c=this.expression(Hn,{comments:i,this:e,expressions:this.parseCsv(()=>this.parseIdVar({anyToken:r}))});return this.matchRParen(c),c}let o=this.parseIdVar({anyToken:r,tokens:this._constructor.ALIAS_TOKENS})||this._constructor.STRING_ALIASES&&this.parseStringAsIdentifier();if(o){i.push(...o.popComments()),e=this.expression(Re,{comments:i,this:e,alias:o});let c=e.args.this;(!e.comments||e.comments.length===0)&&c&&c.comments&&0<c.comments.length&&(e.comments=c.popComments())}return e}parseOpenJson(){let e=this.parseBitwise(),t=(this.match("comma")||void 0)&&this.parseString(),s=n(()=>{let i=this.parseField({anyToken:!0}),o=this.parseTypes(),c=this.parseString(),p=this.matchPair("alias","json")||void 0;return this.expression(IC,{this:i,kind:o,path:c,asJson:p})},"parseOpenJsonColumnDef"),r;return this.matchPair("rParen","with")&&(this.matchLParen(),r=this.parseCsv(s)),this.expression(hb,{this:e,path:t,expressions:r})}parsePosition(e={}){let{haystackFirst:t=!1}=e,s=this.parseCsv(()=>this.parseBitwise());if(this.match("in"))return this.expression(Bs,{this:this.parseBitwise(),substr:D(s,0)});let r=t?D(s,0):D(s,1),i=t?D(s,1):D(s,0);return this.expression(Bs,{this:r,substr:i,position:D(s,2)})}parseJoinHint(e){let t=this.parseCsv(()=>this.parseTable());return new gn({this:e.toUpperCase(),expressions:t})}parseSubstring(){let e=this.parseCsv(()=>this.parseBitwise()),t,s;for(;this.curr;)if(this.match("from"))t=this.parseBitwise();else if(this.match("for"))t||(t=N.number(1)),s=this.parseBitwise();else break;return t&&e.push(t),s&&e.push(s),this.validateExpression(Ns.fromArgList(e),e)}parseTrim(){let e,t,s;this.matchTexts(this._constructor.TRIM_TYPES)&&(e=this.prev?.text.toUpperCase());let r=this.parseBitwise();if(this.matchSet(new Set(["from","comma"]))){let i=this.prev?.tokenType==="from"||this._constructor.TRIM_PATTERN_FIRST;s=this.parseBitwise(),i&&([r,s]=[s,r])}return this.match("collate")&&(t=this.parseBitwise()),this.expression(Ya,{this:r,position:e,expression:s,collation:t})}parseWindowClause(){return(this.match("window")||void 0)&&this.parseCsv(()=>this.parseNamedWindow())}parseNamedWindow(){return this.parseWindow(this.parseIdVar(),{alias:!0})}parseRespectOrIgnoreNulls(e){if(this.curr?.tokenType==="var"){if(this.matchTextSeq(["IGNORE","NULLS"]))return this.expression(IA,{this:e});if(this.matchTextSeq(["RESPECT","NULLS"]))return this.expression(yA,{this:e})}return e}parseJsonObject(e={}){let{agg:t=!1}=e,s=this.parseStar(),r=s?[s]:this.parseCsv(()=>this.parseFormatJson(this.parseJsonKeyValue())),i=this.parseOnHandling("NULL",["NULL","ABSENT"]),o;this.matchTextSeq(["WITH","UNIQUE"])?o=!0:this.matchTextSeq(["WITHOUT","UNIQUE"])&&(o=!1),this.matchTextSeq("KEYS");let c=(this.matchTextSeq("RETURNING")||void 0)&&this.parseFormatJson(this.parseType()),p=(this.matchTextSeq("ENCODING")||void 0)&&this.parseVar();return this.expression(t?Nb:Sh,{expressions:r,nullHandling:i,uniqueKeys:o,returnType:c,encoding:p})}parseJsonColumnDef(){let e,t,s,r;this.matchTextSeq("NESTED")?(e=void 0,t=void 0,s=void 0,r=!0):(e=this.parseIdVar(),t=this.matchPair("for","ordinality")||void 0,s=this.parseTypes({allowIdentifiers:!1}),r=void 0);let i=(this.matchTextSeq("PATH")||void 0)&&this.parseString(),o=r&&this.parseJsonSchema();return this.expression(OC,{this:e,kind:s,path:i,nestedSchema:o,ordinality:t})}parseJsonSchema(){return this.matchTextSeq("COLUMNS"),this.expression(mC,{expressions:this.parseWrappedCsv(()=>this.parseJsonColumnDef(),{optional:!0})})}parseJsonTable(){let e=this.parseFormatJson(this.parseBitwise());e||this.raiseError("Expected expression for JSON_TABLE");let t=(this.match("comma")||void 0)&&this.parseString(),s=this.parseOnHandling("ERROR",["ERROR","NULL"]),r=this.parseOnHandling("EMPTY",["ERROR","NULL"]),i=this.parseJsonSchema();return new ub({this:e,schema:i,path:t,errorHandling:s,emptyHandling:r})}parseMatchAgainst(){let e;if(this.matchTextSeq("TABLE")){e=[];let r=this.parseTable();r&&(e=[r])}else e=this.parseCsv(()=>this.parseColumn());this.matchTextSeq([")","AGAINST","("]);let t=this.parseString(),s;return this.matchTextSeq(["IN","NATURAL","LANGUAGE","MODE"])?(s="IN NATURAL LANGUAGE MODE",this.matchTextSeq(["WITH","QUERY","EXPANSION"])&&(s=`${s} WITH QUERY EXPANSION`)):this.matchTextSeq(["IN","BOOLEAN","MODE"])?s="IN BOOLEAN MODE":this.matchTextSeq(["WITH","QUERY","EXPANSION"])?s="WITH QUERY EXPANSION":s=void 0,this.expression(db,{this:t,expressions:e,modifier:s})}parseJsonKeyValue(){this.matchTextSeq("KEY");let e=this.parseColumn();this.matchSet(this._constructor.JSON_KEY_VALUE_SEPARATOR_TOKENS),this.matchTextSeq("VALUE");let t=this.parseBitwise();if(!(!e&&!t))return this.expression(RC,{this:e,expression:t})}parseFormatJson(e){return!e||!this.matchTextSeq(["FORMAT","JSON"])?e:this.expression(SC,{this:e})}parseOnCondition(){let e,t;this._dialectConstructor.ON_CONDITION_EMPTY_BEFORE_ERROR?(e=this.parseOnHandling("EMPTY",[...this._constructor.ON_CONDITION_TOKENS]),t=this.parseOnHandling("ERROR",[...this._constructor.ON_CONDITION_TOKENS])):(t=this.parseOnHandling("ERROR",[...this._constructor.ON_CONDITION_TOKENS]),e=this.parseOnHandling("EMPTY",[...this._constructor.ON_CONDITION_TOKENS]));let s=this.parseOnHandling("NULL",[...this._constructor.ON_CONDITION_TOKENS]);if(!(!e&&!t&&!s))return this.expression(qy,{empty:e,error:t,null:s})}parseOnHandling(e,t){for(let r of t)if(this.matchTextSeq([r,"ON",e]))return`${r} ON ${e}`;let s=this.index;if(this.match("default")){let r=this.parseBitwise();if(this.matchTextSeq(["ON",e]))return r;this.retreat(s)}}parseConvert(e){let{safe:t,strict:s}=e,r=this.parseBitwise(),i;return this.match("using")?i=this.expression(TA,{this:this.parseVar({tokens:new Set(["binary"])})}):this.match("comma")?i=this.parseTypes():i=void 0,this.buildCast({strict:s,this:r,to:i,safe:t})}parseXmlElement(){let e,t;return this.matchTextSeq("EVALNAME")?(e=!0,t=this.parseBitwise()):(e=void 0,this.matchTextSeq("NAME"),t=this.parseIdVar()),this.expression(Sb,{this:t,expressions:(this.match("comma")||void 0)&&this.parseCsv(()=>this.parseBitwise()),evalname:e})}parseXmlTable(){let e,t,s;this.matchTextSeq(["XMLNAMESPACES","("])&&(e=this.parseXmlNamespace(),this.match("rParen"),this.match("comma"));let r=this.parseString();this.matchTextSeq("PASSING")&&(this.matchTextSeq(["BY","VALUE"]),t=this.parseCsv(()=>this.parseColumn()));let i=this.matchTextSeq(["RETURNING","SEQUENCE","BY","REF"])||void 0;return this.matchTextSeq("COLUMNS")&&(s=this.parseCsv(()=>this.parseFieldDef())),this.expression(Rb,{this:r,namespaces:e,passing:t,columns:s,byRef:i})}parseXmlNamespace(){let e=[];for(;;){let t;if(this.match("default")?t=this.parseString():t=this.parseAlias(this.parseString()),e.push(this.expression(yC,{this:t})),!this.match("comma"))break}return e}parseDecode(){let e=this.parseCsv(()=>this.parseDisjunction());return e.length<3?this.expression(ob,{this:D(e,0),charset:D(e,1)}):this.expression(cb,{expressions:e})}parseGapFill(){this.match("table");let e=this.parseTable();this.match("comma");let t=[e,...this.parseCsv(()=>this.parseLambda())].filter(r=>r instanceof d),s=pb.fromArgList(t);return this.validateExpression(s,t)}parseChar(){return this.expression(gh,{expressions:this.parseCsv(()=>this.parseAssignment()),charset:(this.match("using")||void 0)&&this.parseVar()})}parseCast(e){let{safe:t,strict:s}=e,r=this.parseAssignment();if(!this.match("alias")){if(this.match("comma"))return this.expression(ib,{this:r,to:this.parseString()});this.raiseError("Expected AS after CAST")}let i,o=this.parseTypes(),c;if(this.match("default")&&(c=this.parseBitwise(),this.matchTextSeq(["ON","CONVERSION","ERROR"])),this.matchSet(new Set(["format","comma"]))){let p=this.parseWrapped(()=>this.parseString(),{optional:!0});if(i=this.parseAtTimeZone(p),o||(o=m.build("unknown")),o&&m.TEMPORAL_TYPES.has(o.args.this))return r=this.expression(o.args.this==="date"?oi:Is,{this:r,format:N.string(Wl(p?.args.this??"",Object.keys(this._dialectConstructor.FORMAT_MAPPING).length?this._dialectConstructor.FORMAT_MAPPING:this._dialectConstructor.TIME_MAPPING,Object.keys(this._dialectConstructor.FORMAT_MAPPING).length?this._dialectConstructor.FORMAT_TRIE:this._dialectConstructor.TIME_TRIE)??""),safe:t}),i instanceof gs&&r instanceof Is&&r.setArgKey("zone",i.args.zone),r}else o?o instanceof v?o=m.build(o.name,{dialect:this.dialect,udt:!0}):o.args.this==="char"&&this.match("characterSet")&&(o=this.expression(TA,{this:this.parseVarOrString()})):this.raiseError("Expected TYPE after CAST");return this.buildCast({strict:s,this:r,to:o,format:i,safe:t,action:this.parseVarFromOptions(this._constructor.CAST_ACTIONS,{raiseUnmatched:!1}),default:c})}parseStringAgg(){let e;this.match("distinct")?(e=[this.expression(et,{expressions:[this.parseDisjunction()]})],this.match("comma")&&e.push(...this.parseCsv(()=>this.parseDisjunction()))):e=this.parseCsv(()=>this.parseDisjunction());let t;this.matchTextSeq(["ON","OVERFLOW"])?this.matchTextSeq("ERROR")?t=Z("ERROR"):(this.matchTextSeq("TRUNCATE"),t=this.expression(xC,{this:this.parseString(),withCount:this.matchTextSeq(["WITH","COUNT"])||!this.matchTextSeq(["WITHOUT","COUNT"])})):t=void 0;let s=this.index;return!this.match("rParen")&&0<e.length?(e[0]=this.parseLimit(this.parseOrder({thisExpr:e[0]})),this.expression(sr,{this:e[0],separator:D(e,1)})):this.matchTextSeq(["WITHIN","GROUP"])?(this.matchLParen(),this.expression(sr,{this:this.parseOrder({thisExpr:D(e,0)}),separator:D(e,1),onOverflow:t})):(this.retreat(s),this.validateExpression(sr.fromArgList(e.filter(r=>r instanceof d)),e))}parseBracket(e){if(!this.matchSet(this._constructor.BRACKETS))return e;let t;if(this._constructor.MAP_KEYS_ARE_ARBITRARY_EXPRESSIONS){let i=D(this.tokens,this.index-2);t=i!==void 0&&i.text.toUpperCase()==="MAP"}else t=!1;let s=this.prev?.tokenType;if(s==="lBrace"&&this.curr&&this.curr.tokenType==="var"&&this._constructor.ODBC_DATETIME_LITERALS[this.curr.text.toLowerCase()])return this.parseOdbcDatetimeLiteral();let r=this.parseCsv(()=>this.parseBracketKeyValue({isMap:s==="lBrace"}));if(s==="lBracket"&&!this.match("rBracket")?this.raiseError("Expected ]"):s==="lBrace"&&!this.match("rBrace")&&this.raiseError("Expected }"),s==="lBrace")e=this.expression(Es,{expressions:this.kvToPropEq(r,{parseMap:t})});else if(!e&&s)e=aV(ue,r,s,this.dialect);else if(e&&s){let i=this._constructor.ARRAY_CONSTRUCTORS[e?.name.toUpperCase()??""];if(i)return aV(i,r,s,this.dialect);let o=dA(e,r,-this._dialectConstructor.INDEX_OFFSET,{dialect:this.dialect});e=this.expression(Lt,{this:e,expressions:o,comments:e.popComments()})}return this.addComments(e),this.parseBracket(e)}parseSlice(e){if(!this.match("colon"))return e;let t;this.matchPair("dash","colon",{advance:!1})?(this.advance(),t=N.number("1").neg()):t=this.parseAssignment();let s=this.match("colon")?this.parseUnary():void 0;return this.expression(On,{this:e,expression:t,step:s})}parseCase(){if(this.match("dot",{advance:!1})){this.retreat(this.index-1);return}let e=[],t,s=this.prevComments,r=this.parseDisjunction();for(;this.match("when");){let i=this.parseDisjunction();this.match("then");let o=this.parseDisjunction();e.push(this.expression(fe,{this:i,true:o}))}return this.match("else")&&(t=this.parseDisjunction()),this.match("end")||(t instanceof qe&&(typeof t.args.this=="string"?t.args.this:t.args.this?.sql())?.toUpperCase()==="END"?t=$n({col:"interval"}):this.raiseError("Expected END after CASE",this.prev)),this.expression(ut,{comments:s,this:r,ifs:e,default:t})}parseIf(){if(this.match("lParen")){let e=this.parseCsv(()=>this.parseAlias(this.parseAssignment(),{explicit:!0})),t=this.validateExpression(fe.fromArgList(e),e);return this.matchRParen(),t}else{let e=this.index-1;if(this._constructor.NO_PAREN_IF_COMMANDS&&e===0)return this.parseAsCommand(this.prev);let t=this.parseDisjunction();if(!t){this.retreat(e);return}this.match("then");let s=this.parseDisjunction(),r=this.match("else")?this.parseDisjunction():void 0;return this.match("end"),this.expression(fe,{this:t,true:s,false:r})}}parseNextValueFor(){if(!this.matchTextSeq(["VALUE","FOR"])){this.retreat(this.index-1);return}return this.expression(Ob,{this:this.parseColumn(),order:(this.match("over")||void 0)&&this.parseWrapped(()=>this.parseOrder())})}parseExtract(){let e=this.parseFunction()||this.parseVarOrString({upper:!0});return this.match("from")?this.expression(lr,{this:e,expression:this.parseBitwise()}):(this.match("comma")||this.raiseError("Expected FROM or comma after EXTRACT",this.prev),this.expression(lr,{this:e,expression:this.parseBitwise()}))}parsePrimaryKeyPart(){return this.parseField()}parsePeriodForSystemTime(){if(!this.match("timestampSnapshot")){this.retreat(this.index-1);return}let e=this.parseWrappedIdVars();return this.expression(DC,{this:D(e,0),expression:D(e,1)})}parsePrimaryKey(e={}){let{wrappedOptional:t=!1,inProps:s=!1,namedPrimaryKey:r=!1}=e,i=this.matchSet(new Set(["asc","desc"]))?this.prev?.tokenType==="desc":void 0,o;if(r&&!((this.curr?.text.toUpperCase()||"")in this._constructor.CONSTRAINT_PARSERS)&&this.next&&this.next.tokenType==="lParen"&&(o=this.parseIdVar()),!s&&!this.match("lParen",{advance:!1}))return this.expression(vC,{desc:i,options:this.parseKeyConstraintOptions()});let c=this.parseWrappedCsv(()=>this.parsePrimaryKeyPart(),{optional:t});return this.expression(ru,{this:o,expressions:c,include:this.parseIndexParams(),options:this.parseKeyConstraintOptions()})}parseBracketKeyValue(e={}){return this.parseSlice(this.parseAlias(this.parseDisjunction(),{explicit:!0}))}parseOdbcDatetimeLiteral(){this.match("var");let e=this._constructor.ODBC_DATETIME_LITERALS[this.prev?.text??"".toLowerCase()],t=this.expression(e,{this:this.parseString()});return this.match("rBrace")||this.raiseError("Expected }"),t}parseUniqueKey(){if(!(this.curr&&this.curr.text.toUpperCase()in this._constructor.CONSTRAINT_PARSERS))return this.parseIdVar({anyToken:!1})}parseUnique(){return this.matchTexts(["KEY","INDEX"]),this.expression(Mu,{nulls:this.matchTextSeq(["NULLS","NOT","DISTINCT"])||void 0,this:this.parseSchema({this:this.parseUniqueKey()}),indexType:(this.match("using")||void 0)&&this.advanceAny()&&this.prev?.text,onConflict:this.parseOnConflict(),options:this.parseKeyConstraintOptions()})}parseKeyConstraintOptions(){let e=[];for(;this.curr;)if(this.match("on")){let t,s=this.advanceAny()&&this.prev?.text;this.matchTextSeq(["NO","ACTION"])?t="NO ACTION":this.matchTextSeq("CASCADE")?t="CASCADE":this.matchTextSeq("RESTRICT")?t="RESTRICT":this.matchPair("set","null")?t="SET NULL":this.matchPair("set","default")?t="SET DEFAULT":this.raiseError("Invalid key constraint"),e.push(`ON ${s} ${t}`)}else{let t=this.parseVarFromOptions(this._constructor.KEY_CONSTRAINT_OPTIONS,{raiseUnmatched:!1});if(!t)break;e.push(t.name)}return e}parseReferences(e={}){let{match:t=!0}=e;if(t&&!this.match("references"))return;let s,r=this.parseTable({schema:!0}),i=this.parseKeyConstraintOptions();return this.expression(Zy,{this:r,expressions:s,options:i})}parseForeignKey(){let e=this.match("references",{advance:!1})?void 0:this.parseWrappedIdVars(),t=this.parseReferences(),s={};for(;this.match("on");){this.matchSet(new Set(["delete","update"]))||this.raiseError("Expected DELETE or UPDATE");let r=(this.prev?.text??"").toLowerCase(),i;this.matchTextSeq(["NO","ACTION"])?i="NO ACTION":this.match("set")?(this.matchSet(new Set(["null","default"])),i="SET "+(this.prev?.text??"").toUpperCase()):(this.advance(),i=(this.prev?.text??"").toUpperCase()),s[r]=i}return this.expression(Py,{expressions:e,reference:t,options:this.parseKeyConstraintOptions(),...s})}parsePrimary(){if(this.matchSet(Object.keys(this._constructor.PRIMARY_PARSERS))){let e=this.prev?.tokenType??"unknown",t=this._constructor.PRIMARY_PARSERS[e]?.call(this,this.prev);if(e==="string"){let s=[t];for(;this.match("string");)s.push(N.string(this.prev?.text??""));if(1<s.length)return this.expression(Bt,{expressions:s,coalesce:this._dialectConstructor.CONCAT_COALESCE})}return t}return this.matchPair("dot","number")?N.number(`0.${this.prev?.text??""}`):this.parseParen()}parseField(e={}){let{anyToken:t=!1,tokens:s,anonymousFunc:r=!1}=e||{},i;return r?i=this.parseFunction({anonymous:r,anyToken:t})||this.parsePrimary():i=this.parsePrimary()||this.parseFunction({anonymous:r,anyToken:t}),i||this.parseIdVar({anyToken:t,tokens:s})}parseGeneratedAsIdentity(){let e;if(this.matchTextSeq(["BY","DEFAULT"])){let s=this.matchPair("on","null")||void 0;e=this.expression(Jl,{this:!1,onNull:s})}else this.matchTextSeq("ALWAYS"),e=this.expression(Jl,{this:!0});if(this.match("alias"),this.matchTextSeq("ROW")){let s=this.matchTextSeq("START")||void 0;s||this.match("end");let r=this.matchTextSeq("HIDDEN")||void 0;return this.expression(UC,{start:s,hidden:r})}let t=this.matchTextSeq("IDENTITY")||void 0;if(this.match("lParen")){if(this.match("startWith")&&e.setArgKey("start",this.parseBitwise()),this.matchTextSeq(["INCREMENT","BY"])&&e.setArgKey("increment",this.parseBitwise()),this.matchTextSeq("MINVALUE")&&e.setArgKey("minvalue",this.parseBitwise()),this.matchTextSeq("MAXVALUE")&&e.setArgKey("maxvalue",this.parseBitwise()),this.matchTextSeq("CYCLE")?e.setArgKey("cycle",!0):this.matchTextSeq(["NO","CYCLE"])&&e.setArgKey("cycle",!1),!t)e.setArgKey("expression",this.parseRange());else if(!e.args.start&&this.match("number",{advance:!1})){let s=this.parseCsv(this.parseBitwise.bind(this));e.setArgKey("start",D(s,0)),e.setArgKey("increment",D(s,1))}this.matchRParen()}return e}parseInline(){return this.matchTextSeq("LENGTH"),this.expression(Cu,{this:this.parseBitwise()})}parseNotConstraint(){if(this.matchTextSeq("NULL"))return this.expression(PA);if(this.matchTextSeq("CASESPECIFIC"))return this.expression(kn,{not:!0});if(this.matchTextSeq(["FOR","REPLICATION"]))return this.expression(Pu);this.retreat(this.index-1)}parseColumnConstraint(){let e=(this.match("constraint")||void 0)&&this.parseIdVar();if(!((this.match("with",{advance:!1})||void 0)&&this.next&&this.next.text.toUpperCase()in this._constructor.PROCEDURE_OPTIONS)&&this.matchTexts(Object.keys(this._constructor.CONSTRAINT_PARSERS))){let s=this._constructor.CONSTRAINT_PARSERS[(this.prev?.text??"").toUpperCase()]?.call(this);if(!s){this.retreat(this.index-1);return}return this.expression(yn,{this:e,kind:s})}return e}parseConstraint(){return this.match("constraint")?this.expression(my,{this:this.parseIdVar(),expressions:this.parseUnnamedConstraints()}):this.parseUnnamedConstraint({constraints:this._constructor.SCHEMA_UNNAMED_CONSTRAINTS})}parseUnnamedConstraints(){let e=[];for(;;){let t=this.parseUnnamedConstraint()||this.parseFunction();if(!t)break;e.push(t)}return e}parseUnnamedConstraint(e={}){let t=this.index,{constraints:s}=e;if(this.match("identifier",{advance:!1})||!this.matchTexts(s||Object.keys(this._constructor.CONSTRAINT_PARSERS)))return;let r=(this.prev?.text??"").toUpperCase();r in this._constructor.CONSTRAINT_PARSERS||this.raiseError(`No parser found for schema constraint ${r}.`);let i=this._constructor.CONSTRAINT_PARSERS[r]?.call(this);if(!i||Array.isArray(i)){this.retreat(t);return}return i}parseFieldDef(){return this.parseColumnDef(this.parseField({anyToken:!0}))}parseColumnDef(e,t={}){let{computedColumn:s=!0}=t,r=e;r instanceof $&&(r=r.args.this),s||this.match("alias");let i=this.parseTypes({schema:!0});if(this.matchTextSeq(["FOR","ORDINALITY"]))return this.expression(be,{this:r,ordinality:!0});let o=[];if(!i&&this.match("alias")||this.matchTexts(["ALIAS","MATERIALIZED"])){let p=(this.prev?.text??"").toUpperCase()==="MATERIALIZED",u=new Dn({this:this.parseDisjunction(),persisted:p||this.matchTextSeq("PERSISTED")||void 0,dataType:this.matchTextSeq("AUTO")?new m({this:"AUTO"}):this.parseTypes(),notNull:this.matchPair("not","null")||void 0});o.push(this.expression(yn,{kind:u}))}else if(!i&&this.matchSet(["in","out"],{advance:!1})){let p=this.expression(FC,{input:this.match("in")||void 0,output:this.match("out")||void 0});o.push(p),i=this.parseTypes()}else i&&this.match("alias",{advance:!1})&&(!this._constructor.WRAPPED_TRANSFORM_COLUMN_CONSTRAINT||this.next&&this.next.tokenType==="lParen")&&(this.advance(),o.push(this.expression(yn,{kind:new Dn({this:this.parseDisjunction(),persisted:(this.matchTexts(["STORED","VIRTUAL"])||void 0)&&(this.prev?.text??"").toUpperCase()==="STORED"})})));for(;;){let p=this.parseColumnConstraint();if(!p)break;o.push(p)}if(!i&&o.length===0)return r;let c;if(this.matchTexts(["FIRST","AFTER"])){let p=this.prev?.text??"";c=this.expression(Ty,{this:this.parseColumn(),position:p})}return this.expression(be,{this:r,kind:i,constraints:o,position:c})}parseAutoIncrement(){let e,t,s;if(this.match("lParen",{advance:!1})){let r=this.parseWrappedCsv(this.parseBitwise.bind(this));e=D(r,0),t=D(r,1)}else this.matchTextSeq("START")&&(e=this.parseBitwise(),this.matchTextSeq("INCREMENT"),t=this.parseBitwise(),this.matchTextSeq("ORDER")?s=!0:this.matchTextSeq("NOORDER")&&(s=!1));return e&&t?new Jl({start:e,increment:t,this:!1,order:s}):new kC({})}parseCheckConstraint(){if(this.match("lParen",{advance:!1}))return this.expression(qC,{this:this.parseWrapped(this.parseAssignment.bind(this)),enforced:this.matchTextSeq("ENFORCED")||void 0})}parseAutoProperty(){if(!this.matchTextSeq("REFRESH")){this.retreat(this.index-1);return}return this.expression(Xn,{this:this.parseVar({upper:!0})})}parseCompress(){return this.match("lParen",{advance:!1})?this.expression(bA,{this:this.parseWrappedCsv(this.parseBitwise.bind(this))}):this.expression(bA,{this:this.parseBitwise()})}parseFunction(e={}){let{functions:t,anonymous:s=!1,optionalParens:r=!0,anyToken:i=!1}=e,o=!1;this.match("lBrace",{advance:!1})&&this.next&&this.next.text.toUpperCase()==="FN"&&(this.advance(2),o=!0);let c=this.parseFunctionCall({functions:t,anonymous:s,optionalParens:r,anyToken:i});return o&&this.match("rBrace"),c}parseFunctionArgs(e={}){let{alias:t=!1}=e;return this.parseCsv(()=>this.parseLambda({alias:t}))}parseFunctionCall(e={}){let{functions:t,anonymous:s=!1,optionalParens:r=!0,anyToken:i=!1}=e;if(!this.curr)return;let o=this.curr.comments,c=this.prev,p=this.curr,u=this.curr.tokenType,h=this.curr.text,g=h.toUpperCase(),f=this._constructor.NO_PAREN_FUNCTION_PARSERS[g];if(f&&r&&!this._constructor.INVALID_FUNC_NAME_TOKENS.has(u))return this.advance(),this.parseWindow(f.call(this));if(!this.next||this.next.tokenType!=="lParen"){let T=this._constructor.NO_PAREN_FUNCTIONS[u];return r&&T?(this.advance(),this.expression(T)):void 0}if(i){if(this._constructor.RESERVED_TOKENS.has(u))return}else if(!this._constructor.FUNC_TOKENS.has(u))return;this.advance(2);let x=this._constructor.FUNCTION_PARSERS[g];if(x&&!s){let T=x.call(this);return T instanceof d&&T.addComments(o),this.match("rParen",{expression:T instanceof d?T:void 0}),this.parseWindow(T)}else{let T=this._constructor.SUBQUERY_PREDICATES[u];if(T){let H;if(this._constructor.SUBQUERY_TOKENS.has(this.curr.tokenType)?(H=this.parseSelect(),this.matchRParen()):c&&(c.tokenType==="like"||c.tokenType==="ilike")&&(this.advance(-1),H=this.parseBitwise()),H)return this.expression(T,{comments:o,this:H})}let C=(t??this._constructor.FUNCTIONS)[g],I=C&&!s,b=!I||this._constructor.FUNCTIONS_WITH_ALIASED_ARGS.has(g),k=this.parseFunctionArgs({alias:b}),B=this.curr?.comments,j=I;j&&B&&B.some(H=>H.trimStart().startsWith(ND))&&(j=!1);let Q=b&&j?this.kvToPropEq(k):k,ne;if(j){let H;1<C.length?H=C(Q,{dialect:this.dialect}):H=C(Q),H=this.validateExpression(H,Q),this._dialectConstructor.PRESERVE_ORIGINAL_NAMES&&(H.meta.name=h),ne=H}else{let H=h;u==="identifier"&&(H=new v({this:h,quoted:!0}).updatePositions(p)),ne=this.expression(Qe,{this:H,expressions:k})}return ne=ne.updatePositions(p),ne instanceof d&&ne.addComments(o),this.matchRParen(ne),this.parseWindow(ne)}}toPropEq(e,t){return e}kvToPropEq(e,t={}){let{parseMap:s=!1}=t,r=[];for(let i=0;i<e.length;i++){let o=e[i];if([...this._constructor.KEY_VALUE_DEFINITIONS.keys()].some(c=>o instanceof c)){if(o instanceof Re&&(o=this.expression(ot,{this:o.args.alias,expression:o.args.this})),!(o instanceof ot)){let c=o.args.this;o=this.expression(ot,{this:s?o.args.this:K(c instanceof d?c.name:c?.toString()),expression:o.args.expression})}o.args.this instanceof $&&o.args.this.replace(o.args.this.args.this)}else o=this.toPropEq(o,i);r.push(o)}return r}parseUserDefinedFunctionExpression(){return this.parseStatement()}parseFunctionParameter(){return this.parseColumnDef(this.parseIdVar(),{computedColumn:!1})}parseUserDefinedFunction(e={}){let t=this.parseTableParts({schema:!0});if(!this.match("lParen"))return t;let s=this.parseCsv(this.parseFunctionParameter.bind(this));return this.matchRParen(),this.expression(fy,{this:t,expressions:s,wrapped:!0})}parseIntroducer(e){let t=this.parsePrimary();return t?this.expression(Uy,{token:e,expression:t}):this.identifierExpression(e)}parseSessionParameter(){let e,t=this.parseIdVar()||this.parsePrimary();return t&&this.match("dot")&&(e=t.name,t=this.parseVar()||this.parsePrimary()),this.expression(VC,{this:t,kind:e})}parseLambdaArg(){return this.parseIdVar()}parseLambda(e={}){let{alias:t=!1}=e,s=this.next?.tokenType;if(s!==void 0&&this._constructor.LAMBDA_ARG_TERMINATORS.has(s)){let c=this.parseAtom();if(c!==void 0)return c}let r=this.index,i;if(this.match("lParen"))if(i=this.parseCsv(this.parseLambdaArg.bind(this)),!this.match("rParen"))this.retreat(r);else if(this.matchSet(Object.keys(this._constructor.LAMBDAS))){let c=this.prev?.tokenType;return c&&this._constructor.LAMBDAS[c]?.call(this,i.filter(p=>!!p))}else this.retreat(r);else if(this._constructor.TYPED_LAMBDA_ARGS||s!==void 0&&s in this._constructor.LAMBDAS){if(i=[this.parseLambdaArg()],this.matchSet(Object.keys(this._constructor.LAMBDAS))){let c=this.prev?.tokenType;return c&&this._constructor.LAMBDAS[c]?.call(this,i.filter(p=>!!p))}this.retreat(r)}let o;return this.match("distinct")?o=this.expression(et,{expressions:this.parseCsv(this.parseDisjunction.bind(this))}):o=this.parseSelectOrExpression({alias:t}),this.parseLimit(this.parseRespectOrIgnoreNulls(this.parseOrder({thisExpr:this.parseHavingMax(this.parseRespectOrIgnoreNulls(o))})))}parseSchema(e={}){let{this:t}=e,s=this.index;if(!this.match("lParen"))return t;if(this.matchSet(this._constructor.SELECT_START_TOKENS))return this.retreat(s),t;let r=this.parseCsv(()=>this.parseConstraint()||this.parseFieldDef());return this.matchRParen(),this.expression(Rt,{this:t,expressions:r})}parseAlterTableSet(){let e=this.expression(Sy);if(this.match("lParen",{advance:!1})||this.matchTextSeq(["TABLE","PROPERTIES"]))e.setArgKey("expressions",this.parseWrappedCsv(this.parseAssignment.bind(this)));else if(this.matchTextSeq("FILESTREAM_ON",{advance:!1}))e.setArgKey("expressions",[this.parseAssignment()]);else if(this.matchTexts(["LOGGED","UNLOGGED"]))e.setArgKey("option",Z((this.prev?.text??"").toUpperCase()));else if(this.matchTextSeq("WITHOUT")&&this.matchTexts(["CLUSTER","OIDS"]))e.setArgKey("option",Z(`WITHOUT ${(this.prev?.text??"").toUpperCase()}`));else if(this.matchTextSeq("LOCATION"))e.setArgKey("location",this.parseField());else if(this.matchTextSeq(["ACCESS","METHOD"]))e.setArgKey("accessMethod",this.parseField());else if(this.matchTextSeq("TABLESPACE"))e.setArgKey("tablespace",this.parseField());else if(this.matchTextSeq(["FILE","FORMAT"])||this.matchTextSeq("FILEFORMAT"))e.setArgKey("fileFormat",[this.parseField()]);else if(this.matchTextSeq("STAGE_FILE_FORMAT"))e.setArgKey("fileFormat",this.parseWrappedOptions());else if(this.matchTextSeq("STAGE_COPY_OPTIONS"))e.setArgKey("copyOptions",this.parseWrappedOptions());else if(this.matchTextSeq("TAG")||this.matchTextSeq("TAGS"))e.setArgKey("tag",this.parseCsv(this.parseAssignment.bind(this)));else{this.matchTextSeq("SERDE")&&e.setArgKey("serde",this.parseField());let t=this.parseWrapped(this.parseProperties.bind(this),{optional:!0});e.setArgKey("expressions",t?[t]:[])}return e}parseAlterSession(){if(this.match("set")){let t=this.parseCsv(()=>this.parseSetItemAssignment());return this.expression(mA,{expressions:t,unset:!1})}this.matchTextSeq("UNSET");let e=this.parseCsv(()=>this.expression(Xl,{this:this.parseIdVar({anyToken:!0})}));return this.expression(mA,{expressions:e,unset:!0})}parseAlter(){let e=this.prev,t=this.matchTextSeq("ICEBERG")||void 0,s=(this.matchSet(this._constructor.ALTERABLES)||void 0)&&this.prev;if(!s)return this.parseAsCommand(e);if(t&&s.tokenType!=="table")return this.parseAsCommand(e);let r=this.parseExists(),i=this.matchTextSeq("ONLY")||void 0,o,c,p;s.tokenType==="session"?(o=void 0,c=void 0,p=void 0):(o=this.parseTable({schema:!0,parsePartition:this._constructor.ALTER_TABLE_PARTITIONS}),c=this.matchTextSeq(["WITH","CHECK"])||void 0,p=this.match("on")?this.parseOnProperty():void 0,this.next&&this.advance());let u=this.prev?this._constructor.ALTER_PARSERS[this.prev.text.toUpperCase()]:void 0;if(u){let h=J(u.call(this)),g=this.matchTextSeq(["NOT","VALID"])||void 0,f=this.parseCsv(this.parseProperty.bind(this)),x=this._dialectConstructor.ALTER_TABLE_SUPPORTS_CASCADE&&this.matchTextSeq("CASCADE");if(!this.curr&&h)return this.expression(lu,{this:o,kind:st(YI,s.text)??s.text.toUpperCase(),exists:r,actions:h,only:i,options:f,cluster:p,notValid:g,check:c,cascade:x,iceberg:t})}return this.parseAsCommand(e)}parseAnalyze(){let e=this.prev;if(!this.curr)return this.expression(NA);let t=[];for(;this.matchTexts(this._constructor.ANALYZE_STYLES);)(this.prev?.text??"").toUpperCase()==="BUFFER_USAGE_LIMIT"?t.push(`BUFFER_USAGE_LIMIT ${this.parseNumber()}`):t.push((this.prev?.text??"").toUpperCase());let s,r,i=this.curr?.text.toUpperCase();this.match("table")||this.match("index")?s=this.parseTableParts():this.matchTextSeq("TABLES")?this.matchSet(["from","in"])&&(i=`${i} ${(this.prev?.text??"").toUpperCase()}`,s=this.parseTable({schema:!0,isDbReference:!0})):this.matchTextSeq("DATABASE")?s=this.parseTable({schema:!0,isDbReference:!0}):this.matchTextSeq("CLUSTER")?s=this.parseTable():this.matchTexts(Object.keys(this._constructor.ANALYZE_EXPRESSION_PARSERS))?(i=void 0,r=this._constructor.ANALYZE_EXPRESSION_PARSERS[(this.prev?.text??"").toUpperCase()].call(this)):(i=void 0,s=this.parseTableParts());let o=this.tryParse(this.parsePartition.bind(this));if(!o&&this.matchTexts(this._constructor.PARTITION_KEYWORDS))return this.parseAsCommand(e);let c;this.matchTextSeq(["WITH","SYNC","MODE"])||this.matchTextSeq(["WITH","ASYNC","MODE"])?c=`WITH ${this.tokens[this.index-2].text.toUpperCase()} MODE`:c=void 0,this.matchTexts(Object.keys(this._constructor.ANALYZE_EXPRESSION_PARSERS))&&(r=this._constructor.ANALYZE_EXPRESSION_PARSERS[(this.prev?.text??"").toUpperCase()].call(this));let p=this.parseProperties();return this.expression(NA,{kind:i,this:s,mode:c,partition:o,properties:p,expression:r,options:t})}parseAnalyzeStatistics(){let e,t=(this.prev?.text??"").toUpperCase(),s=this.matchTextSeq("DELTA")?(this.prev?.text??"").toUpperCase():void 0,r=[];if(this.matchTextSeq("STATISTICS")||this.raiseError("Expecting token STATISTICS"),this.matchTextSeq("NOSCAN"))e="NOSCAN";else if(this.match("for"))this.matchTextSeq(["ALL","COLUMNS"])&&(e="FOR ALL COLUMNS"),this.matchTexts("COLUMNS")&&(e="FOR COLUMNS",r=this.parseCsv(this.parseColumnReference.bind(this)));else if(this.matchTextSeq("SAMPLE")){let i=this.parseNumber();r=[this.expression(lC,{sample:i,kind:this.match("percent")?(this.prev?.text??"").toUpperCase():void 0})]}return this.expression(cC,{kind:t,option:s,this:e,expressions:r})}parseAnalyzeValidate(){let e,t,s;return this.matchTextSeq(["REF","UPDATE"])?(e="REF",t="UPDATE",this.matchTextSeq(["SET","DANGLING","TO","NULL"])&&(t="UPDATE SET DANGLING TO NULL")):this.matchTextSeq("STRUCTURE")&&(e="STRUCTURE",this.matchTextSeq(["CASCADE","FAST"])?t="CASCADE FAST":this.matchTextSeq(["CASCADE","COMPLETE"])&&this.matchTexts(["ONLINE","OFFLINE"])&&(t=`CASCADE COMPLETE ${(this.prev?.text??"").toUpperCase()}`,s=this.parseInto())),this.expression(gC,{kind:e,this:t,expression:s})}parseAnalyzeColumns(){let e=(this.prev?.text??"").toUpperCase();if(this.matchTextSeq("COLUMNS"))return this.expression(hu,{this:`${e} ${(this.prev?.text??"").toUpperCase()}`})}parseAnalyzeDelete(){let e=this.matchTextSeq("SYSTEM")?(this.prev?.text??"").toUpperCase():void 0;if(this.matchTextSeq("STATISTICS"))return this.expression(hC,{kind:e})}parseAnalyzeList(){if(this.matchTextSeq(["CHAINED","ROWS"]))return this.expression(uC,{expression:this.parseInto()})}parseAnalyzeHistogram(){let e=(this.prev?.text??"").toUpperCase(),t,s=[],r;if(this.matchTextSeq(["HISTOGRAM","ON"])){s=this.parseCsv(this.parseColumnReference.bind(this));let i=[];for(;this.match("with");)if(this.matchTexts(["SYNC","ASYNC"]))this.matchTextSeq("MODE",{advance:!1})&&(i.push(`${(this.prev?.text??"").toUpperCase()} MODE`),this.advance());else{let o=this.parseNumber();this.matchTextSeq("BUCKETS")&&i.push(`${o} BUCKETS`)}0<i.length&&(t=this.expression(uu,{expressions:i})),this.matchTexts(["MANUAL","AUTO"])&&this.match("update",{advance:!1})?(r=(this.prev?.text??"").toUpperCase(),this.advance()):this.matchTextSeq(["USING","DATA"])&&(t=this.expression(gu,{this:this.parseString()}))}return this.expression(pC,{this:e,expressions:s,expression:t,updateOptions:r})}parseMerge(){this.match("into");let e=this.parseTable();e&&this.match("alias",{advance:!1})&&e.setArgKey("alias",this.parseTableAlias()),this.match("using");let t=this.parseTable();return this.expression(GA,{this:e,using:t,on:(this.match("on")||void 0)&&this.parseDisjunction(),usingCond:(this.match("using")||void 0)&&this.parseUsingIdentifiers(),whens:this.parseWhenMatched(),returning:this.parseReturning()})}parseWhenMatched(){let e=[];for(;this.match("when");){let t=!this.match("not");this.matchTextSeq("MATCHED");let s=this.matchTextSeq(["BY","TARGET"])?!1:this.matchTextSeq(["BY","SOURCE"]),r=this.match("and")?this.parseDisjunction():void 0;this.match("then");let i;if(this.match("insert")){let o=this.parseStar();o?i=this.expression(es,{this:o}):i=this.expression(es,{this:this.matchTextSeq("ROW")?Z("ROW"):this.parseValue({values:!1}),expression:this.matchTextSeq("VALUES")&&this.parseValue()})}else if(this.match("update")){let o=this.parseStar();o?i=this.expression(us,{expressions:o}):i=this.expression(us,{expressions:this.match("set")&&this.parseCsv(this.parseEquality.bind(this))})}else this.match("delete")?i=this.expression(Ve,{this:this.prev?.text??""}):i=this.parseVarFromOptions(this._constructor.CONFLICT_ACTIONS);e.push(this.expression(_n,{matched:t,source:s,condition:r,then:i}))}return this.expression(Au,{expressions:e})}parseShow(){let e=this.findParser(this._constructor.SHOW_PARSERS,this._constructor.SHOW_TRIE);return e?e.call(this):this.parseAsCommand(this.prev)}parseSetItemAssignment(e={}){let{kind:t}=e,s=this.index;if((t==="GLOBAL"||t==="SESSION")&&this.matchTextSeq("TRANSACTION"))return this.parseSetTransaction({global:t==="GLOBAL"});let r=this.parsePrimary()||this.parseColumn(),i=this.matchTexts(this._constructor.SET_ASSIGNMENT_DELIMITERS)||void 0;if(!r||this._constructor.SET_REQUIRES_ASSIGNMENT_DELIMITER&&!i){this.retreat(s);return}let o=this.parseStatement()||this.parseIdVar();(o instanceof $||o instanceof v)&&(o=Z(o.name));let c=this.expression(Me,{this:r,expression:o});return this.expression(Xl,{this:c,kind:t})}parseSetTransaction(e={}){let{global:t=!1}=e;this.matchTextSeq("TRANSACTION");let s=this.parseCsv(()=>this.parseVarFromOptions(this._constructor.TRANSACTION_CHARACTERISTICS));return this.expression(Xl,{expressions:s,kind:"TRANSACTION",global:t})}parseSetItem(){let e=this.findParser(this._constructor.SET_PARSERS,this._constructor.SET_TRIE);return e?e.call(this):this.parseSetItemAssignment({kind:void 0})}parseSet(e={}){let{unset:t=!1,tag:s=!1}=e,r=this.index,i=this.expression(Zl,{expressions:this.parseCsv(this.parseSetItem.bind(this)),unset:t,tag:s});return this.curr?(this.retreat(r),this.parseAsCommand(this.prev)):i}parseVarFromOptions(e,t={}){let{raiseUnmatched:s=!0}=t,r=this.curr;if(!r)return;let i=r.text.toUpperCase(),o=e[i],c=this.index;this.advance();let p=!1;for(let u of o||[]){let h=typeof u=="string"?[u]:u;if(this.matchTextSeq(h)){i=`${i} ${h.join(" ")}`,p=!0;break}}if(!p&&(o===void 0||0<o.length)){s&&this.raiseError(`Unknown option ${i}`),this.retreat(c);return}return Z(i)}parseCache(){let e=this.matchTextSeq("LAZY")||void 0;this.match("table");let t=this.parseTable({schema:!0}),s=[];if(this.matchTextSeq("OPTIONS")){this.matchLParen();let r=this.parseString();r||this.raiseError("Expected option key"),this.match("eq");let i=this.parseString();i||this.raiseError("Expected option value"),s=[r,i].filter(Boolean),this.matchRParen()}return this.match("alias"),this.expression(iy,{this:t,lazy:e,options:s,expression:this.parseSelect({nested:!0})})}parsePartition(){if(this.matchTexts(this._constructor.PARTITION_KEYWORDS))return this.expression(By,{subpartition:(this.prev?.text??"").toUpperCase()==="SUBPARTITION",expressions:this.parseWrappedCsv(this.parseDisjunction.bind(this))})}parseValue(e){let t=n(()=>this._dialectConstructor.SUPPORTS_VALUES_DEFAULT&&this.match("default")?Z((this.prev?.text??"").toUpperCase()):this.parseExpression(),"parseValueExpression");if(this.match("lParen")){let r=this.parseCsv(t);return this.matchRParen(),this.expression(Ze,{expressions:r})}let s=this.parseExpression();if(s)return this.expression(Ze,{expressions:[s]})}parseProjections(){return[this.parseExpressions(),void 0]}parseWrappedSelect(e={}){let{table:t=!1}=e,s;if(this.matchSet(["pivot","unpivot"]))s=this.parseSimplifiedPivot({isUnpivot:this.prev?.tokenType==="unpivot"});else if(this.match("from")){let r=this.parseFrom({skipFromToken:!0,consumePipe:!0}),i=this.parseSelect({from:r});i?(i.args.from||i.setArgKey("from",r),s=i):(s=Ye("*").from(r),s=this.parseQueryModifiers(this.parseSetOperations(s)))}else{if(s=t?this.parseTable({consumePipe:!0}):this.parseSelect({nested:!0,parseSetOperation:!1}),t&&s instanceof tr&&s.alias){let r=s.args.alias?.pop();s=new _({this:s,alias:r})}s=this.parseQueryModifiers(this.parseSetOperations(s))}return s}parseCommitOrRollback(){let e,t,s=this.prev?.tokenType==="rollback";return this.matchTexts(["TRANSACTION","WORK"]),this.matchTextSeq("TO")&&(this.matchTextSeq("SAVEPOINT"),t=this.parseIdVar()),this.match("and")&&(e=!this.matchTextSeq("NO"),this.matchTextSeq("CHAIN")),s?this.expression(oC,{savepoint:t}):this.expression(aC,{chain:e})}parseRefresh(){let e;this.match("table")?e="TABLE":this.matchTextSeq(["MATERIALIZED","VIEW"])?e="MATERIALIZED VIEW":e="";let t=this.parseString()||this.parseTable();return!e&&!(t instanceof N)?this.parseAsCommand(this.prev):this.expression(ay,{this:t,kind:e})}parseColumnDefWithExists(){let e=this.index;this.match("column");let t=this.parseExists({not:!0}),s=this.parseFieldDef();if(!(s instanceof be)){this.retreat(e);return}return s.setArgKey("exists",t),s}parseAddColumn(){if((this.prev?.text??"").toUpperCase()==="ADD")return this.parseColumnDefWithExists()??void 0}parseDropColumn(){let e=(this.match("drop")||void 0)&&this.parseDrop();return e&&!(e instanceof $r)&&e.setArgKey("kind",e.args.kind||"COLUMN"),e}parseDropPartition(e={}){let{exists:t}=e;return this.expression(dC,{expressions:this.parseCsv(this.parsePartition.bind(this)),exists:t})}parseAlterTableAdd(){let e=n(()=>{if(this.matchTextSeq("ADD"),this.matchSet(this._constructor.ADD_CONSTRAINT_TOKENS,{advance:!1}))return this.expression(EC,{expressions:this.parseCsv(this.parseConstraint.bind(this))});let t=this.parseAddColumn();if(t instanceof be)return t;let s=this.parseExists({not:!0});if(this.matchPair("partition","lParen",{advance:!1}))return this.expression(AC,{exists:s,this:this.parseField({anyToken:!0}),location:this.matchTextSeq("LOCATION",{advance:!1})&&this.parseProperty()})},"parseAddAlteration");if(!this.matchSet(this._constructor.ADD_CONSTRAINT_TOKENS,{advance:!1})&&(!this._dialectConstructor.ALTER_TABLE_ADD_REQUIRED_FOR_EACH_COLUMN||this.matchTextSeq("COLUMNS"))){let t=this.parseSchema();return t?Array.from(J(t)):this.parseCsv(this.parseColumnDefWithExists.bind(this))}return this.parseCsv(e)}parseAlterTableAlter(){if(this.matchTexts(Object.keys(this._constructor.ALTER_ALTER_PARSERS)))return this._constructor.ALTER_ALTER_PARSERS[(this.prev?.text??"").toUpperCase()]?.call(this);this.match("column");let e=this.parseField({anyToken:!0});return this.matchPair("drop","default")?this.expression(Os,{this:e,drop:!0}):this.matchPair("set","default")?this.expression(Os,{this:e,default:this.parseDisjunction()}):this.match("comment")?this.expression(Os,{this:e,comment:this.parseString()}):this.matchTextSeq(["DROP","NOT","NULL"])?this.expression(Os,{this:e,drop:!0,allowNull:!0}):this.matchTextSeq(["SET","NOT","NULL"])?this.expression(Os,{this:e,allowNull:!1}):this.matchTextSeq(["SET","VISIBLE"])?this.expression(Os,{this:e,visible:"VISIBLE"}):this.matchTextSeq(["SET","INVISIBLE"])?this.expression(Os,{this:e,visible:"INVISIBLE"}):(this.matchTextSeq(["SET","DATA"]),this.matchTextSeq("TYPE"),this.expression(Os,{this:e,dtype:this.parseTypes(),collate:this.match("collate")&&this.parseTerm(),using:this.match("using")&&this.parseDisjunction()}))}parseAlterDiststyle(){return this.matchTexts(["ALL","EVEN","AUTO"])?this.expression(SA,{this:Z((this.prev?.text??"").toUpperCase())}):(this.matchTextSeq(["KEY","DISTKEY"]),this.expression(SA,{this:this.parseColumn()}))}parseAlterSortkey(e={}){let{compound:t}=e;return t&&this.matchTextSeq("SORTKEY"),this.match("lParen",{advance:!1})?this.expression(RA,{expressions:this.parseWrappedIdVars(),compound:t}):(this.matchTexts(["AUTO","NONE"]),this.expression(RA,{this:Z((this.prev?.text??"").toUpperCase()),compound:t}))}parseAlterTableDrop(){let e=this.index-1,t=this.parseExists();return this.match("partition",{advance:!1})?this.parseCsv(()=>this.parseDropPartition({exists:t})):(this.retreat(e),this.parseCsv(this.parseDropColumn.bind(this)))}parseAlterTableRename(){if(this.match("column")||!this._constructor.ALTER_RENAME_REQUIRES_COLUMN){let e=this.parseExists(),t=this.parseColumn(),s=this.matchTextSeq("TO")||void 0,r=this.parseColumn();return!t||!s||!r?void 0:this.expression(vA,{this:t,to:r,exists:e})}return this.matchTextSeq("TO"),this.expression(Yn,{this:this.parseTable({schema:!0})})}parseLoad(){if(this.matchTextSeq("DATA")){let e=this.matchTextSeq("LOCAL")||void 0;this.matchTextSeq("INPATH");let t=this.parseString(),s=this.match("overwrite")||void 0;return this.matchPair("into","table"),this.expression(Fy,{this:this.parseTable({schema:!0}),local:e,overwrite:s,inpath:t,partition:this.parsePartition(),inputFormat:this.matchTextSeq("INPUTFORMAT")&&this.parseString(),serde:this.matchTextSeq("SERDE")&&this.parseString()})}return this.parseAsCommand(this.prev)}parseDelete(){let e;this.match("from",{advance:!1})||(e=this.parseCsv(this.parseTable.bind(this))||void 0);let t=this.parseReturning();return this.expression(Gr,{tables:e,this:this.match("from")&&this.parseTable({joins:!0}),using:this.match("using")&&this.parseCsv(()=>this.parseTable({joins:!0})),cluster:this.match("on")&&this.parseOnProperty(),where:this.parseWhere(),returning:t||this.parseReturning(),order:this.parseOrder(),limit:this.parseLimit()})}parseUpdate(){let e={this:this.parseTable({joins:!0,aliasTokens:this._constructor.UPDATE_ALIAS_TOKENS})};for(;this.curr;)if(this.match("set"))e.expressions=this.parseCsv(this.parseEquality.bind(this));else if(this.match("returning",{advance:!1}))e.returning=this.parseReturning();else if(this.match("from",{advance:!1})){let t=this.parseFrom({joins:!0}),s=t?.args.this;if(s instanceof he&&this.match("join",{advance:!1})){let r=this.parseJoins();s.setArgKey("joins",0<r.length?r:void 0)}e.from=t}else if(this.match("where",{advance:!1}))e.where=this.parseWhere();else if(this.match("orderBy",{advance:!1}))e.order=this.parseOrder();else if(this.match("limit",{advance:!1}))e.limit=this.parseLimit();else break;return this.expression(us,e)}parseUse(){return this.expression(CC,{kind:this.parseVarFromOptions(this._constructor.USABLES,{raiseUnmatched:!1}),this:this.parseTable({schema:!1})})}parseUncache(){return this.match("table")||this.raiseError("Expecting TABLE after UNCACHE"),this.expression(ny,{exists:this.parseExists(),this:this.parseTable({schema:!0})})}parseAsCommand(e){for(;this.curr;)this.advance();let t=this.findSql(e,this.prev),s=e?.text.length||0;return this.warnUnsupported(),new $r({this:t.substring(0,s),expression:t.substring(s)})}parseDictProperty(e){let t=[];this.matchLParen();let s=this.parseIdVar();if(this.match("lParen")){for(;;){let r=this.parseIdVar(),i=this.parsePrimary();if(!r&&!i)break;t.push(this.expression(GC,{this:r,value:i}))}this.match("rParen")}return this.matchRParen(),this.expression(Hu,{this:e.this,kind:s?.args.this,settings:t})}parseDictRange(e){this.matchLParen();let t=this.matchTextSeq("MIN")||void 0,s,r;return t?(s=this.parseVar()||this.parsePrimary(),s||this.raiseError("Expected MIN value"),this.matchTextSeq("MAX"),r=this.parseVar()||this.parsePrimary(),r||this.raiseError("Expected MAX value")):(r=this.parseVar()||this.parsePrimary(),r||this.raiseError("Expected MAX value"),s=N.number(0)),this.matchRParen(),this.expression(_u,{this:e.this,min:s,max:r})}parseComprehension(e){let t=this.index,s=this.parseColumn(),r=(this.match("comma")||void 0)&&this.parseColumn();if(!this.match("in")){this.retreat(t-1);return}let i=this.parseColumn(),o=this.matchTextSeq("IF")?this.parseDisjunction():void 0;return this.expression(Oy,{this:e,expression:s,position:r,iterator:i,condition:o})}parseHeredoc(){if(this.match("heredocString"))return this.expression(xA,{this:this.prev?.text??""});if(!this.matchTextSeq("$"))return;let e=["$"],t;this.isConnected()?(this.advance(),e.push((this.prev?.text??"").toUpperCase())):this.raiseError("No closing $ found"),e[e.length-1]!=="$"&&(this.isConnected()&&this.matchTextSeq("$")?(t=e[e.length-1],e.push("$")):this.raiseError("No closing $ found"));let s=this.curr;for(;this.curr;){if(this.matchTextSeq(e,{advance:!1})){let r=this.findSql(s,this.prev);return this.advance(e.length),this.expression(xA,{this:r,tag:t})}this.advance()}this.raiseError(`No closing ${e.join("")} found`)}findParser(e,t){if(!this.curr)return;let s=this.index,r=[];for(;;){let i=this.curr.text.toUpperCase(),o=i.split(" ");r.push(i),this.advance();let[c,p]=Nn(t,o);if(t=p,c===0)break;if(c===2)return e[r.join(" ")]}this.retreat(s)}parseGroupConcat(){let e=n((i,o)=>{if(i instanceof et&&1<(i.args.expressions?.length??0)){let c=[this.expression(Bt,{expressions:i.args.expressions,safe:!0,coalesce:this._dialectConstructor.CONCAT_COALESCE})];return i.setArgKey("expressions",c),i}return o.length===1?o[0]:this.expression(Bt,{expressions:o,safe:!0,coalesce:this._dialectConstructor.CONCAT_COALESCE})},"concatExprs"),t=this.parseCsv(this.parseLambda.bind(this)),s;if(t){let i=t[t.length-1],o=i instanceof Ie?i:void 0;o?.args.this&&(t[t.length-1]=o.args.this,o.setArgKey("this",e(o.args.this,t))),s=o||e(t[0],t)}else s=void 0;let r=this.match("separator")?this.parseField():void 0;return this.expression(sr,{this:s,separator:r})}parseInitcap(){let e=Th.fromArgList(this.parseFunctionArgs());return e.args.expression||e.setArgKey("expression",N.string(this._dialectConstructor.INITCAP_DEFAULT_DELIMITER_CHARS)),e}parseOperator(e){let t=e;for(;this.match("lParen");){let s="";for(;this.curr&&!this.match("rParen");)s+=this.curr.text,this.advance();if(t=this.expression(ch,{comments:this.prevComments,this:t,operator:s,expression:this.parseBitwise()}),!this.match("operator"))break}return t}buildPipeCte(e){let{query:t,expressions:s,aliasCte:r}=e,i;r?i=r:(this.pipeCteCounter+=1,i=`__tmp${this.pipeCteCounter}`);let c=t.args.with?.pop(),p=Ye(...s,{copy:!1}).from(i,{copy:!1});return c&&p.setArgKey("with",c),p.with(i,t,{copy:!1})}parsePipeSyntaxSelect(e){let t=this.parseSelect({consumePipe:!1});return t?this.buildPipeCte({query:e.select(t.args.expressions,{append:!1}),expressions:[new Ne({})]}):e}parsePipeSyntaxLimit(e){let t=this.parseLimit(),s=this.parseOffset();if(t){let r=e.args.limit||t,i;if(typeof r=="number")i=r;else{re(r,kt);let c=r.args.expression;re(c,d),i=c.toValue()}(t.args.expression?.toValue()??0)<=i&&e.limit(t,{copy:!1})}if(s){let r=e.args.offset,i;if(r===void 0)i=0;else if(typeof r=="number")i=r;else{re(r,Cn);let p=r.args.expression;i=typeof p=="number"?p:(re(p,d),p.toValue())}let o=s.args.expression,c=typeof o=="number"?o:(re(o,d),o.toValue());e.offset(N.number(i+c),{copy:!1})}return e}parsePipeSyntaxAggregateFields(){let e=this.parseDisjunction();return this.matchTextSeq(["GROUP","AND"],{advance:!1})?e:(e=this.parseAlias(e),this.matchSet(["asc","desc"],{advance:!1})?this.parseOrdered(()=>e):e)}parsePipeSyntaxAggregateGroupOrderBy(e,t={}){let{groupByExists:s=!0}=t,r=this.parseCsv(this.parsePipeSyntaxAggregateFields.bind(this)),i=[],o=[];for(let c of r){let p;c instanceof hs?(p=c.args.this,p instanceof Re&&c.setArgKey("this",p.args.alias),o.push(c)):p=c,p&&i.push(p)}return s?e.select(i,{copy:!1}).groupBy(i.map(c=>c.args.alias||c),{copy:!1}):e.select(i,{append:!1,copy:!1}),0<o.length?e.orderBy(o,{append:!1,copy:!1}):e}parsePipeSyntaxAggregate(e){return this.matchTextSeq("AGGREGATE"),e=this.parsePipeSyntaxAggregateGroupOrderBy(e,{groupByExists:!1}),(this.match("groupBy")||this.matchTextSeq(["GROUP","AND"])&&this.match("orderBy"))&&(e=this.parsePipeSyntaxAggregateGroupOrderBy(e)),this.buildPipeCte({query:e,expressions:[new Ne({})]})}parsePipeSyntaxSetOperator(e){if(!e)return;let t=this.parseSetOperation(e);if(!t)return;let s=n(()=>{let c=this.parseParen();return c?c.assertIs(he).unnest():void 0},"parseAndUnwrapQuery");t.args.this?.pop();let r=[t.args.expression?.pop().assertIs(he).unnest(),...this.parseCsv(s)];e=this.buildPipeCte({query:e,expressions:[new Ne({})]});let o=e.args.with?.pop();if(t instanceof or?e=e.union(r,{copy:!1,...t.args}):t instanceof cr?e=e.except(r,{copy:!1,...t.args}):e=e.intersect(r,{copy:!1,...t.args}),!!e)return e.setArgKey("with",o),this.buildPipeCte({query:e,expressions:[new Ne({})]})}parsePipeSyntaxJoin(e){if(!e)return;let t=this.parseJoin();if(t)return e instanceof se?e.join(t,{copy:!1}):e}parsePipeSyntaxPivot(e){let t=this.parsePivots();if(!t)return e;let s=e.args.from;if(s){let r=s.args.this;Y(r,d)&&r.setArgKey("pivots",t)}return this.buildPipeCte({query:e,expressions:[new Ne({})]})}parsePipeSyntaxExtend(e){return this.matchTextSeq("EXTEND"),e.select([new Ne({}),...this.parseExpressions()],{append:!1,copy:!1}),this.buildPipeCte({query:e,expressions:[new Ne({})]})}parsePipeSyntaxTablesample(e){let t=this.parseTableSample(),s=e.args.with;if(s){let r=s.args.expressions?.[s.args.expressions.length-1];r instanceof d&&r.args.this instanceof d&&r.args.this.setArgKey("sample",t)}else e.setArgKey("sample",t);return e}parsePipeSyntaxQuery(e){let t=e;for(t instanceof he&&(t=Ye("*").from(t,{copy:!1})),t.args.from||(t=Ye("*").from(t.subquery(void 0,{copy:!1}),{copy:!1}));this.match("pipeGt");){let s=this.curr,r=s?this.tokens.indexOf(s):-1,i=this._constructor.PIPE_SYNTAX_TRANSFORM_PARSERS[this.curr?.text.toUpperCase()??""];if(i)t=i.call(this,t);else{let o=this.parsePipeSyntaxSetOperator(t);if(o=o||this.parsePipeSyntaxJoin(t),!o&&0<=r){this.retreat(r),this.raiseError(`Unsupported pipe syntax operator: '${s?.text.toUpperCase()}'.`);break}t=o}}return t}parseDeclareitem(){this.matchTexts(["VAR","VARIABLE"]);let e=this.parseCsv(this.parseIdVar.bind(this));if(!e)return;this.match("alias");let t=this.match("table")?this.parseSchema():this.parseTypes(),s=(this.match("default")||this.match("eq"))&&this.parseBitwise();return this.expression(dy,{this:e,kind:t,default:s})}parseDeclare(){let e=this.prev,t=this.matchTextSeq(["OR","REPLACE"]),s=this.tryParse(()=>this.parseCsv(this.parseDeclareitem.bind(this)));return!s||this.curr?this.parseAsCommand(e):this.expression(Ay,{expressions:s,replace:t||void 0})}buildCast(e){let{strict:t}=e,s=t?z:$t,r={...e};return delete r.strict,s===$t&&(r.requiresString=this._dialectConstructor.TRY_CAST_REQUIRES_STRING),this.expression(s,r)}parseJsonValue(){let e=this.parseBitwise();this.match("comma");let t=this.parseBitwise(),s=(this.match("returning")||void 0)&&this.parseType();return this.expression(NC,{this:e,path:this.dialect.toJsonPath(t),returning:s,onCondition:this.parseOnCondition()})}validateExpression(e,t){if(this.errorLevel!==0)for(let s of e.errorMessages(t))this.raiseError(s);return e}get _constructor(){return this.constructor}get _dialectConstructor(){return this.dialect._constructor}};F=vt(null),R(F,10,"FUNCTIONS",MH,S),R(F,10,"NO_PAREN_FUNCTIONS",wH,S),R(F,10,"STRUCT_TYPE_TOKENS",LH,S),R(F,10,"NESTED_TYPE_TOKENS",PH,S),R(F,10,"ENUM_TYPE_TOKENS",bH,S),R(F,10,"AGGREGATE_TYPE_TOKENS",CH,S),R(F,10,"TYPE_TOKENS",yH,S),R(F,10,"SIGNED_TO_UNSIGNED_TYPE_TOKEN",IH,S),R(F,10,"SUBQUERY_PREDICATES",NH,S),R(F,10,"SUBQUERY_TOKENS",mH,S),R(F,10,"RESERVED_TOKENS",OH,S),R(F,10,"DB_CREATABLES",RH,S),R(F,10,"CREATABLES",SH,S),R(F,10,"ALTERABLES",TH,S),R(F,10,"ID_VAR_TOKENS",xH,S),R(F,10,"TABLE_ALIAS_TOKENS",fH,S),R(F,10,"ALIAS_TOKENS",dH,S),R(F,10,"COLON_PLACEHOLDER_TOKENS",AH,S),R(F,10,"ARRAY_CONSTRUCTORS",EH,S),R(F,10,"COMMENT_TABLE_ALIAS_TOKENS",gH,S),R(F,10,"UPDATE_ALIAS_TOKENS",hH,S),R(F,10,"TRIM_TYPES",uH,S),R(F,10,"TABLE_FAST_TERMINATORS",lH,S),R(F,10,"FUNC_TOKENS",pH,S),R(F,10,"CONJUNCTION",cH,S),R(F,10,"ASSIGNMENT",oH,S),R(F,10,"DISJUNCTION",aH,S),R(F,10,"EQUALITY",nH,S),R(F,10,"COMPARISON",iH,S),R(F,10,"BITWISE",rH,S),R(F,10,"TERM",sH,S),R(F,10,"FACTOR",tH,S),R(F,10,"EXPONENT",eH,S),R(F,10,"TIMES",KV,S),R(F,10,"TIMESTAMPS",ZV,S),R(F,10,"SET_OPERATIONS",QV,S),R(F,10,"JOIN_METHODS",zV,S),R(F,10,"JOIN_SIDES",JV,S),R(F,10,"JOIN_KINDS",XV,S),R(F,10,"LAMBDAS",jV,S),R(F,10,"COLUMN_OPERATORS",WV,S),R(F,10,"CAST_COLUMN_OPERATORS",_V,S),R(F,10,"EXPRESSION_PARSERS",HV,S),R(F,10,"STATEMENT_PARSERS",VV,S),R(F,10,"UNARY_PARSERS",YV,S),R(F,10,"STRING_PARSERS",GV,S),R(F,10,"NUMERIC_PARSERS",$V,S),R(F,10,"PRIMARY_PARSERS",BV,S),R(F,10,"PLACEHOLDER_PARSERS",FV,S),R(F,10,"RANGE_PARSERS",vV,S),R(F,10,"PIPE_SYNTAX_TRANSFORM_PARSERS",UV,S),R(F,10,"PROPERTY_PARSERS",qV,S),R(F,10,"CONSTRAINT_PARSERS",DV,S),R(F,10,"ALTER_PARSERS",kV,S),R(F,10,"NO_PAREN_FUNCTION_PARSERS",MV,S),R(F,10,"INVALID_FUNC_NAME_TOKENS",wV,S),R(F,10,"KEY_VALUE_DEFINITIONS",LV,S),R(F,10,"FUNCTION_PARSERS",PV,S),R(F,10,"QUERY_MODIFIER_PARSERS",bV,S),R(F,10,"QUERY_MODIFIER_TOKENS",CV,S),R(F,10,"TYPE_LITERAL_PARSERS",yV,S),R(F,10,"TYPE_CONVERTERS",IV,S),R(F,10,"DDL_SELECT_TOKENS",NV,S),R(F,10,"PRE_VOLATILE_TOKENS",mV,S),R(F,10,"OPTYPE_FOLLOW_TOKENS",OV,S),R(F,10,"TABLE_INDEX_HINT_TOKENS",RV,S),R(F,10,"WINDOW_ALIAS_TOKENS",SV,S),R(F,10,"WINDOW_BEFORE_PAREN_TOKENS",TV,S),R(F,10,"JSON_KEY_VALUE_SEPARATOR_TOKENS",xV,S),R(F,10,"FETCH_TOKENS",fV,S),R(F,10,"ADD_CONSTRAINT_TOKENS",dV,S),R(F,10,"DISTINCT_TOKENS",AV,S),R(F,10,"UNNEST_OFFSET_ALIAS_TOKENS",EV,S),R(F,10,"SELECT_START_TOKENS",gV,S),R(F,10,"PRIVILEGE_FOLLOW_TOKENS",hV,S),R(F,10,"AMBIGUOUS_ALIAS_TOKENS",uV,S),R(F,10,"MODIFIABLES",lV,S),Nt(F,S),It(F,3,S),n(S,"Parser"),S._showTrie=void 0,S._setTrie=void 0,S.FAST_COLUMN_TOKENS=new Set(["var","identifier"]),S.BRACKETS=new Set(["lBracket","lBrace"]),S.COLUMN_POSTFIX_TOKENS=new Set(["lParen","lBracket","lBrace","colon","joinMarker"]),S.TABLE_POSTFIX_TOKENS=new Set(["lParen","lBracket","lBrace","pivot","unpivot","tableSample"]),S.JOIN_HINTS=new Set,S.TYPED_LAMBDA_ARGS=!1,S.LAMBDA_ARG_TERMINATORS=new Set(["comma","rParen"]),S.ALTER_ALTER_PARSERS={DISTKEY:n(function(){return this.parseAlterDiststyle()},"DISTKEY"),DISTSTYLE:n(function(){return this.parseAlterDiststyle()},"DISTSTYLE"),SORTKEY:n(function(){return this.parseAlterSortkey()},"SORTKEY"),COMPOUND:n(function(){return this.parseAlterSortkey({compound:!0})},"COMPOUND")},S.SCHEMA_UNNAMED_CONSTRAINTS=new Set(["CHECK","EXCLUDE","FOREIGN KEY","LIKE","PERIOD","PRIMARY KEY","UNIQUE","BUCKET","TRUNCATE"]),S.FUNCTIONS_WITH_ALIASED_ARGS=new Set(["STRUCT"]),S.SET_PARSERS={GLOBAL:n(function(){return this.parseSetItemAssignment({kind:"GLOBAL"})},"GLOBAL"),LOCAL:n(function(){return this.parseSetItemAssignment({kind:"LOCAL"})},"LOCAL"),SESSION:n(function(){return this.parseSetItemAssignment({kind:"SESSION"})},"SESSION"),TRANSACTION:n(function(){return this.parseSetTransaction()},"TRANSACTION")},S.SHOW_PARSERS={},S.TRANSACTION_KIND=new Set(["DEFERRED","IMMEDIATE","EXCLUSIVE"]),S.TRANSACTION_CHARACTERISTICS={ISOLATION:[["LEVEL","REPEATABLE","READ"],["LEVEL","READ","COMMITTED"],["LEVEL","READ","UNCOMITTED"],["LEVEL","SERIALIZABLE"]],READ:["WRITE","ONLY"]},S.CONFLICT_ACTIONS={...Object.fromEntries(["ABORT","FAIL","IGNORE","REPLACE","ROLLBACK","UPDATE"].map(e=>[e,[]])),DO:["NOTHING","UPDATE"]},S.TRIGGER_TIMING={INSTEAD:[["OF"]],BEFORE:[],AFTER:[]},S.TRIGGER_FOR_EACH={ROW:[],STATEMENT:[]},S.TRIGGER_DEFERRABLE={NOT:[["DEFERRABLE"]],DEFERRABLE:[]},S.TRIGGER_INITIALLY_VALUE={IMMEDIATE:[],DEFERRED:[]},S.CREATE_SEQUENCE={SCALE:["EXTEND","NOEXTEND"],ShaRD:["EXTEND","NOEXTEND"],NO:["CYCLE","CACHE","MAXVALUE","MINVALUE"],...Object.fromEntries(["SESSION","GLOBAL","KEEP","NOKEEP","ORDER","NOORDER","NOCACHE","CYCLE","NOCYCLE","NOMINVALUE","NOMAXVALUE","NOSCALE","NOSHARD"].map(e=>[e,[]]))},S.ISOLATED_LOADING_OPTIONS={FOR:["ALL","INSERT","NONE"]},S.USABLES=Object.fromEntries(["ROLE","WAREHOUSE","DATABASE","SCHEMA","CATALOG"].map(e=>[e,[]])),S.CAST_ACTIONS=Object.fromEntries(["RENAME","ADD"].map(e=>[e,["FIELDS"]])),S.SCHEMA_BINDING_OPTIONS={TYPE:["EVOLUTION"],...Object.fromEntries(["BINDING","COMPENSATION","EVOLUTION"].map(e=>[e,[]]))},S.PROCEDURE_OPTIONS={},S.EXECUTE_AS_OPTIONS=Object.fromEntries(["CALLER","SELF","OWNER"].map(e=>[e,[]])),S.KEY_CONSTRAINT_OPTIONS={NOT:["ENFORCED"],MATCH:["FULL","PARTIAL","SIMPLE"],INITIALLY:["DEFERRED","IMMEDIATE"],USING:["BTREE","HASH"],...Object.fromEntries(["DEFERRABLE","NORELY","RELY"].map(e=>[e,[]]))},S.WINDOW_EXCLUDE_OPTIONS={NO:["OTHERS"],CURRENT:["ROW"],...Object.fromEntries(["GROUP","TIES"].map(e=>[e,[]]))},S.INSERT_ALTERNATIVES=new Set(["ABORT","FAIL","IGNORE","REPLACE","ROLLBACK"]),S.CLONE_KEYWORDS=new Set(["CLONE","COPY"]),S.HISTORICAL_DATA_PREFIX=new Set(["AT","BEFORE","END"]),S.HISTORICAL_DATA_KIND=new Set(["OFFSET","STATEMENT","STREAM","TIMESTAMP","VERSION"]),S.OPCLASS_FOLLOW_KEYWORDS=new Set(["ASC","DESC","NULLS","WITH"]),S.VIEW_ATTRIBUTES=new Set(["ENCRYPTION","SCHEMABINDING","VIEW_METADATA"]),S.WINDOW_SIDES=new Set(["FOLLOWING","PRECEDING"]),S.COPY_INTO_VARLEN_OPTIONS=new Set(["FILE_FORMAT","COPY_OPTIONS","FORMAT_OPTIONS","CREDENTIAL"]),S.IS_JSON_PREDICATE_KIND=new Set(["VALUE","SCALAR","ARRAY","OBJECT"]),S.ODBC_DATETIME_LITERALS={},S.ON_CONDITION_TOKENS=new Set(["ERROR","NULL","TRUE","FALSE","EMPTY"]),S.DESCRIBE_STYLES=new Set(["ANALYZE","EXTENDED","FORMATTED","HISTORY"]),S.SET_ASSIGNMENT_DELIMITERS=new Set(["=",":=","TO"]),S.ANALYZE_STYLES=new Set(["BUFFER_USAGE_LIMIT","FULL","LOCAL","NO_WRITE_TO_BINLOG","SAMPLE","SKIP_LOCKED","VERBOSE"]),S.ANALYZE_EXPRESSION_PARSERS={ALL:n(function(){return this.parseAnalyzeColumns()},"ALL"),COMPUTE:n(function(){return this.parseAnalyzeStatistics()},"COMPUTE"),DELETE:n(function(){return this.parseAnalyzeDelete()},"DELETE"),DROP:n(function(){return this.parseAnalyzeHistogram()},"DROP"),ESTIMATE:n(function(){return this.parseAnalyzeStatistics()},"ESTIMATE"),LIST:n(function(){return this.parseAnalyzeList()},"LIST"),PREDICATE:n(function(){return this.parseAnalyzeColumns()},"PREDICATE"),UPDATE:n(function(){return this.parseAnalyzeHistogram()},"UPDATE"),VALIDATE:n(function(){return this.parseAnalyzeValidate()},"VALIDATE")},S.PARTITION_KEYWORDS=new Set(["PARTITION","SUBPARTITION"]),S.OPERATION_MODIFIERS=new Set,S.RECURSIVE_CTE_SEARCH_KIND=new Set(["BREADTH","DEPTH","CYCLE"]),S.SECURITY_PROPERTY_KEYWORDS=["DEFINER","INVOKER","NONE"],S.STRICT_CAST=!0,S.PREFIXED_PIVOT_COLUMNS=!1,S.IDENTIFY_PIVOT_STRINGS=!1,S.LOG_DEFAULTS_TO_LN=!1,S.TABLESAMPLE_CSV=!1,S.DEFAULT_SAMPLING_METHOD=void 0,S.SET_REQUIRES_ASSIGNMENT_DELIMITER=!0,S.TRIM_PATTERN_FIRST=!1,S.STRING_ALIASES=!1,S.MODIFIERS_ATTACHED_TO_SET_OP=!0,S.SET_OP_MODIFIERS=new Set(["order","limit","offset"]),S.NO_PAREN_IF_COMMANDS=!0,S.JSON_ARROWS_REQUIRE_JSON_TYPE=!1,S.COLON_IS_VARIANT_EXTRACT=!1,S.VALUES_FOLLOWED_BY_PAREN=!0,S.SUPPORTS_IMPLICIT_UNNEST=!1,S.INTERVAL_SPANS=!0,S.SUPPORTS_PARTITION_SELECTION=!1,S.WRAPPED_TRANSFORM_COLUMN_CONSTRAINT=!0,S.OPTIONAL_ALIAS_TOKEN_CTE=!0,S.ALTER_RENAME_REQUIRES_COLUMN=!0,S.ALTER_TABLE_PARTITIONS=!1,S.JOINS_HAVE_EQUAL_PRECEDENCE=!1,S.ZONE_AWARE_TIMESTAMP_CONSTRUCTOR=!1,S.MAP_KEYS_ARE_ARBITRARY_EXPRESSIONS=!1,S.JSON_EXTRACT_REQUIRES_JSON_EXPRESSION=!1,S.ADD_JOIN_ON_TRUE=!1,S.SUPPORTS_OMITTED_INTERVAL_SPAN_UNIT=!1;var ry=S;var kH,DH,CD,fr=class fr extends(DH=Fr,kH=[O],DH){static get KEYWORDS(){return{"..":"dot"}}};CD=vt(DH),R(CD,10,"KEYWORDS",kH,fr),Nt(CD,fr),It(CD,3,fr),n(fr,"JsonPathTokenizer"),fr.SINGLE_TOKENS={"(":"lParen",")":"rParen","[":"lBracket","]":"rBracket",":":"colon",",":"comma","-":"dash",".":"dot","?":"placeholder","@":"parameter","'":"quote",'"':"quote",$:"dollar","*":"star"},fr.IDENTIFIER_ESCAPES=["\\"],fr.STRING_ESCAPES=["\\"],fr.VAR_TOKENS=new Set(["var"]);var YA=fr;var iJ={jsonPathFilter:(a,e)=>`?${e.args.this}`,jsonPathKey:(a,e)=>a.jsonPathKeySql(e),jsonPathRecursive:(a,e)=>`..${e.args.this||""}`,jsonPathRoot:(a,e)=>"$",jsonPathScript:(a,e)=>`(${e.args.this}`,jsonPathSelector:(a,e)=>`[${a.jsonPathPart(e.args.this)}]`,jsonPathSlice:(a,e)=>[e.args.start,e.args.end,e.args.step].filter(s=>s!==void 0).map(s=>s===void 0?"":a.jsonPathPart(s)).join(":"),jsonPathSubscript:(a,e)=>a.jsonPathSubscriptSql(e),jsonPathUnion:(a,e)=>`[${(e.args.expressions??[]).map(t=>a.jsonPathPart(t)).join(",")}]`,jsonPathWildcard:(a,e)=>"*"},bD=new Set([Vs,Mt,xr,zt,Hs,ci,Tr,ts,Sr,Dt]);function PD(a,e){let t=ae.getOrRaise(e?.dialect).jsonpathTokenizer(),s=t.tokenize(a),r=s.length,i=0;function o(){return i<r?s[i].tokenType:void 0}n(o,"curr");function c(){return s[i-1]}n(c,"prev");function p(){return i+=1,c()}n(p,"advance");function u(I){return`${I} at index ${i}: ${a}`}n(u,"error");function h(I,b={}){let{raiseUnmatched:k=!1}=b;if(o()===I)return p();if(k)throw new Ke(u(`Expected ${I}`))}n(h,"match");function g(I){let b=o();if(b!==void 0)return I.has(b)?p():void 0}n(g,"matchSet");function f(){let I=h("string")||h("identifier");if(I)return I.text;if(h("star"))return new Dt({});if(h("placeholder")||h("lParen")){let B=c().text==="(",j=i;for(;;){h("lBracket")&&T();let Pe=o();if(Pe==="rBracket"||Pe===void 0)break;p()}let Q=B?Hs:Vs,ne=s[j].start??0,H=i<r?s[i].end??a.length:a.length;return new Q({this:a.slice(ne,H)})}let b=h("dash")?"-":"",k=h("number");return k&&(b+=k.text),b?parseInt(b,10):!1}n(f,"parseLiteral");function x(){let I=f(),b=!!h("colon"),k=b?f():void 0,B=!!h("colon"),j=B?f():void 0;return!b&&!B?I:new Tr({start:I,end:k,step:j})}n(x,"parseSlice");function T(){let I=x();if(typeof I=="string"||I!==!1){let b=[I];for(;h("comma");){let B=x();B!==!1&&b.push(B)}let k;return b.length===1?typeof I=="string"?k=new Mt({this:b[0]}):I instanceof Hs||I instanceof Vs?k=new ci({this:b[0]}):k=new ts({this:b[0]}):k=new Sr({expressions:b}),h("rBracket",{raiseUnmatched:!0}),k}else throw new Ke(u("Cannot have empty segment"))}n(T,"parseBracket");function y(){let I=i-2;for(;g(t.constructor.VAR_TOKENS););let b=I<0?0:(s[I].end??0)+1,k;return s.length<=i?k=a.slice(b):k=a.slice(b,s[i].start??a.length),k}n(y,"parseVarText"),h("dollar");let C=[new zt({})];for(;o();)if(h("dot")||h("colon")){let I=c().text==="..",b;if(g(t.constructor.VAR_TOKENS)?b=y():h("identifier")?b=c().text:h("star")?b=new Dt({}):b=void 0,I)C.push(new xr({this:b}));else if(b)C.push(new Mt({this:b}));else throw new Ke(u("Expected key name or * after DOT"))}else if(h("lBracket"))C.push(T());else if(g(t.constructor.VAR_TOKENS))C.push(new Mt({this:y()}));else if(h("identifier"))C.push(new Mt({this:c().text}));else if(h("star"))C.push(new Dt({}));else throw new Ke(u(`Unexpected ${s[i].tokenType}`));return new Er({expressions:C})}n(PD,"parse");function TJ(a,e={}){let{dialect:t}=e,s=ae.getOrRaise(t);function r(i){return i=cj(i),i=pj(i,s),i=uj(i,{promoteToInferredDatetimeType:s._constructor.PROMOTE_TO_INFERRED_DATETIME_TYPE}),i=hj(i),i=MD(i,wD),i=gj(i),i}return n(r,"_canonicalize"),a.transform(r,{copy:!1})}n(TJ,"canonicalize");function cj(a){if(a instanceof we&&a.type instanceof d&&a.type.args.this&&m.TEXT_TYPES.has(a.type.args.this)){let e=a.args.this,t=a.args.expression;return!e||!t?a:new Bt({expressions:[e,t],coalesce:!1})}return a}n(cj,"addTextToConcat");function pj(a,e){if(a instanceof pi||a instanceof os){let t=a.args.expressions,s=a instanceof pi?a.args.zone:void 0,r=a.args.this;if(!(t&&Array.isArray(t)&&0<t.length)&&!s&&r){let o=r;if(o.isString&&EA(o.name))return new z({this:r,to:new m({this:"date"})})}}if(a instanceof Lh&&!a.args.zone){let r=a;a.type||(r=Kt(a,{dialect:e}));let i=r.args.this;if(!i)return a;let o=r.type||new m({this:"timestamp"});return o instanceof m?new z({this:i,to:o}):a}return a}n(pj,"replaceDateFuncs");var lj=O(()=>[we,ye,Me,ft,je,Je,Fe,nt,Ks,Ur]);function uj(a,e={}){let{promoteToInferredDatetimeType:t=!1}=e;if(lj().some(r=>a instanceof r)){let r=a.args.this,i=a.args.expression;r&&i&&qH(r,i,{promoteToInferredDatetimeType:t})}else if(a instanceof Ts){let r=a.args.this,i=a.args.low;r&&i&&qH(r,i,{promoteToInferredDatetimeType:t})}else if(a instanceof lr){let r=a.args.expression;if(r){let i=r;i.type instanceof d&&i.type.args.this&&m.TEMPORAL_TYPES.has(i.type.args.this)||LD(i,"datetime")}}else if(a instanceof xt||a instanceof jt||a instanceof ls){let r=a.args.this,i=a.args.unit;r&&UH(r,i)}else a instanceof _s&&Ej(a);return a}n(uj,"coerceType");function hj(a){if(a instanceof z){let e=a.args.this,t=a.args.to;if(e&&t){let s=e,r=t;if(s.type&&r.equals(s.type))return s}}if(a instanceof pi||a instanceof os){let e=a.args.this;if(e){let t=e;if(t.type instanceof d&&t.type.args.this==="date"){let s=t.type.args.expressions;if(!(s&&Array.isArray(s)&&0<s.length))return t}}}return a}n(hj,"removeRedundantCasts");function MD(a,e){if(a instanceof Ae){let t=a.args.this,s=a.args.expression;t&&e(t),s&&e(s)}else if(a instanceof Le){let t=a.args.this;t&&e(t)}else if(a instanceof fe){let t=a.parent;if(!(t instanceof ut&&t.args.this)){let r=a.args.this;r&&e(r)}}else if(a instanceof St||a instanceof ds){let t=a.args.this;t&&e(t)}return a}n(MD,"ensureBools");function gj(a){if(a instanceof hs){let e=a.args;e.desc===!1&&(e.desc=void 0)}return a}n(gj,"removeAscendingOrder");function qH(a,e,t){let{promoteToInferredDatetimeType:s}=t;for(let[r,i]of[[a,e],[e,a]]){if(i instanceof qe){let h=i.args.unit;UH(r,h)}let o=r.type;if(!o||!(o instanceof d)||!o.args.this||!m.TEMPORAL_TYPES.has(o.args.this))continue;let c=o,p=i.type;if(!p||!(p instanceof d)||!p.args.this||!m.TEXT_TYPES.has(p.args.this))continue;let u;if(s){let h;if(i.isString){let f=i.name;EA(f)?h="date":zI(f)?h="datetime":h=c.args.this}else h="datetime";let g=Yl.COERCES_TO.get(c.args.this);u=g&&g.has(h)?h:c.args.this}else u=c.args.this;u!==c.args.this&&LD(r,u),LD(i,u)}}n(qH,"coerceDate");function UH(a,e){if(!a.type)return a;if(a.type instanceof d&&a.type.args.this&&m.TEXT_TYPES.has(a.type.args.this)){let t=a.name,s=EA(t);if(s&&AA(e))return a.replace(new z({this:a.copy(),to:new m({this:"date"})}));if(s||zI(t))return a.replace(new z({this:a.copy(),to:new m({this:"datetime"})}))}else if(a.type instanceof d&&a.type.args.this==="date"&&!AA(e))return a.replace(new z({this:a.copy(),to:new m({this:"datetime"})}));return a}n(UH,"coerceTimeunitArg");function Ej(a){let e=a.args.this,t=a.args.expression;for(let s of[e,t])if(s){let r=s;r.type instanceof d&&r.type.args.this&&!m.TEMPORAL_TYPES.has(r.type.args.this)&&r.replace(new z({this:r.copy(),to:new m({this:"datetime"})}))}}n(Ej,"coerceDateDiffArgs");function LD(a,e){a.replace(new z({this:a.copy(),to:new m({this:e})}))}n(LD,"replaceCast");function wD(a){if(a instanceof tt){let e=a.args.this;e instanceof d&&wD(e);let t=a.args.expressions;if(t)for(let s of t)s instanceof d&&wD(s)}else a.type instanceof d&&a.type.args.this&&m.INTEGER_TYPES.has(a.type.args.this)&&a.replace(a.neq(0))}n(wD,"replaceIntPredicate");var Aj=["on","side","kind","using","method"];function IJ(a){for(let e of a.findAll(se)){let t=Et(e.args.joins??[],xe);if(!vH(t))continue;let s={},r=[];for(let i of t){let o=kD(i);if(0<o.size)for(let c of o)s[c]||(s[c]=[]),s[c].push(i);else r.push([i.aliasOrName,i])}for(let[i,o]of r)for(let c of s[i]??[]){let p=c.args.on;if(p instanceof Ae){if(kD(c).size<2)continue;let u=p.constructor;for(let h of p.flatten())if(wM(h).has(i)){h.replace(We());let g=VA([o.args.on,h],u,{copy:!1});o.on(g,{append:!1,copy:!1})}}}}return a=dj(a),a=fj(a),a}n(IJ,"optimizeJoins");function dj(a){for(let e of a.findAll(rt)){let t=e.parent;if(!t)continue;let s=Et(t.args.joins??[],xe);if(!vH(s))continue;let r=new Map;for(let u of s)r.set(u.aliasOrName,u);let i=new Map;for(let[u,h]of r)i.set(u,kD(h));let o=vY(i),c=e.aliasOrName,p=o.filter(u=>u!==c&&r.has(u)).map(u=>r.get(u));t.setArgKey("joins",p)}return a}n(dj,"reorderJoins");function fj(a){for(let e of a.findAll(xe)){let t=Aj.some(r=>e.args[r]!=null),s=e.args;t||(s.kind="cross"),s.kind==="cross"?s.on=void 0:((s.kind==="inner"||s.kind==="outer")&&(s.kind=void 0),!s.on&&!s.using&&(s.on=We()))}return a}n(fj,"normalize");function kD(a){let e=a.args.on;return e?wM(e,{exclude:a.aliasOrName}):new Set}n(kD,"otherTableNames");function vH(a){for(let e of a)if(e.args.side)return!1;return!0}n(vH,"isReorderable");function DJ(a,e){return function(t){let s=t,r=s.constructor;try{for(let c of a)s=c(s)}catch(c){if(c instanceof kr)this.unsupported(c.message);else throw c}if(e)return e.call(this,s);let i=this[`${s._constructor.key}Sql`];if(i instanceof Function)return i.call(this,s);let o=this._constructor.TRANSFORMS.get(s._constructor);if(o){if(r===s.constructor){if(s instanceof E)return this.functionFallbackSql(s);throw new Error(`Expression type ${s.constructor.name} requires a _sql method to be transformed.`)}return o.call(this,s)}throw new Error(`Unsupported expression type ${s.constructor.name}.`)}}n(DJ,"preprocess");function qJ(a){if(a instanceof se){let e=0,t=[];for(let s of a.findAll(Ee)){let r=s.parent;if(!(r instanceof rt||r instanceof xe)||s.args.expressions?.length!==1||!(s.args.expressions[0]instanceof ii))continue;let i=s.args.expressions[0],o=i.args.start,c=i.args.end,p=i.args.step;if(!o||!c||!(p instanceof qe))continue;let u=s.args.alias,h=u instanceof pe?u.columns[0]:void 0,g=Y(h,v)?h:Y(h,d)?h.name:"date_value",f=X(o,"date"),x=new Qe({this:"date_add",expressions:[g,N.number(p.name),p.args.unit||""]}),T=X(x,"date"),y=`_generated_dates${e?`_${e}`:""}`,C=Ye(new Re({this:f,alias:g})),I=Ye(T).from(y).where(new nt({this:T,expression:X(c,"date")})),b=C.union(I,{distinct:!1});s.replace(Ye(g).from(y).subquery(y)),t.push(Be(new Ft({this:b}),y,{table:[g]})),e++}if(0<t.length){let s=ct(a.args.with,dt)??new dt({expressions:[]});s.setArgKey("recursive",!0),s.setArgKey("expressions",[...t,...s.args.expressions??[]]),a.setArgKey("with",s)}}return a}n(qJ,"unnestGenerateDateArrayUsingRecursiveCte");function UJ(a){let e=a.args.this;if(a instanceof _&&e instanceof As){let t=new Ee({expressions:[e]});return a.args.alias?Be(t,"_u",{table:[a.args.alias instanceof pe?Y(a.args.alias.args.this,v)||typeof a.args.alias.args.this=="string"?a.args.alias.args.this:"":typeof a.args.alias=="string"?a.args.alias:""]}):t}return a}n(UJ,"unnestGenerateSeries");function vJ(a){if(a instanceof se&&a.args.distinct&&a.args.distinct.getArgKey("on")instanceof Ze){let e=En(a.namedSelects,"_row_number"),t=a.args.distinct.pop().getArgKey("on").args.expressions,s=new Ue({this:new yb({}),partitionBy:t}),r=a.args.order;r?s.setArgKey("order",r.pop()):s.setArgKey("order",new Ie({expressions:t?.map(c=>c instanceof d?c.copy():c)??[]})),a.select(Be(s,e),{copy:!1});let i=[],o=[e];for(let c of a.selects.slice(0,-1)){if(c.isStar){i=[new Ne];break}let p=c;if(!(p instanceof Re)){let u=En(o,p.outputName||"_col"),h=p instanceof $&&p.args.this instanceof d?!!p.args.this?.getArgKey("quoted"):void 0;p=p.replace(Be(p,u,{quoted:h}))}o.push(p.outputName),i.push(p.getArgKey("alias"))}return Ye(i).from(a.subquery("_t",{copy:!1})).where(new $({this:e}).eq(1))}return a}n(vJ,"eliminateDistinctOn");function FJ(a){if(a instanceof se&&a.args.qualify){let e=new Set(a.namedSelects);for(let c of a.selects)if(!c.aliasOrName){let p=En(e,"_c");c.replace(Be(c,p)),e.add(p)}let t=n(c=>{let p=c.aliasOrName,u=c.getArgKey("alias")||c.args.this;return u instanceof v?$n({col:p},{quoted:u.args.quoted}):p},"selectAliasOrName"),s=Ye(a.selects.map(t)),r=ct(a.args.qualify.pop().args.this,d),i={};for(let c of a.selects)c instanceof Re&&(i[c.alias]=c.args.this);let o=a.isStar?[Ue]:[Ue,$];for(let c of[...r?.findAll(o)??[]])if(c instanceof Ue){if(i)for(let h of c.findAll($)){let g=i[h.name];g&&h.replace(g)}let p=En(a.namedSelects,"_w");a.select(Be(c,p),{copy:!1});let u=$n({col:p});c.parent instanceof Xs?r=u:c.replace(u)}else a.namedSelects.includes(c.name)||a.select(c.copy(),{copy:!1});return s.from(a.subquery("_t",{copy:!1}),{copy:!1}).where(r,{copy:!1})}return a}n(FJ,"eliminateQualify");function BJ(a){for(let e of a.findAll(m))e.setArgKey("expressions",e.args.expressions?.filter(t=>!(t instanceof Jr)));return a}n(BJ,"removePrecisionParameterizedTypes");function $J(a){if(a instanceof se){let e=new Set(Dr(a,[Ee]).filter(t=>t.parent instanceof rt||t.parent instanceof xe).map(t=>t.alias));if(0<e.size)for(let t of a.findAll($)){let s=t.parts[0];s&&s.argKey!=="this"&&s.args&&e.has(s.args.this)&&s.pop()}}return a}n($J,"unqualifyUnnest");function GJ(a,e={}){let{unnestUsingArraysZip:t=!0}=e;function s(i,o,c){let{hasMultiExpr:p}=c;if(p){if(!t)throw new kr("Cannot transpile UNNEST with multiple input arrays");let u=[new Qe({this:"ARRAYS_ZIP",expressions:o})];return i.setArgKey("expressions",u),u}return o}n(s,"unnestZipExprs");function r(i,o={}){let{hasMultiExpr:c}=o;return i.args.offset?li:c?Ib:Xt}if(n(r,"getUdtfType"),a instanceof se){let i=a.args.from;if(i&&i.args.this instanceof Ee){let c=i.args.this,p=c.args.alias,u=c.args.expressions,h=1<(u?.length??0),[g]=s(c,u??[],{hasMultiExpr:h}),f=Y(p,pe)?Et(p.columns,v):[],x=c.args.offset;x&&f.unshift(x instanceof v?x:new v({this:"pos",quoted:!1}));let T=r(c,{hasMultiExpr:h});c.replace(new _({this:new T({this:g}),alias:Y(p,pe)?new pe({this:Y(p.args.this,d)||typeof p.args.this=="string"?p.args.this:void 0,columns:f}):void 0}))}let o=a.args.joins||[];for(let c of[...o]){let p=c.args.this,u=p instanceof Ct,h=u?p.args.this:p;if(h instanceof Ee){let g=u?p.args.alias:h.args.alias,f=h.args.expressions,x=1<(f?.length??0),T=s(h,f??[],{hasMultiExpr:x});o.splice(o.indexOf(c),1);let y=Y(g,pe)?g:void 0,C=y?Et(y.columns,v):[];if(!x&&C.length!==1&&C.length!==2)throw new kr("CROSS JOIN UNNEST to LATERAL VIEW EXPLODE transformation requires explicit column aliases");let I=h.args.offset;I&&C.unshift(I instanceof v?I:new v({this:"pos",quoted:!1}));let b=r(h,{hasMultiExpr:x});for(let k of T)a.append("laterals",new Ct({this:new b({this:k}),view:!0,alias:new pe({this:y&&(Y(y.args.this,d)||typeof y.args.this=="string")?y.args.this:void 0,columns:C})}))}}}return a}n(GJ,"unnestToExplode");function FH(a){let e=a.getArgKey("with");for(let t of a.findAll(dt))if(t.parent!==a)if(!e)e=t.pop(),a.setArgKey("with",e);else{t.recursive&&e.setArgKey("recursive",!0);let s=t.findAncestor(Ft);t.pop();let r=t.args.expressions;if(re(e,dt),s){let i=e.args.expressions?.indexOf(s)??-1;e.args.expressions?.splice(i,0,...Et(r??[],d))}else e.setArgKey("expressions",[...e.args.expressions??[],...Et(r??[],d)])}return a}n(FH,"moveCtesToTopLevel");function YJ(a){if(a instanceof se)for(let e of a.findAll(Tt)){let t=e.args.this;if(t instanceof ee||e.parent instanceof Qt||e.parent instanceof Gs)continue;let s=e.parent;if(s instanceof U){let r=new v({this:"x",quoted:!1});e.replace(r);let i=new ps({this:s.copy(),expressions:[r]});s.replace(new Ys({this:t?.unnest(),expression:i}))}}return a}n(YJ,"anyToExists");function VJ(a=0){return e=>{if(e instanceof se){let t=[...e.namedSelects],r=[...new js({expression:e}).references].map(([h])=>h),i=n((h,g)=>{let f=En(h,g);return h.push(f),f},"newName"),o=[],c=i(t,"pos"),p=i(r,"_u"),u=Be(new Ee({expressions:[new As({start:N.number(a)})]}),p,{table:[c]});for(let h of[...e.selects]){let g=h.find(Xt);if(g){let f,x,T;if(h instanceof Re){let H=h.getArgKey("alias");x=H instanceof v?H:h.alias,T=h}else if(h instanceof Hn)f=h.aliases[0],x=h.aliases[1],T=h.replace(new Re({this:h.args.this,alias:""}));else{let H=new Re({alias:""});h.replace(H),H.setArgKey("this",h),T=H;let Pe=T.find(Xt);Pe&&(g=Pe)}let y=g instanceof li,C=g.args.this;if(g instanceof _A&&C instanceof d){let H=new Lt({this:C,expressions:[N.number(0)]});H.setArgKey("safe",!0),H.setArgKey("offset",1),C=HA("IF",HA("ARRAY_SIZE",new tt({expressions:[C,new ue({expressions:[]})]})).eq(N.number(0)),new ue({expressions:[H.copy()]}),C)}C instanceof $&&t.push(C.outputName);let I=i(r,"_u");x||(x=i(t,"col")),y&&!f&&(f=i(t,"pos")),f||(f=i(t,"pos")),T.setArgKey("alias",K(x instanceof v?x:x??""));let b=u.args.alias?.args.this,k=K(I),B=n((H,Pe)=>new $({this:Y(H,v)?H.copy():K(H??""),table:typeof Pe=="string"?K(Pe):Pe?.copy()}),"mkCol"),j=new fe({this:B(c,b).eq(B(f,k)),true:B(x,k)});if(g.replace(j),y){let H=e.args.expressions,Pe=H?.indexOf(T)??-1;H?.splice(Pe+1,0,Be(new fe({this:B(c,b).eq(B(f,k)),true:B(f,k)}),Y(f,v)||typeof f=="string"?f:void 0)),e.setArgKey("expressions",H)}o.length===0&&(e.args.from?e.join(u,{joinType:"cross",copy:!1}):e.from(u,{copy:!1}));let Q=new Rr({this:C instanceof d?C.copy():C});o.push(Q),e.join(Be(new Ee({expressions:C!==void 0?[C instanceof d?C.copy():C]:void 0,offset:new v({this:f,quoted:!1})}),I,{table:[Y(x,v)||typeof x=="string"?x:""]}),{joinType:"cross",copy:!1});let ne=Q;a!==1&&(ne=new Se({this:new ye({this:Q,expression:N.number(1)})})),e.where(B(c,b).eq(B(f,k)).or(new Te({this:new je({this:B(c,b),expression:ne}),expression:new Me({this:B(f,k),expression:ne.copy()})})),{copy:!1})}}if(0<o.length){let h=new ni({this:o[0],expressions:o.slice(1),ignoreNulls:!1});a!==1&&(h=new ye({this:h,expression:N.number(1-a)})),ct(u.args.expressions?.[0],d)?.setArgKey("end",h)}}return e}}n(VJ,"explodeProjectionToUnnest");function HJ(a){if(MM.some(e=>a instanceof e)&&!(a.parent instanceof ns)&&a.args.expression){let e=a,t=e.args.this?.pop();e.setArgKey("this",e.args.expression?.pop());let s=new Ie({expressions:[new hs({this:t,nullsFirst:!1})]});return new ns({this:e,expression:s})}return a}n(HJ,"addWithinGroupForPercentiles");function _J(a){if(a instanceof ns&&MM.some(e=>a.args.this instanceof e)&&a.args.expression instanceof Ie){let e=ct(a.args.this,d)?.args.this,t=a.find(hs),s=t?t.args.this:void 0;return a.replace(new wh({this:s,quantile:e}))}return a}n(_J,"removeWithinGroupForPercentiles");function WJ(a){if(a instanceof dt&&a.recursive){let e=CM("_c_");for(let t of a.args.expressions??[]){re(t,Ft);let s=Y(t.args.alias,pe)?t.args.alias:void 0;if(!s?.columns.length){let r=t.args.this;r instanceof Ge&&(r=r.args.this),re(r,ee),s?.setArgKey("columns",r.selects.map(i=>K(i.aliasOrName||e())))}}}return a}n(WJ,"addRecursiveCteColumnNames");function jJ(a){return(a instanceof z||a instanceof $t)&&a.name.toLowerCase()==="epoch"&&m.TEMPORAL_TYPES.has(st(At,(a.args.to instanceof d?a.args.to.args.this?.toString():a.args.to?.toString())??"")??"")&&ct(a.args.this,d)?.replace(N.string("1970-01-01 00:00:00")),a}n(jJ,"epochCastToTs");function XJ(a){if(a instanceof se){let e=a.args.joins||[];for(let t of[...e]){re(t,xe);let s=t.args.on;if(s&&(t.args.kind==="semi"||t.args.kind==="anti")){let r=Ye("1").from(t.args.this).where(s),i=new Ys({this:r});t.args.kind==="anti"&&(i=i.not()),t.pop(),a.where(i,{copy:!1})}}}return a}n(XJ,"eliminateSemiAndAntiJoins");function JJ(a){if(a instanceof se){let e=a.args.joins||[],s=Et(e,xe).map((r,i)=>({index:i,join:r})).filter(({join:r})=>r.args.side==="full");if(s.length===1){let r=a.copy();a.setArgKey("limit",void 0);let{index:i,join:o}=s[0],c=a.args.from?.aliasOrName,p=o.aliasOrName,u=o.args.on||new Te({expressions:(o.args.using||[]).map(T=>new Me({this:new $({this:T,table:c}),expression:new $({this:T,table:p})}))});o.setArgKey("side","left");let h=Ye("1").from(a.args.from).where(u);r.args.joins?.[i]?.setArgKey("side","right");let f=new Ys({this:h}).not();return r.where(f,{copy:!1}).setArgKey("with",void 0),a.setArgKey("order",void 0),WA([a,r],{distinct:!1})??a}}return a}n(JJ,"eliminateFullOuterJoin");function BH(a){let e=n(t=>{(t.isNumber||!(t instanceof Us)&&t.isType(["unknown",...m.NUMERIC_TYPES])||t instanceof $&&!t.type)&&t.replace(t.neq(0))},"_ensureBool");for(let t of a.walk())MD(t,e);return a}n(BH,"ensureBools");function zJ(a){for(let e of a.findAll($)){let t=e.parts;for(let s=0;s<t.length-1;s++)t[s].pop()}return a}n(zJ,"unqualifyColumns");function QJ(a){if(!(a instanceof ss))return a;for(let e of a.findAll(Mu))e.parent&&e.parent.pop();return a}n(QJ,"removeUniqueConstraints");function ZJ(a,e=t=>t){if(!(a instanceof ss))return a;let s=a.args.properties?.args.expressions?.some(r=>r instanceof $s);return a.kind==="table"&&s?a.args.expression?new ss({kind:"temporary view",this:a.args.this,expression:a.args.expression}):e(a):a}n(ZJ,"ctasWithTmpTablesToCreateTmpView");function KJ(a){if(!(a instanceof ss))return a;let e=a.args.this instanceof Rt,t=a.kind==="table"||a.kind==="view";if(e&&t){let s=a.find(ys);if(s&&s.args.this&&!(s.args.this instanceof Rt)){let r=a.args.this;re(r,Rt);let i=new Set(s.args.this.args.expressions?.map(c=>c instanceof d?c.name.toUpperCase():c.toString())),o=r.args.expressions?.filter(c=>i.has(c.name.toUpperCase()));r.setArgKey("expressions",r.args.expressions?.filter(c=>!o?.includes(c))),s.replace(new ys({this:new Rt({expressions:Et(o??[],d)})})),a.setArgKey("this",r)}}return a}n(KJ,"moveSchemaColumnsToPartitionedBy");function ez(a){if(!(a instanceof ss))return a;let e=a.find(ys);if(e&&e.args.this instanceof Rt&&e.args.this.args.expressions?.every(t=>t instanceof be&&t.kind)){let t=new Ze({expressions:e.args.this.args.expressions.map(r=>{let i=r.args.this;return i instanceof d?K(Y(i,v)?i:i.name):K(i?.toString()??"")})}),s=a.args.this;for(let r of e.args.this.args.expressions)s.append("expressions",r);e.setArgKey("this",t)}return a}n(ez,"movePartitionedByToSchemaColumns");function tz(a){if(a instanceof se&&a.args.windows){let e=a.args.windows;a.setArgKey("windows",void 0);let t={},s=n(r=>{let i=r.alias?.toLowerCase();if(i===void 0)return;let o=t[i];if(o){r.setArgKey("alias",void 0);for(let c of["partitionBy","order","spec"]){let p=o.getArgKey(c);p instanceof d&&r.setArgKey(c,p.copy()),Array.isArray(p)&&0<p.length&&r.setArgKey(c,[...p])}}},"inlineInheritedWindow");for(let r of e)s(r),t[r.name.toLowerCase()]=r;for(let r of Dr(a,[Ue]))s(r)}return a}n(tz,"eliminateWindowClause");function sz(a){if(a instanceof ue&&a.args.structNameInheritance&&a.args.expressions?.[0]instanceof Es){let e=a.args.expressions[0];if(!e.args.expressions?.every(s=>s instanceof ot))return a;let t=e.args.expressions.map(s=>s.args.this);for(let s of a.args.expressions.slice(1)){if(!(s instanceof Es)||s.args.expressions?.length!==t.length)continue;let r=s.args.expressions.map((i,o)=>{if(!(i instanceof ot)){let c=t[o],p=c instanceof d?c.args.this:c,u=new ot({this:new v({this:p instanceof d?p.copy():p?.toString()||"",quoted:!1}),expression:i});return u.type=i.type,u}return i});s.setArgKey("expressions",r)}}return a}n(sz,"inheritStructFieldNames");var xj=/\\(\d+)/g;function Cb(a,...e){let t=a._constructor.name,s=this.dialect._constructor.name;for(let r of e){let[i,o]=typeof r=="string"?[r,void 0]:r;a.getArgKey(i)&&this.unsupported(o??`Argument '${i}' is not supported for expression '${t}' when targeting ${s}.`)}}n(Cb,"unsupportedArgs");var $H,GH,YH,VH,HH,_H,WH,jH,XH,JH,zH,QH,rs;QH=[O,O],zH=[O],JH=[O],XH=[O],jH=[O],WH=[O],_H=[O],HH=[O],VH=[O],YH=[O],GH=[O],$H=[O];var L=class L{constructor(e={}){this.pretty=void 0;this.identify=void 0;this.normalize=void 0;this.pad=void 0;this.indentAmount=void 0;this.normalizeFunctions=void 0;this.unsupportedLevel=void 0;this.maxUnsupported=void 0;this.leadingComma=void 0;this.maxTextWidth=void 0;this.comments=void 0;this.dialect=void 0;this.unsupportedMessages=void 0;this.escapedQuoteEnd=void 0;this.nextName=void 0;this.escapedByteQuoteEnd=void 0;this.escapedIdentifierEnd=void 0;this.identifierStart=void 0;this.identifierEnd=void 0;this.quoteJsonPathKeyUsingBrackets=void 0;this.pretty=e.pretty??!1,this.identify=e.identify??!1,this.normalize=e.normalize??!1,this.pad=e.pad??2,this.indentAmount=e.indent??2,this.unsupportedLevel=e.unsupportedLevel??1,this.maxUnsupported=e.maxUnsupported??3,this.leadingComma=e.leadingComma??!1,this.maxTextWidth=e.maxTextWidth??80,this.comments=e.comments??!0,this.dialect=ae.getOrRaise(e.dialect);let t=this.dialect._constructor;this.normalizeFunctions=e.normalizeFunctions??t.NORMALIZE_FUNCTIONS??"upper";let s=t.tokenizerClass.STRING_ESCAPES,r=s&&0<s.length?s[0]:"";this.escapedQuoteEnd=r+this.dialect._constructor.QUOTE_END,this.escapedByteQuoteEnd=this.dialect._constructor.BYTE_END?r+this.dialect._constructor.BYTE_END:"",this.escapedIdentifierEnd=this.dialect._constructor.IDENTIFIER_END+this.dialect._constructor.IDENTIFIER_END,this.identifierStart=this.dialect._constructor.IDENTIFIER_START,this.identifierEnd=this.dialect._constructor.IDENTIFIER_END,this.unsupportedMessages=[],this.nextName=CM("_t"),this.quoteJsonPathKeyUsingBrackets=!0}static get NULL_ORDERING_SUPPORTED(){return"supported"}static get SUPPORTED_JSON_PATH_PARTS(){return new Set([...bD])}static get UNWRAPPED_INTERVAL_VALUES(){return new Set([$,N,bt,Se])}static get WITH_SEPARATED_COMMENTS(){return new Set([$r,ss,Ql,Gr,tu,rt,es,xe,nu,Ie,Yr,ds,se,Ge,us,St,dt])}static get EXCLUDE_COMMENTS(){return new Set([U,Ge])}static get TYPE_MAPPING(){return new Map([["datetime2","TIMESTAMP"],["nchar","CHAR"],["nvarchar","VARCHAR"],["mediumtext","TEXT"],["longtext","TEXT"],["tinytext","TEXT"],["blob","VARBINARY"],["mediumblob","BLOB"],["longblob","BLOB"],["tinyblob","BLOB"],["inet","INET"],["rowversion","VARBINARY"],["smalldatetime","TIMESTAMP"]])}static get UNSUPPORTED_TYPES(){return new Set}static get PARAMETERIZABLE_TEXT_TYPES(){return new Set(["nvarchar","varchar","char","nchar"])}static get TOKEN_MAPPING(){return{}}static get ORIGINAL_TRANSFORMS(){return new Map([[ph,function(e){return this.binary(e,"-|-")}],[Vn,function(e){return`ALLOWED_VALUES ${this.expressions(e,{flat:!0})}`}],[hu,function(e){return this.sql(e,"this")}],[uu,function(e){return this.expressions(e,{prefix:"WITH ",sep:" "})}],[Fn,function(e){return this.binary(e,"@>")}],[Fb,function(e){return this.binary(e,"&&")}],[Mb,function(e){return`ASSUME (${this.sql(e,"this")})`}],[Xn,function(e){return`AUTO REFRESH ${this.sql(e,"this")}`}],[Jn,function(e){return`BACKUP ${this.sql(e,"this")}`}],[kn,e=>`${e.getArgKey("not")?"NOT ":""}CASESPECIFIC`],[ti,function(e){return this.ceilFloor(e)}],[xu,function(e){return`CHARACTER SET ${this.sql(e,"this")}`}],[zr,function(e){return`${e.getArgKey("default")?"DEFAULT ":""}CHARACTER SET=${this.sql(e,"this")}`}],[Tu,function(e){return`CLUSTERED (${this.expressions(e,{key:"this",indent:!1})})`}],[Su,function(e){return`COLLATE ${this.sql(e,"this")}`}],[Ru,function(e){return`COMMENT ${this.sql(e,"this")}`}],[Eh,function(e){return`CONNECT_BY_ROOT ${this.sql(e,"this")}`}],[vb,function(e){return this.func("CONVERT",[e.args.this,e.args.dest,e.args.source])}],[Qn,()=>"COPY GRANTS"],[pd,function(e){return`CREDENTIALS=(${this.expressions(e,{key:"expressions",sep:" "})})`}],[Mh,()=>"CURRENT_CATALOG"],[kh,()=>"SESSION_USER"],[Ou,function(e){return`FORMAT ${this.sql(e,"this")}`}],[mu,function(e){return`DEFAULT ${this.sql(e,"this")}`}],[JA,()=>"API"],[zA,()=>"APPLICATION"],[QA,()=>"CATALOG"],[ZA,()=>"COMPUTE"],[KA,()=>"DATABASE"],[Aa,()=>"DYNAMIC"],[da,()=>"EMPTY"],[du,()=>"END"],[Nu,function(e){return`ENCODE ${this.sql(e,"this")}`}],[ga,function(e){return`ENVIRONMENT (${this.expressions(e,{flat:!0})})`}],[ra,function(e){return`HANDLER ${this.sql(e,"this")}`}],[ia,function(e){return`PARAMETER STYLE ${this.sql(e,"this")}`}],[yu,function(e){return`EPHEMERAL${e.args.this?" "+this.sql(e,"this"):""}`}],[Iu,function(e){return`EXCLUDE ${this.sql(e,"this").trimStart()}`}],[nr,function(e){return this.nakedProperty(e)}],[cr,function(e){return this.setOperations(e)}],[oa,()=>"EXTERNAL"],[xh,function(e){return this.ceilFloor(e)}],[bb,function(e){return this.getPutSql(e)}],[ca,()=>"GLOBAL"],[na,()=>"HEAP"],[ed,()=>"HYBRID"],[pa,()=>"ICEBERG"],[la,function(e){return`INHERITS (${this.expressions(e,{flat:!0})})`}],[Cu,function(e){return`INLINE LENGTH ${this.sql(e,"this")}`}],[ua,function(e){return`INPUT${this.sql(e,"this")}`}],[ei,function(e){return this.setOperations(e)}],[Wr,function(e){return`${this.sql(e,"this")} TO ${this.sql(e,"expression")}`}],[Uh,function(e){return this.sql(X(e.args.this||"","bigint"))}],[Rh,function(e){return this.binary(e,"?|")}],[Oh,function(e){return this.binary(e,"?&")}],[mh,function(e){return this.binary(e,"#-")}],[Vs,function(e){return`?${e.args.this}`}],[xr,function(e){return`..${e.args.this||""}`}],[zt,()=>"$"],[Hs,function(e){return`(${e.args.this}`}],[ci,function(e){return`[${this.jsonPathPart(e.args.this)}]`}],[Tr,function(e){return[e.args.start,e.args.end,e.args.step].filter(t=>t!==void 0).map(t=>t===!1?"":this.jsonPathPart(t)).join(":")}],[Sr,function(e){return`[${(e.args.expressions??[]).map(s=>this.jsonPathPart(s)).join(",")}]`}],[Dt,()=>"*"],[Qr,function(e){return this.nakedProperty(e)}],[Zr,function(e){return this.nakedProperty(e)}],[fa,e=>`${e.getArgKey("no")?"NO ":""}LOG`],[td,()=>"MASKING"],[xa,()=>"MATERIALIZED"],[sd,()=>"NETWORK"],[Yb,function(e){return`NET.${this.sql(e,"this")}`}],[bu,function(e){return`NONCLUSTERED (${this.expressions(e,{key:"this",indent:!1})})`}],[Ta,()=>"NO PRIMARY INDEX"],[Pu,()=>"NOT FOR REPLICATION"],[Hr,e=>`ON COMMIT ${e.getArgKey("delete")?"DELETE":"PRESERVE"} ROWS`],[Vr,function(e){return`ON ${this.sql(e,"this")}`}],[Lu,function(e){return`ON UPDATE ${this.sql(e,"this")}`}],[ch,function(e){return this.binary(e,"")}],[ha,function(e){return`OUTPUT${this.sql(e,"this")}`}],[nh,function(e){return this.binary(e,"&<")}],[ah,function(e){return this.binary(e,"&>")}],[Du,function(e){return`PATH ${this.sql(e,"this")}`}],[Xu,function(e){return this.func("BUCKET",[e.args.this,e.args.expression])}],[Ju,function(e){return this.func("TRUNCATE",[e.args.this,e.args.expression])}],[wn,function(e){return`ANY${this.sql(e,"this")}`}],[Pb,function(e){return`#${this.sql(e,"this")}`}],[kb,function(e){return`PROJECTION POLICY ${this.sql(e,"this")}`}],[wb,()=>"ZEROFILL"],[jA,function(e){return this.getPutSql(e)}],[Ra,function(e){return`REMOTE WITH CONNECTION ${this.sql(e,"this")}`}],[Kr,function(e){return e.getArgKey("null")?"RETURNS NULL ON NULL INPUT":this.nakedProperty(e)}],[Ub,function(e){return`SAFE.${this.sql(e,"this")}`}],[Na,function(e){return`SAMPLE BY ${this.sql(e,"this")}`}],[rd,()=>"ROW ACCESS"],[La,()=>"SECURE"],[id,()=>"SECURITY"],[XA,function(e){return this.sql(e,"this")}],[_r,e=>`${e.getArgKey("multi")?"MULTI":""}SET`],[Ca,function(e){return`SETTINGS${this.seg("")}${this.expressions(e)}`}],[ya,function(e){return`SHARING=${this.sql(e,"this")}`}],[vs,e=>e.name],[Pa,function(e){return`SQL SECURITY ${this.sql(e,"this")}`}],[Fs,e=>e.name],[Eu,function(e){return`STREAM ${this.sql(e,"this")}`}],[Sa,()=>"STREAMING"],[Oa,()=>"STRICT"],[Kl,function(e){return`SWAP WITH ${this.sql(e,"this")}`}],[Gl,function(e){return this.sql(e.args.this)}],[nd,function(e){return`TAG (${this.expressions(e,{flat:!0})})`}],[$s,()=>"TEMPORARY"],[wu,function(e){return`TITLE ${this.sql(e,"this")}`}],[vh,function(e){return`MAP ${this.sql(e,"this")}`}],[aa,function(e){return`TO ${this.sql(e.args.this)}`}],[wa,function(e){return this.func("TRANSFORM",e.args.expressions||[])}],[Ma,()=>"TRANSIENT"],[or,function(e){return this.setOperations(e)}],[ka,()=>"UNLOGGED"],[ad,function(e){return`USING TEMPLATE ${this.sql(e,"this")}`}],[gu,function(e){return`USING DATA ${this.sql(e,"this")}`}],[ku,()=>"UPPERCASE"],[Bb,function(e){return this.sql(new pr({this:N.string("UTC")}))}],[$b,function(e){return this.sql(new si({this:N.string("UTC")}))}],[Gb,function(e){return this.sql(new ri({this:N.string("UTC")}))}],[Lb,function(e){return`VARIADIC ${this.sql(e,"this")}`}],[Ss,function(e){return this.func("MAP",[e.args.keys,e.args.values])}],[Da,function(e){return`WITH ${this.sql(e,"this")}`}],[qa,()=>"VOLATILE"],[Ua,function(e){return`WITH JOURNAL TABLE=${this.sql(e,"this")}`}],[Fa,function(e){return`WITH ${this.expressions(e,{flat:!0})}`}],[va,function(e){return`WITH SCHEMA ${this.sql(e,"this")}`}],[eu,function(e){return`${this.sql(e,"this")} WITH ${this.sql(e,"op")}`}],[od,()=>"FORCE"]])}static get TRANSFORMS(){let e=new Map(this.ORIGINAL_TRANSFORMS);for(let t of Array.from(bD).filter(s=>!this.SUPPORTED_JSON_PATH_PARTS.has(s)))e.delete(t);return e}static get PROPERTIES_LOCATION(){return new Map([[Vn,"postSchema"],[Wn,"postCreate"],[JA,"postCreate"],[zA,"postCreate"],[jn,"postSchema"],[Xn,"postSchema"],[Jn,"postSchema"],[qu,"postName"],[QA,"postCreate"],[zr,"postSchema"],[Uu,"postName"],[zn,"postSchema"],[ZA,"postCreate"],[Qn,"postSchema"],[rr,"postSchema"],[Ea,"postSchema"],[ea,"postSchema"],[Bu,"postSchema"],[vu,"postName"],[KA,"postCreate"],[Fu,"postSchema"],[Zn,"postCreate"],[_u,"postSchema"],[Hu,"postSchema"],[Aa,"postCreate"],[Kn,"postSchema"],[ta,"postSchema"],[da,"postSchema"],[ud,"postExpression"],[sa,"postSchema"],[ga,"postSchema"],[ra,"postSchema"],[ia,"postSchema"],[nr,"postSchema"],[oa,"postCreate"],[$u,"postName"],[ir,"postWith"],[Gu,"postName"],[ca,"postCreate"],[na,"postWith"],[ed,"postCreate"],[la,"postSchema"],[pa,"postCreate"],[hd,"postSchema"],[ua,"postSchema"],[Yu,"postName"],[Vu,"postName"],[Qr,"postSchema"],[Wu,"postSchema"],[Zr,"postSchema"],[ld,"postSchema"],[ju,"postAlias"],[fa,"postName"],[td,"postCreate"],[xa,"postCreate"],[qn,"postName"],[sd,"postCreate"],[Ta,"postExpression"],[Vr,"postSchema"],[Hr,"postExpression"],[Ie,"postSchema"],[ha,"postSchema"],[ys,"postWith"],[zu,"postSchema"],[ru,"postSchema"],[w,"postWith"],[qb,"postSchema"],[Ra,"postSchema"],[Kr,"postSchema"],[Db,"unsupported"],[ma,"postSchema"],[Qu,"postSchema"],[Zu,"postSchema"],[rd,"postCreate"],[Na,"postSchema"],[Ia,"postSchema"],[La,"postCreate"],[id,"postCreate"],[Ku,"postSchema"],[Zl,"postSchema"],[Ca,"postSchema"],[_r,"postCreate"],[XA,"postSchema"],[ya,"postExpression"],[Br,"postExpression"],[Gn,"postExpression"],[ba,"postSchema"],[vs,"postSchema"],[Pa,"postSchema"],[Fs,"postSchema"],[eh,"postSchema"],[Sa,"postCreate"],[Oa,"postSchema"],[nd,"postWith"],[$s,"postCreate"],[aa,"postSchema"],[Ma,"postCreate"],[wa,"postSchema"],[Pn,"postSchema"],[ka,"postCreate"],[ad,"postSchema"],[Da,"postSchema"],[qa,"postCreate"],[th,"postExpression"],[Ua,"postName"],[Fa,"postSchema"],[va,"postSchema"],[sh,"postSchema"],[od,"postCreate"]])}get _constructor(){return this.constructor}generate(e,t={}){let{copy:s=!0}=t,r=s?e.copy():e;r=this.preprocess(r),this.unsupportedMessages=[];let i=this.sql(r).trim();if(this.pretty&&(i=i.replaceAll(this._constructor.SENTINEL_LINE_BREAK,`
|
|
3
|
+
`)}n(gM,"concatMessages");function Wk(a){return a.flatMap(e=>e.errors)}n(Wk,"mergeErrors");function EM(a,e){return typeof e=="string"?typeof a===e||e==="object"&&a===null:a instanceof e}n(EM,"checkOne");function K_(a){return typeof a=="string"?`typeof === '${a}'`:a.name??String(a)}n(K_,"checkerName");function Y(a,...e){return e.some(t=>EM(a,t))}n(Y,"isInstanceOf");function re(a,...e){if(!e.some(t=>EM(a,t))){let t=e.map(K_).join(" | ");throw new TypeError(`Expected ${t}, got ${typeof a}`)}}n(re,"assertIsInstanceOf");function ct(a,...e){return e.some(t=>EM(a,t))?a:void 0}n(ct,"narrowInstanceOf");function Et(a,...e){let t=[];for(let s of a)e.some(r=>EM(s,r))&&t.push(s);return t}n(Et,"filterInstanceOf");function O(a,e){if(e){let r=new WeakMap;return e.addInitializer(function(){Object.defineProperty(this,e.name,{get(){return r.has(this)||r.set(this,a.call(this)),r.get(this)},set(i){r.set(this,i)},configurable:!0})}),a}let t,s=!1;return()=>(s||(t=a(),s=!0),t)}n(O,"cache");var Kk=new WeakMap;function eW(a){let e=[],t=a;for(;t&&t!==Object&&t.prototype;)e.push(t),t=Object.getPrototypeOf(t);return e}n(eW,"getPrototypeChain");function V(a,...e){let o=class o extends a{};n(o,"MultiInheritClass");let t=o,s=[a,...e],r=[],i=new Set;for(let c of s){let p=eW(c);for(let u of p)i.has(u)||(i.add(u),r.push(u))}for(let c of r){for(let u of Object.getOwnPropertyNames(c.prototype))if(u!=="constructor"&&!Object.getOwnPropertyDescriptor(t.prototype,u)){let h=Object.getOwnPropertyDescriptor(c.prototype,u);h&&Object.defineProperty(t.prototype,u,h)}for(let u of Object.getOwnPropertyNames(c))if(!["prototype","length","name"].includes(u)&&!Object.getOwnPropertyDescriptor(t,u)){let h=Object.getOwnPropertyDescriptor(c,u);h&&Object.defineProperty(t,u,h)}let p=Kk.get(c);p||(p=new Set,Kk.set(c,p),Object.defineProperty(c,Symbol.hasInstance,{value(u){if(this.prototype.isPrototypeOf(Object(u)))return!0;let h=Kk.get(this);if(!h)return!1;let g=u?.constructor;for(;g&&g!==Object;){if(h.has(g))return!0;g=Object.getPrototypeOf(g)}return!1},configurable:!0})),p.add(t)}return t}n(V,"multiInherit");var eD=class eD{constructor(){this._map=new Map}get(e,t){return this._map.get(e)?.get(t)}set(e,t,s){let r=this._map.get(e);return r||(r=new Map,this._map.set(e,r)),r.set(t,s),this}has(e,t){return this._map.get(e)?.has(t)??!1}delete(e,t){let s=this._map.get(e);if(!s)return!1;let r=s.delete(t);return s.size===0&&this._map.delete(e),r}clear(){this._map.clear()}get size(){let e=0;for(let t of this._map.values())e+=t.size;return e}*[Symbol.iterator](){for(let[e,t]of this._map)for(let[s,r]of t)yield[[e,s],r]}*keys(){for(let[e,t]of this._map)for(let s of t.keys())yield[e,s]}*values(){for(let e of this._map.values())yield*e.values()}*entries(){yield*this}};n(eD,"MapBinaryTuple");var KE=eD;function st(a,e){let t=Object.values(a),s=e?.toLowerCase();return t.find(r=>r===s)??t.find(r=>r.toLowerCase()===s)}n(st,"enumFromString");function GI(a){return a!=null&&typeof a[Symbol.iterator]=="function"}n(GI,"isIterable");var tW=0n,oG=new WeakMap,cG=new Map;function pG(){return(tW++).toString()}n(pG,"nextId");function sW(a){if(a!==null&&typeof a=="object"||typeof a=="function"){let t=a,s=oG.get(t);return s===void 0&&(s=pG(),oG.set(t,s)),s}let e=cG.get(a);return e===void 0&&(e=pG(),cG.set(a,e)),e}n(sW,"id");function rW(a){return a!==null&&typeof a=="object"&&typeof a.add=="function"}n(rW,"isAddableObj");function iW(a){return a!==null&&typeof a=="object"&&typeof a.radd=="function"}n(iW,"isRaddableObj");function pX(a,e){return rW(a)?a.add(e):iW(e)?e.radd(a):Array.isArray(a)&&Array.isArray(e)?[...a,...e]:a+e}n(pX,"add");function nW(a){return a!==null&&typeof a=="object"&&typeof a.sub=="function"}n(nW,"isSubtractableObj");function aW(a){return a!==null&&typeof a=="object"&&typeof a.rsub=="function"}n(aW,"isRsubtractableObj");function lX(a,e){return nW(a)?a.sub(e):aW(e)?e.rsub(a):a instanceof Set&&e instanceof Set?new Set([...a].filter(t=>!e.has(t))):a-e}n(lX,"sub");function oW(a){return a!==null&&typeof a=="object"&&typeof a.mul=="function"}n(oW,"isMultipliableObj");function cW(a){return a!==null&&typeof a=="object"&&typeof a.rmul=="function"}n(cW,"isRmultipliableObj");function uX(a,e){return oW(a)?a.mul(e):cW(e)?e.rmul(a):a*e}n(uX,"mul");function pW(a){return a!==null&&typeof a=="object"&&typeof a.truediv=="function"}n(pW,"isTrueDivisibleObj");function lW(a){return a!==null&&typeof a=="object"&&typeof a.rtruediv=="function"}n(lW,"isRtrueDivisibleObj");function hX(a,e){return pW(a)?a.truediv(e):lW(e)?e.rtruediv(a):a/e}n(hX,"truediv");function uW(a){return a!==null&&typeof a=="object"&&typeof a.floorDiv=="function"}n(uW,"isFloorDivisibleObj");function hW(a){return a!==null&&typeof a=="object"&&typeof a.rfloorDiv=="function"}n(hW,"isRfloorDivisibleObj");function gX(a,e){return uW(a)?a.floorDiv(e):hW(e)?e.rfloorDiv(a):Math.trunc(a/e)}n(gX,"floorDiv");function gW(a){return a!==null&&typeof a=="object"&&typeof a.mod=="function"}n(gW,"isModableObj");function EW(a){return a!==null&&typeof a=="object"&&typeof a.rmod=="function"}n(EW,"isRmodableObj");function EX(a,e){return gW(a)?a.mod(e):EW(e)?e.rmod(a):a%e}n(EX,"mod");function AW(a){return a!==null&&typeof a=="object"&&typeof a.pow=="function"}n(AW,"isPowableObj");function dW(a){return a!==null&&typeof a=="object"&&typeof a.rpow=="function"}n(dW,"isRpowableObj");function AX(a,e){return AW(a)?a.pow(e):dW(e)?e.rpow(a):a**e}n(AX,"pow");function hG(a){return a!==null&&typeof a=="object"&&typeof a.lt=="function"}n(hG,"isLtComparableObj");function dX(a,e){return hG(a)?a.lt(e):EG(e)?e.gt(a):a<e}n(dX,"lt");function gG(a){return a!==null&&typeof a=="object"&&typeof a.lte=="function"}n(gG,"isLteComparableObj");function xX(a,e){return gG(a)?a.lte(e):AG(e)?e.gte(a):a<=e}n(xX,"lte");function EG(a){return a!==null&&typeof a=="object"&&typeof a.gt=="function"}n(EG,"isGtComparableObj");function fX(a,e){return EG(a)?a.gt(e):hG(e)?e.lt(a):e<a}n(fX,"gt");function AG(a){return a!==null&&typeof a=="object"&&typeof a.gte=="function"}n(AG,"isGteComparableObj");function TX(a,e){return AG(a)?a.gte(e):gG(e)?e.lte(a):e<=a}n(TX,"gte");function lG(a){return a!==null&&typeof a=="object"&&typeof a.eq=="function"}n(lG,"isEqComparableObj");function xW(a,e){return lG(a)?a.eq(e):lG(e)?e.eq(a):a===e}n(xW,"eq");function uG(a){return a!==null&&typeof a=="object"&&typeof a.neq=="function"}n(uG,"isNeqComparableObj");function SX(a,e){return uG(a)?a.neq(e):uG(e)?e.neq(a):!xW(a,e)}n(SX,"neq");function fW(a){return a!==null&&typeof a=="object"&&typeof a.or=="function"}n(fW,"isOrableObj");function TW(a){return a!==null&&typeof a=="object"&&typeof a.ror=="function"}n(TW,"isRorableObj");function RX(a,e){return fW(a)?a.or(e):TW(e)?e.ror(a):a instanceof Set&&e instanceof Set?new Set([...a,...e]):a|e}n(RX,"or");function SW(a){return a!==null&&typeof a=="object"&&typeof a.and=="function"}n(SW,"isAndableObj");function RW(a){return a!==null&&typeof a=="object"&&typeof a.rand=="function"}n(RW,"isRandableObj");function OX(a,e){return SW(a)?a.and(e):RW(e)?e.rand(a):a instanceof Set&&e instanceof Set?new Set([...a].filter(t=>e.has(t))):a&e}n(OX,"and");function OW(a){return a!==null&&typeof a=="object"&&typeof a.xor=="function"}n(OW,"isXorableObj");function mW(a){return a!==null&&typeof a=="object"&&typeof a.rxor=="function"}n(mW,"isRxorableObj");function mX(a,e){if(OW(a))return a.xor(e);if(mW(e))return e.rxor(a);if(a instanceof Set&&e instanceof Set){let t=a,s=e;return new Set([...[...t].filter(r=>!s.has(r)),...[...s].filter(r=>!t.has(r))])}return a^e}n(mX,"xor");function NW(a){return a!==null&&typeof a=="object"&&typeof a.lshift=="function"}n(NW,"isLshiftableObj");function IW(a){return a!==null&&typeof a=="object"&&typeof a.rlshift=="function"}n(IW,"isRlshiftableObj");function NX(a,e){return NW(a)?a.lshift(e):IW(e)?e.rlshift(a):a<<e}n(NX,"lshift");function yW(a){return a!==null&&typeof a=="object"&&typeof a.rshift=="function"}n(yW,"isRshiftableObj");function CW(a){return a!==null&&typeof a=="object"&&typeof a.rrshift=="function"}n(CW,"isRrshiftableObj");function IX(a,e){return yW(a)?a.rshift(e):CW(e)?e.rrshift(a):a>>e}n(IX,"rshift");var YI=(l=>(l.ABS="abs",l.ACOS="acos",l.ACOSH="acosh",l.ADD="add",l.ADD_CONSTRAINT="addConstraint",l.ADD_MONTHS="addMonths",l.ADD_PARTITION="addPartition",l.ADJACENT="adjacent",l.AGG_FUNC="aggFunc",l.AI_AGG="aiAgg",l.AI_CLASSIFY="aiClassify",l.AI_SUMMARIZE_AGG="aiSummarizeAgg",l.ALGORITHM_PROPERTY="algorithmProperty",l.ALIAS="alias",l.ALIASES="aliases",l.ALL="all",l.ALLOWED_VALUES_PROPERTY="allowedValuesProperty",l.ALTER="alter",l.ALTER_COLUMN="alterColumn",l.ALTER_DIST_STYLE="alterDistStyle",l.ALTER_INDEX="alterIndex",l.ALTER_MODIFY_SQL_SECURITY="alterModifySqlSecurity",l.ALTER_RENAME="alterRename",l.ALTER_SESSION="alterSession",l.ALTER_SET="alterSet",l.ALTER_SORT_KEY="alterSortKey",l.ANALYZE="analyze",l.ANALYZE_COLUMNS="analyzeColumns",l.ANALYZE_DELETE="analyzeDelete",l.ANALYZE_HISTOGRAM="analyzeHistogram",l.ANALYZE_LIST_CHAINED_ROWS="analyzeListChainedRows",l.ANALYZE_SAMPLE="analyzeSample",l.ANALYZE_STATISTICS="analyzeStatistics",l.ANALYZE_VALIDATE="analyzeValidate",l.ANALYZE_WITH="analyzeWith",l.AND="and",l.ANONYMOUS="anonymous",l.ANONYMOUS_AGG_FUNC="anonymousAggFunc",l.ANY="any",l.ANY_VALUE="anyValue",l.APPLY="apply",l.APPROXIMATE_SIMILARITY="approximateSimilarity",l.APPROX_DISTINCT="approxDistinct",l.APPROX_PERCENTILE_ACCUMULATE="approxPercentileAccumulate",l.APPROX_PERCENTILE_COMBINE="approxPercentileCombine",l.APPROX_PERCENTILE_ESTIMATE="approxPercentileEstimate",l.APPROX_QUANTILE="approxQuantile",l.APPROX_QUANTILES="approxQuantiles",l.APPROX_TOP_K="approxTopK",l.APPROX_TOP_K_ACCUMULATE="approxTopKAccumulate",l.APPROX_TOP_K_COMBINE="approxTopKCombine",l.APPROX_TOP_K_ESTIMATE="approxTopKEstimate",l.APPROX_TOP_SUM="approxTopSum",l.ARG_MAX="argMax",l.ARG_MIN="argMin",l.ARRAY="array",l.ARRAYS_ZIP="arraysZip",l.ARRAY_AGG="arrayAgg",l.ARRAY_ALL="arrayAll",l.ARRAY_ANY="arrayAny",l.ARRAY_APPEND="arrayAppend",l.ARRAY_COMPACT="arrayCompact",l.ARRAY_CONCAT="arrayConcat",l.ARRAY_CONCAT_AGG="arrayConcatAgg",l.ARRAY_CONSTRUCT_COMPACT="arrayConstructCompact",l.ARRAY_DISTINCT="arrayDistinct",l.ARRAY_EXCEPT="arrayExcept",l.ARRAY_MAX="arrayMax",l.ARRAY_MIN="arrayMin",l.ARRAY_CONTAINS="arrayContains",l.ARRAY_CONTAINS_ALL="arrayContainsAll",l.ARRAY_FILTER="arrayFilter",l.ARRAY_FIRST="arrayFirst",l.ARRAY_INSERT="arrayInsert",l.ARRAY_INTERSECT="arrayIntersect",l.ARRAY_LAST="arrayLast",l.ARRAY_OVERLAPS="arrayOverlaps",l.ARRAY_POSITION="arrayPosition",l.ARRAY_PREPEND="arrayPrepend",l.ARRAY_REMOVE="arrayRemove",l.ARRAY_REMOVE_AT="arrayRemoveAt",l.ARRAY_REVERSE="arrayReverse",l.ARRAY_SIZE="arraySize",l.ARRAY_SLICE="arraySlice",l.ARRAY_SORT="arraySort",l.ARRAY_SUM="arraySum",l.ARRAY_TO_STRING="arrayToString",l.ARRAY_UNION_AGG="arrayUnionAgg",l.ARRAY_UNIQUE_AGG="arrayUniqueAgg",l.ASCII="ascii",l.ASIN="asin",l.ASINH="asinh",l.ATAN="atan",l.ATAN2="atan2",l.ATANH="atanh",l.ATTACH="attach",l.ATTACH_OPTION="attachOption",l.AT_INDEX="atIndex",l.API_PROPERTY="apiProperty",l.APPLICATION_PROPERTY="applicationProperty",l.ASSUME_COLUMN_CONSTRAINT="assumeColumnConstraint",l.AT_TIME_ZONE="atTimeZone",l.AUTO_INCREMENT_COLUMN_CONSTRAINT="autoIncrementColumnConstraint",l.AUTO_INCREMENT_PROPERTY="autoIncrementProperty",l.AUTO_REFRESH_PROPERTY="autoRefreshProperty",l.AVG="avg",l.BACKUP_PROPERTY="backupProperty",l.BASE64_DECODE_BINARY="base64DecodeBinary",l.BASE64_DECODE_STRING="base64DecodeString",l.BASE64_ENCODE="base64Encode",l.BETWEEN="between",l.BINARY="binary",l.BITMAP_BIT_POSITION="bitmapBitPosition",l.BITMAP_BUCKET_NUMBER="bitmapBucketNumber",l.BITMAP_CONSTRUCT_AGG="bitmapConstructAgg",l.BITMAP_COUNT="bitmapCount",l.BITMAP_OR_AGG="bitmapOrAgg",l.BITWISE_AND="bitwiseAnd",l.BITWISE_AND_AGG="bitwiseAndAgg",l.BITWISE_COUNT="bitwiseCount",l.BITWISE_LEFT_SHIFT="bitwiseLeftShift",l.BITWISE_NOT="bitwiseNot",l.BITWISE_OR="bitwiseOr",l.BITWISE_OR_AGG="bitwiseOrAgg",l.BITWISE_RIGHT_SHIFT="bitwiseRightShift",l.BITWISE_XOR="bitwiseXor",l.BITWISE_XOR_AGG="bitwiseXorAgg",l.BIT_LENGTH="bitLength",l.BIT_STRING="bitString",l.BLOCK="block",l.BLOCK_COMPRESSION_PROPERTY="blockCompressionProperty",l.BOOLAND="booland",l.BOOLEAN="boolean",l.BOOLNOT="boolnot",l.BOOLOR="boolor",l.BOOLXOR_AGG="boolxorAgg",l.BRACKET="bracket",l.BUILD_PROPERTY="buildProperty",l.BYTE_LENGTH="byteLength",l.BYTE_STRING="byteString",l.CACHE="cache",l.CASE="case",l.CASE_SPECIFIC_COLUMN_CONSTRAINT="caseSpecificColumnConstraint",l.CAST="cast",l.CAST_TO_STR_TYPE="castToStrType",l.CATALOG_PROPERTY="catalogProperty",l.CBRT="cbrt",l.CEIL="ceil",l.CHANGES="changes",l.CHARACTER_SET="characterSet",l.CHARACTER_SET_COLUMN_CONSTRAINT="characterSetColumnConstraint",l.CHARACTER_SET_PROPERTY="characterSetProperty",l.CHECK="check",l.CHECKSUM_PROPERTY="checksumProperty",l.CHECK_COLUMN_CONSTRAINT="checkColumnConstraint",l.CHECK_JSON="checkJson",l.CHECK_XML="checkXml",l.CHR="chr",l.CITY_HASH64="cityHash64",l.CLONE="clone",l.CLUSTER="cluster",l.CLUSTERED_BY_PROPERTY="clusteredByProperty",l.CLUSTERED_COLUMN_CONSTRAINT="clusteredColumnConstraint",l.COALESCE="coalesce",l.CODE_POINTS_TO_BYTES="codePointsToBytes",l.CODE_POINTS_TO_STRING="codePointsToString",l.COLLATE="collate",l.COLLATE_COLUMN_CONSTRAINT="collateColumnConstraint",l.COLLATE_PROPERTY="collateProperty",l.COLLATION="collation",l.COLUMN="column",l.COLUMNS="columns",l.COLUMN_CONSTRAINT="columnConstraint",l.COLUMN_CONSTRAINT_KIND="columnConstraintKind",l.COLUMN_DEF="columnDef",l.COLUMN_POSITION="columnPosition",l.COLUMN_PREFIX="columnPrefix",l.COMBINED_AGG_FUNC="combinedAggFunc",l.COMBINED_PARAMETERIZED_AGG="combinedParameterizedAgg",l.COMMAND="command",l.COMMENT="comment",l.COMMENT_COLUMN_CONSTRAINT="commentColumnConstraint",l.COMMIT="commit",l.COMPUTE_PROPERTY="computeProperty",l.COMPREHENSION="comprehension",l.COMPRESS="compress",l.COMPRESS_COLUMN_CONSTRAINT="compressColumnConstraint",l.COMPUTED_COLUMN_CONSTRAINT="computedColumnConstraint",l.CONCAT="concat",l.CONCAT_WS="concatWs",l.CONDITION="condition",l.CONDITIONAL_INSERT="conditionalInsert",l.CONNECT="connect",l.CONNECTOR="connector",l.CONNECT_BY_ROOT="connectByRoot",l.CONSTRAINT="constraint",l.CONTAINS="contains",l.CONVERT="convert",l.CONVERT_TIMEZONE="convertTimezone",l.CONVERT_TO_CHARSET="convertToCharset",l.COPY="copy",l.COPY_GRANTS_PROPERTY="copyGrantsProperty",l.COPY_PARAMETER="copyParameter",l.CORR="corr",l.COS="cos",l.COSH="cosh",l.COSINE_DISTANCE="cosineDistance",l.COT="cot",l.COTH="coth",l.COUNT="count",l.COUNT_IF="countIf",l.COVAR_POP="covarPop",l.COVAR_SAMP="covarSamp",l.CREATE="create",l.CREDENTIALS="credentials",l.CREDENTIALS_PROPERTY="credentialsProperty",l.CSC="csc",l.CSCH="csch",l.CTE="cte",l.CUBE="cube",l.CUME_DIST="cumeDist",l.CURRENT_ACCOUNT="currentAccount",l.CURRENT_ACCOUNT_NAME="currentAccountName",l.CURRENT_AVAILABLE_ROLES="currentAvailableRoles",l.CURRENT_CATALOG="currentCatalog",l.CURRENT_CLIENT="currentClient",l.CURRENT_DATABASE="currentDatabase",l.CURRENT_DATE="currentDate",l.CURRENT_DATETIME="currentDatetime",l.CURRENT_IP_ADDRESS="currentIpAddress",l.CURRENT_ORGANIZATION_NAME="currentOrganizationName",l.CURRENT_ORGANIZATION_USER="currentOrganizationUser",l.CURRENT_REGION="currentRegion",l.CURRENT_ROLE="currentRole",l.CURRENT_ROLE_TYPE="currentRoleType",l.CURRENT_SCHEMA="currentSchema",l.CURRENT_SCHEMAS="currentSchemas",l.CURRENT_SECONDARY_ROLES="currentSecondaryRoles",l.CURRENT_SESSION="currentSession",l.CURRENT_STATEMENT="currentStatement",l.CURRENT_TIME="currentTime",l.CURRENT_TIMESTAMP="currentTimestamp",l.CURRENT_TIMESTAMP_LTZ="currentTimestampLtz",l.CURRENT_TIMEZONE="currentTimezone",l.CURRENT_TRANSACTION="currentTransaction",l.CURRENT_USER="currentUser",l.CURRENT_VERSION="currentVersion",l.CURRENT_WAREHOUSE="currentWarehouse",l.DATA_BLOCKSIZE_PROPERTY="dataBlocksizeProperty",l.DATABASE_PROPERTY="databaseProperty",l.DATA_DELETION_PROPERTY="dataDeletionProperty",l.DATA_TYPE="dataType",l.DATA_TYPE_PARAM="dataTypeParam",l.DATE="date",l.DATETIME="datetime",l.DATETIME_ADD="datetimeAdd",l.DATETIME_DIFF="datetimeDiff",l.DATETIME_SUB="datetimeSub",l.DATETIME_TRUNC="datetimeTrunc",l.DATE_ADD="dateAdd",l.DATE_BIN="dateBin",l.DATE_DIFF="dateDiff",l.DATE_FORMAT_COLUMN_CONSTRAINT="dateFormatColumnConstraint",l.DATE_FROM_PARTS="dateFromParts",l.DATE_FROM_UNIX_DATE="dateFromUnixDate",l.DATE_STR_TO_DATE="dateStrToDate",l.DATE_SUB="dateSub",l.DATE_TO_DATE_STR="dateToDateStr",l.DATE_TO_DI="dateToDi",l.DATE_TRUNC="dateTrunc",l.DAY="day",l.DAYNAME="dayname",l.DAY_OF_MONTH="dayOfMonth",l.DAY_OF_WEEK="dayOfWeek",l.DAY_OF_WEEK_ISO="dayOfWeekIso",l.DAY_OF_YEAR="dayOfYear",l.DDL="ddl",l.DECLARE="declare",l.DECLARE_ITEM="declareItem",l.DECODE="decode",l.DECODE_CASE="decodeCase",l.DECOMPRESS_BINARY="decompressBinary",l.DECOMPRESS_STRING="decompressString",l.DECRYPT="decrypt",l.DECRYPT_RAW="decryptRaw",l.DEFAULT_COLUMN_CONSTRAINT="defaultColumnConstraint",l.DEFINER_PROPERTY="definerProperty",l.DEGREES="degrees",l.DELETE="delete",l.DENSE_RANK="denseRank",l.DERIVED_TABLE="derivedTable",l.DESCRIBE="describe",l.DETACH="detach",l.DICT_PROPERTY="dictProperty",l.DICT_RANGE="dictRange",l.DICT_SUB_PROPERTY="dictSubProperty",l.DIRECTORY="directory",l.DIRECTORY_STAGE="directoryStage",l.DISTANCE="distance",l.DISTINCT="distinct",l.DISTRIBUTE="distribute",l.DISTRIBUTED_BY_PROPERTY="distributedByProperty",l.DIST_KEY_PROPERTY="distKeyProperty",l.DIST_STYLE_PROPERTY="distStyleProperty",l.DIV="div",l.DI_TO_DATE="diToDate",l.DML="dml",l.DOT="dot",l.DOT_PRODUCT="dotProduct",l.DROP="drop",l.DROP_PARTITION="dropPartition",l.DUPLICATE_KEY_PROPERTY="duplicateKeyProperty",l.DYNAMIC_PROPERTY="dynamicProperty",l.D_PIPE="dPipe",l.ELT="elt",l.EMPTY_PROPERTY="emptyProperty",l.ENCODE="encode",l.ENCODE_COLUMN_CONSTRAINT="encodeColumnConstraint",l.ENCODE_PROPERTY="encodeProperty",l.ENCRYPT="encrypt",l.ENCRYPT_RAW="encryptRaw",l.END_STATEMENT="endStatement",l.ENDS_WITH="endsWith",l.ENGINE_PROPERTY="engineProperty",l.ENVIROMENT_PROPERTY="enviromentProperty",l.EPHEMERAL_COLUMN_CONSTRAINT="ephemeralColumnConstraint",l.EQ="eq",l.EqUAL_NULL="equalNull",l.ESCAPE="escape",l.EUCLIDEAN_DISTANCE="euclideanDistance",l.EXCEPT="except",l.EXCLUDE_COLUMN_CONSTRAINT="excludeColumnConstraint",l.EXECUTE="execute",l.EXECUTE_AS_PROPERTY="executeAsProperty",l.EXECUTE_SQL="executeSql",l.EXISTS="exists",l.EXP="exp",l.EXPLODE="explode",l.EXPLODE_OUTER="explodeOuter",l.EXPLODING_GENERATE_SERIES="explodingGenerateSeries",l.EXPORT="export",l.EXPRESSION="expression",l.EXTENDS_LEFT="extendsLeft",l.EXTENDS_RIGHT="extendsRight",l.EXTERNAL_PROPERTY="externalProperty",l.EXTRACT="extract",l.FACTORIAL="factorial",l.FALLBACK_PROPERTY="fallbackProperty",l.FARM_FINGERPRINT="farmFingerprint",l.FEATURES_AT_TIME="featuresAtTime",l.FETCH="fetch",l.FILE_FORMAT_PROPERTY="fileFormatProperty",l.FILTER="filter",l.FINAL="final",l.FIRST="first",l.FIRST_VALUE="firstValue",l.FLATTEN="flatten",l.FLOAT64="float64",l.FLOOR="floor",l.FORCE_PROPERTY="forceProperty",l.FOREIGN_KEY="foreignKey",l.FORMAT="format",l.FORMAT_JSON="formatJson",l.FORMAT_PHRASE="formatPhrase",l.FOR_IN="forIn",l.FREESPACE_PROPERTY="freespaceProperty",l.FROM="from",l.FROM_BASE="fromBase",l.FROM_BASE32="fromBase32",l.FROM_BASE64="fromBase64",l.FROM_ISO8601_TIMESTAMP="fromIso8601Timestamp",l.FROM_TIME_ZONE="fromTimeZone",l.FUNC="func",l.GAP_FILL="gapFill",l.GENERATED_AS_IDENTITY_COLUMN_CONSTRAINT="generatedAsIdentityColumnConstraint",l.GENERATED_AS_ROW_COLUMN_CONSTRAINT="generatedAsRowColumnConstraint",l.GENERATE_DATE_ARRAY="generateDateArray",l.GENERATE_EMBEDDING="generateEmbedding",l.GENERATE_SERIES="generateSeries",l.GENERATE_TIMESTAMP_ARRAY="generateTimestampArray",l.GENERATOR="generator",l.GET="get",l.GETBIT="getbit",l.GET_EXTRACT="getExtract",l.GLOB="glob",l.GLOBAL_PROPERTY="globalProperty",l.GRANT="grant",l.GRANT_PRINCIPAL="grantPrincipal",l.GRANT_PRIVILEGE="grantPrivilege",l.GREATEST="greatest",l.GROUP="group",l.GROUPING="grouping",l.GROUPING_ID="groupingId",l.GROUPING_SETS="groupingSets",l.GROUP_CONCAT="groupConcat",l.GT="gt",l.GTE="gte",l.HASH_AGG="hashAgg",l.HAVING="having",l.HAVING_MAX="havingMax",l.HANDLER_PROPERTY="handlerProperty",l.HEAP_PROPERTY="heapProperty",l.HYBRID_PROPERTY="hybridProperty",l.HEREDOC="heredoc",l.HEX="hex",l.HEX_DECODE_STRING="hexDecodeString",l.HEX_ENCODE="hexEncode",l.HEX_STRING="hexString",l.HINT="hint",l.HISTORICAL_DATA="historicalData",l.HLL="hll",l.HOST="host",l.HOUR="hour",l.ICEBERG_PROPERTY="icebergProperty",l.IDENTIFIER="identifier",l.IF="if",l.IF_BLOCK="ifBlock",l.IGNORE_NULLS="ignoreNulls",l.IN="in",l.INCLUDE_PROPERTY="includeProperty",l.INDEX="index",l.INDEX_COLUMN_CONSTRAINT="indexColumnConstraint",l.INDEX_CONSTRAINT_OPTION="indexConstraintOption",l.INDEX_PARAMETERS="indexParameters",l.INDEX_TABLE_HINT="indexTableHint",l.INHERITS_PROPERTY="inheritsProperty",l.INITCAP="initcap",l.INLINE="inline",l.INLINE_LENGTH_COLUMN_CONSTRAINT="inlineLengthColumnConstraint",l.INPUT_MODEL_PROPERTY="inputModelProperty",l.INPUT_OUTPUT_FORMAT="inputOutputFormat",l.INSERT="insert",l.INSTALL="install",l.INT64="int64",l.INTERSECT="intersect",l.INTERVAL="interval",l.INTERVAL_OP="intervalOp",l.INTERVAL_SPAN="intervalSpan",l.INTO="into",l.INTRODUCER="introducer",l.INT_DIV="intDiv",l.IN_OUT_COLUMN_CONSTRAINT="inOutColumnConstraint",l.IS="is",l.ISOLATED_LOADING_PROPERTY="isolatedLoadingProperty",l.IS_ARRAY="isArray",l.IS_ASCII="isAscii",l.IS_INF="isInf",l.IS_NAN="isNan",l.IS_NULL_VALUE="isNullValue",l.ILIKE="iLike",l.JAROWINKLER_SIMILARITY="jarowinklerSimilarity",l.JOIN="join",l.JOIN_HINT="joinHint",l.JOURNAL_PROPERTY="journalProperty",l.JSON="json",l.JSON_ARRAY="jsonArray",l.JSON_ARRAY_AGG="jsonArrayAgg",l.JSON_ARRAY_APPEND="jsonArrayAppend",l.JSON_ARRAY_CONTAINS="jsonArrayContains",l.JSON_ARRAY_INSERT="jsonArrayInsert",l.JSON_BOOL="jsonBool",l.JSONB_CONTAINS="jsonbContains",l.JSONB_CONTAINS_ALL_TOP_KEYS="jsonbContainsAllTopKeys",l.JSONB_CONTAINS_ANY_TOP_KEYS="jsonbContainsAnyTopKeys",l.JSONB_DELETE_AT_PATH="jsonbDeleteAtPath",l.JSONB_EXISTS="jsonbExists",l.JSONB_EXTRACT="jsonbExtract",l.JSONB_EXTRACT_SCALAR="jsonbExtractScalar",l.JSONB_OBJECT_AGG="jsonbObjectAgg",l.JSON_CAST="jsonCast",l.JSON_COLUMN_DEF="jsonColumnDef",l.JSON_EXISTS="jsonExists",l.JSON_EXTRACT="jsonExtract",l.JSON_EXTRACT_ARRAY="jsonExtractArray",l.JSON_EXTRACT_QUOTE="jsonExtractQuote",l.JSON_EXTRACT_SCALAR="jsonExtractScalar",l.JSON_FORMAT="jsonFormat",l.JSON_KEYS="jsonKeys",l.JSON_KEYS_AT_DEPTH="jsonKeysAtDepth",l.JSON_KEY_VALUE="jsonKeyValue",l.JSON_OBJECT="jsonObject",l.JSON_OBJECT_AGG="jsonObjectAgg",l.JSON_PATH="jsonPath",l.JSON_PATH_FILTER="jsonPathFilter",l.JSON_PATH_KEY="jsonPathKey",l.JSON_PATH_PART="jsonPathPart",l.JSON_PATH_RECURSIVE="jsonPathRecursive",l.JSON_PATH_ROOT="jsonPathRoot",l.JSON_PATH_SCRIPT="jsonPathScript",l.JSON_PATH_SELECTOR="jsonPathSelector",l.JSON_PATH_SLICE="jsonPathSlice",l.JSON_PATH_SUBSCRIPT="jsonPathSubscript",l.JSON_PATH_UNION="jsonPathUnion",l.JSON_PATH_WILDCARD="jsonPathWildcard",l.JSON_REMOVE="jsonRemove",l.JSON_SCHEMA="jsonSchema",l.JSON_SET="jsonSet",l.JSON_STRIP_NULLS="jsonStripNulls",l.JSON_TABLE="jsonTable",l.JSON_TYPE="jsontype",l.JSON_VALUE="jsonValue",l.JSON_VALUE_ARRAY="jsonValueArray",l.JUSTIFY_DAYS="justifyDays",l.JUSTIFY_HOURS="justifyHours",l.JUSTIFY_INTERVAL="justifyInterval",l.KILL="kill",l.KURTOSIS="kurtosis",l.KWARG="kwarg",l.LAG="lag",l.LAMBDA="lambda",l.LANGUAGE_PROPERTY="languageProperty",l.LAST="last",l.LAST_DAY="lastDay",l.LAST_VALUE="lastValue",l.LATERAL="lateral",l.LAX_BOOL="laxBool",l.LAX_FLOAT64="laxFloat64",l.LAX_INT64="laxInt64",l.LAX_STRING="laxString",l.LEAD="lead",l.LEAST="least",l.LEFT="left",l.LENGTH="length",l.LEVENSHTEIN="levenshtein",l.LIKE="like",l.LIKE_PROPERTY="likeProperty",l.LIMIT="limit",l.LIMIT_OPTIONS="limitOptions",l.LIST="list",l.LITERAL="literal",l.LN="ln",l.LOAD_DATA="loadData",l.LOCALTIME="localtime",l.LOCALTIMESTAMP="localtimestamp",l.LOCATION="location",l.LOCATION_PROPERTY="locationProperty",l.LOCK="lock",l.LOCKING_PROPERTY="lockingProperty",l.LOCKING_STATEMENT="lockingStatement",l.LOCK_PROPERTY="lockProperty",l.LOG="log",l.LOGICAL_AND="logicalAnd",l.LOGICAL_OR="logicalOr",l.LOG_PROPERTY="logProperty",l.LOWER="lower",l.LOWER_HEX="lowerHex",l.LT="lt",l.LTE="lte",l.MAKE_INTERVAL="makeInterval",l.MANHATTAN_DISTANCE="manhattanDistance",l.MAP="map",l.MAP_CAT="mapCat",l.MAP_CONTAINS_KEY="mapContainsKey",l.MAP_DELETE="mapDelete",l.MAP_FROM_ENTRIES="mapFromEntries",l.MAP_INSERT="mapInsert",l.MAP_KEYS="mapkeys",l.MAP_PICK="mapPick",l.MAP_SIZE="mapSize",l.MASKING_POLICY_COLUMN_CONSTRAINT="maskingPolicyColumnConstraint",l.MATCH="match",l.MATCH_AGAINST="matchAgainst",l.MATCH_RECOGNIZE="matchRecognize",l.MATCH_RECOGNIZE_MEASURE="matchRecognizeMeasure",l.MASKING_PROPERTY="maskingProperty",l.MATERIALIZED_PROPERTY="materializedProperty",l.MAX="max",l.MD5="md5",l.MD5_DIGEST="md5Digest",l.MD5_NUMBER_LOWER64="md5NumberLower64",l.MD5_NUMBER_UPPER64="md5NumberUpper64",l.MEDIAN="median",l.MERGE="merge",l.MERGE_BLOCK_RATIO_PROPERTY="mergeBlockRatioProperty",l.MERGE_TREE_TTL="mergeTreeTtl",l.MERGE_TREE_TTL_ACTION="mergeTreeTtlAction",l.MIN="min",l.MINHASH="minhash",l.MINHASH_COMBINE="minhashCombine",l.MINUTE="minute",l.ML_FORECAST="mlForecast",l.ML_TRANSLATE="mlTranslate",l.MOD="mod",l.MODE="mode",l.MODEL_ATTRIBUTE="modelAttribute",l.MODIFY_COLUMN="modifyColumn",l.MONTH="month",l.MONTHNAME="monthname",l.MONTHS_BETWEEN="monthsBetween",l.MUL="mul",l.MULTITABLE_INSERTS="multitableInserts",l.NATIONAL="national",l.NEG="neg",l.NEQ="neq",l.NESTED_JSON_SELECT="nestedJsonSelect",l.NET_FUNC="netFunc",l.NEXT_DAY="nextDay",l.NEXT_VALUE_FOR="nextValueFor",l.NON_CLUSTERED_COLUMN_CONSTRAINT="nonClusteredColumnConstraint",l.NORMAL="normal",l.NORMALIZE="normalize",l.NOT="not",l.NOT_FOR_REPLICATION_COLUMN_CONSTRAINT="notForReplicationColumnConstraint",l.NOT_NULL_COLUMN_CONSTRAINT="notNullColumnConstraint",l.NETWORK_PROPERTY="networkProperty",l.NO_PRIMARY_INDEX_PROPERTY="noPrimaryIndexProperty",l.NTH_VALUE="nthValue",l.NTILE="ntile",l.NULL="null",l.NULLIF="nullif",l.NULL_SAFE_EQ="nullSafeEq",l.NULL_SAFE_NEQ="nullSafeNeq",l.NUMBER_TO_STR="numberToStr",l.NVL2="nvl2",l.OBJECT_AGG="objectAgg",l.OBJECT_ID="objectId",l.OBJECT_IDENTIFIER="objectIdentifier",l.OBJECT_INSERT="objectInsert",l.OFFSET="offset",l.ON_CLUSTER="onCluster",l.ON_COMMIT_PROPERTY="onCommitProperty",l.ON_CONDITION="onCondition",l.ON_CONFLICT="onConflict",l.ON_PROPERTY="onProperty",l.ON_UPDATE_COLUMN_CONSTRAINT="onUpdateColumnConstraint",l.OPCLASS="opclass",l.OPEN_JSON="openJson",l.OPEN_JSON_COLUMN_DEF="openJsonColumnDef",l.OPERATOR="operator",l.OR="or",l.ORDER="order",l.ORDERED="ordered",l.OUTPUT_MODEL_PROPERTY="outputModelProperty",l.OVERFLOW_TRUNCATE_BEHAVIOR="overflowTruncateBehavior",l.OVERLAPS="overlaps",l.OVERLAY="overlay",l.PAD="pad",l.PARAMETER="parameter",l.PARAMETERIZED_AGG="parameterizedAgg",l.PAREN="paren",l.PARSE_BIGNUMERIC="parseBignumeric",l.PARSE_DATETIME="parseDatetime",l.PARSE_IP="parseIp",l.PARSE_JSON="parseJson",l.PARSE_NUMERIC="parseNumeric",l.PARSE_TIME="parseTime",l.PARSE_URL="parseUrl",l.PARTITION="partition",l.PARTITIONED_BY_BUCKET="partitionedByBucket",l.PARTITIONED_BY_PROPERTY="partitionedByProperty",l.PARTITIONED_OF_PROPERTY="partitionedOfProperty",l.PARTITION_BOUND_SPEC="partitionBoundSpec",l.PARTITION_BY_LIST_PROPERTY="partitionByListProperty",l.PARAMETER_STYLE_PROPERTY="parameterStyleProperty",l.PARTITION_BY_RANGE_PROPERTY="partitionByRangeProperty",l.PARTITION_BY_RANGE_PROPERTY_DYNAMIC="partitionByRangePropertyDynamic",l.PARTITION_BY_TRUNCATE="partitionByTruncate",l.PARTITION_ID="partitionId",l.PARTITION_LIST="partitionList",l.PARTITION_RANGE="partitionRange",l.PATH_COLUMN_CONSTRAINT="pathColumnConstraint",l.PERCENTILE_CONT="percentileCont",l.PERCENTILE_DISC="percentileDisc",l.PERCENT_RANK="percentRank",l.PERIOD_FOR_SYSTEM_TIME_CONSTRAINT="periodForSystemTimeConstraint",l.PI="pi",l.PIVOT="pivot",l.PIVOT_ALIAS="pivotAlias",l.PIVOT_ANY="pivotAny",l.PLACEHOLDER="placeholder",l.POSEXPLODE="posexplode",l.POSEXPLODE_OUTER="posexplodeOuter",l.POSITIONAL_COLUMN="positionalColumn",l.POW="pow",l.PRAGMA="pragma",l.PREDICATE="predicate",l.PREDICT="predict",l.PREVIOUS_DAY="previousDay",l.PRE_WHERE="preWhere",l.PRIMARY_KEY="primaryKey",l.PRIMARY_KEY_COLUMN_CONSTRAINT="primaryKeyColumnConstraint",l.PRIOR="prior",l.PROJECTION_DEF="projectionDef",l.PROJECTION_POLICY_COLUMN_CONSTRAINT="projectionPolicyColumnConstraint",l.PROPERTIES="properties",l.PROPERTY="property",l.PROPERTY_EQ="propertyEq",l.PSEUDOCOLUMN="pseudocolumn",l.PSEUDO_TYPE="pseudoType",l.PUT="put",l.QUALIFY="qualify",l.QUANTILE="quantile",l.QUARTER="quarter",l.QUERY="query",l.QUERY_BAND="queryBand",l.QUERY_OPTION="queryOption",l.QUERY_TRANSFORM="queryTransform",l.RADIANS="radians",l.RAND="rand",l.RANDN="randn",l.RANDSTR="randstr",l.RANGE_BUCKET="rangeBucket",l.RANGE_N="rangeN",l.RANK="rank",l.RAW_STRING="rawString",l.READ_CSV="readCsv",l.READ_PARQUET="readParquet",l.RECURSIVE_WITH_SEARCH="recursiveWithSearch",l.REDUCE="reduce",l.REFERENCE="reference",l.REFRESH="refresh",l.REFRESH_TRIGGER_PROPERTY="refreshTriggerProperty",l.REGEXP_COUNT="regexpCount",l.REGEXP_EXTRACT="regexpExtract",l.REGEXP_EXTRACT_ALL="regexpExtractAll",l.REGEXP_FULL_MATCH="regexpFullMatch",l.REGEXP_INSTR="regexpInstr",l.REGEXP_ILIKE="regexpIlike",l.REGEXP_LIKE="regexpLike",l.REGEXP_REPLACE="regexpReplace",l.REGEXP_SPLIT="regexpSplit",l.REGR_AVGX="regrAvgx",l.REGR_AVGY="regrAvgy",l.REGR_COUNT="regrCount",l.REGR_INTERCEPT="regrIntercept",l.REGR_R2="regrR2",l.REGR_SLOPE="regrSlope",l.REGR_SXX="regrSxx",l.REGR_SXY="regrSxy",l.REGR_SYY="regrSyy",l.REGR_VALX="regrValx",l.REGR_VALY="regrValy",l.REG_DOMAIN="regDomain",l.REMOTE_WITH_CONNECTION_MODEL_PROPERTY="remoteWithConnectionModelProperty",l.RENAME_COLUMN="renameColumn",l.REPEAT="repeat",l.REPLACE="replace",l.REPLACE_PARTITION="replacePartition",l.RESPECT_NULLS="respectNulls",l.RETURN="return",l.RETURNING="returning",l.RETURNS_PROPERTY="returnsProperty",l.REVERSE="reverse",l.REVOKE="revoke",l.RIGHT="right",l.ROLLBACK="rollback",l.ROLLUP="rollup",l.ROLLUP_INDEX="rollupIndex",l.ROLLUP_PROPERTY="rollupProperty",l.ROUND="round",l.ROW_ACCESS_PROPERTY="rowAccessProperty",l.ROW_FORMAT_DELIMITED_PROPERTY="rowFormatDelimitedProperty",l.ROW_FORMAT_PROPERTY="rowFormatProperty",l.ROW_FORMAT_SERDE_PROPERTY="rowFormatSerdeProperty",l.ROW_NUMBER="rowNumber",l.RTRIMMED_LENGTH="rtrimmedLength",l.SAFE_ADD="safeAdd",l.SAFE_CONVERT_BYTES_TO_STRING="safeConvertBytesToString",l.SAFE_DIVIDE="safeDivide",l.SAFE_FUNC="safeFunc",l.SAFE_MULTIPLY="safeMultiply",l.SAFE_NEGATE="safeNegate",l.SAFE_SUBTRACT="safeSubtract",l.SAMPLE_PROPERTY="sampleProperty",l.SCHEMA="schema",l.SCHEMA_COMMENT_PROPERTY="schemaCommentProperty",l.SCOPE_RESOLUTION="scopeResolution",l.SEARCH="search",l.SEARCH_IP="searchIp",l.SEC="sec",l.SECH="sech",l.SECOND="second",l.SECURE_PROPERTY="secureProperty",l.SECURITY_INTEGRATION_PROPERTY="securityIntegrationProperty",l.SELECT="select",l.SEMANTIC_VIEW="semanticView",l.SEMICOLON="semicolon",l.SEQ1="seq1",l.SEQ2="seq2",l.SEQ4="seq4",l.SEQ8="seq8",l.SEQUENCE_PROPERTIES="sequenceProperties",l.SERDE_PROPERTIES="serdeProperties",l.SESSION_PARAMETER="sessionParameter",l.SESSION_USER="sessionUser",l.SET="set",l.SETTINGS_PROPERTY="settingsProperty",l.SET_CONFIG_PROPERTY="setConfigProperty",l.SET_ITEM="setItem",l.SET_OPERATION="setOperation",l.SET_PROPERTY="setProperty",l.SHA="sha",l.Sha1_DIGEST="sha1Digest",l.Sha2="sha2",l.Sha2_DIGEST="sha2Digest",l.SHARING_PROPERTY="sharingProperty",l.SHOW="show",l.SIGN="sign",l.SIMILAR_TO="similarTo",l.SIN="sin",l.SINH="sinh",l.SKEWNESS="skewness",l.SKIP_JSON_COLUMN="skipJsonColumn",l.SLICE="slice",l.SORT="sort",l.SORT_ARRAY="sortArray",l.SORT_KEY_PROPERTY="sortKeyProperty",l.SOUNDEX="soundex",l.SOUNDEX_P123="soundexP123",l.SPACE="space",l.SPLIT="split",l.SPLIT_PART="splitPart",l.SQL_READ_WRITE_PROPERTY="sqlReadWriteProperty",l.SQL_SECURITY_PROPERTY="sqlSecurityProperty",l.SQRT="sqrt",l.STABILITY_PROPERTY="stabilityProperty",l.STANDARD_HASH="standardHash",l.STAR="star",l.STARTS_WITH="startsWith",l.STAR_MAP="starMap",l.STRTOK="strtok",l.STDDEV="stddev",l.STDDEV_POP="stddevPop",l.STDDEV_SAMP="stddevSamp",l.STORED_PROCEDURE="storedProcedure",l.STORAGE_HANDLER_PROPERTY="storageHandlerProperty",l.STREAM="stream",l.STREAMING_TABLE_PROPERTY="streamingTableProperty",l.STRICT_PROPERTY="strictProperty",l.STRING="string",l.STRING_TO_ARRAY="stringToArray",l.STRUCT="struct",l.STRUCT_EXTRACT="structExtract",l.STR_POSITION="strPosition",l.STR_TO_DATE="strToDate",l.STR_TO_MAP="strToMap",l.STR_TO_TIME="strToTime",l.STR_TO_UNIX="strToUnix",l.STUFF="stuff",l.ST_DISTANCE="stDistance",l.ST_POINT="stPoint",l.SUB="sub",l.SUBQUERY="subquery",l.SUBQUERY_PREDICATE="subqueryPredicate",l.SUBSTRING="substring",l.SUBSTRING_INDEX="substringIndex",l.SUM="sum",l.SUMMARIZE="summarize",l.SWAP_TABLE="swapTable",l.SYSTIMESTAMP="systimestamp",l.TABLE="table",l.TABLE_ALIAS="tableAlias",l.TABLE_COLUMN="tableColumn",l.TABLE_FROM_ROWS="tableFromRows",l.TABLE_SAMPLE="tableSample",l.TAG="tag",l.TAGS="tags",l.TAN="tan",l.TANH="tanh",l.TEMPORARY_PROPERTY="temporaryProperty",l.TIME="time",l.TIMESTAMP="timestamp",l.TIMESTAMP_ADD="timestampAdd",l.TIMESTAMP_DIFF="timestampDiff",l.TIMESTAMP_FROM_PARTS="timestampFromParts",l.TIMESTAMP_LTZ_FROM_PARTS="timestampLtzFromParts",l.TIMESTAMP_SUB="timestampSub",l.TIMESTAMP_TRUNC="timestampTrunc",l.TIMESTAMP_TZ_FROM_PARTS="timestampTzFromParts",l.TIME_ADD="timeAdd",l.TIME_DIFF="timeDiff",l.TIME_FROM_PARTS="timeFromParts",l.TIME_SLICE="timeSlice",l.TIME_STR_TO_DATE="timeStrToDate",l.TIME_STR_TO_TIME="timeStrToTime",l.TIME_STR_TO_UNIX="timeStrToUnix",l.TIME_SUB="timeSub",l.TIME_TO_STR="timeToStr",l.TIME_TO_TIME_STR="timeToTimeStr",l.TIME_TO_UNIX="timeToUnix",l.TIME_TRUNC="timeTrunc",l.TIME_UNIT="timeUnit",l.TITLE_COLUMN_CONSTRAINT="titleColumnConstraint",l.TO_ARRAY="toArray",l.TO_BASE32="toBase32",l.TO_BASE64="toBase64",l.TO_BINARY="toBinary",l.TO_BOOLEAN="toBoolean",l.TO_CHAR="toChar",l.TO_CODE_POINTS="toCodePoints",l.TO_DAYS="toDays",l.TO_DECFLOAT="toDecfloat",l.TO_DOUBLE="toDouble",l.TO_FILE="toFile",l.TO_MAP="toMap",l.TO_NUMBER="toNumber",l.TO_TABLE_PROPERTY="toTableProperty",l.TO_VARIANT="toVariant",l.TRANSACTION="transaction",l.TRANSFORM="transform",l.TRANSFORM_MODEL_PROPERTY="transformModelProperty",l.TRANSIENT_PROPERTY="transientProperty",l.TRANSLATE="translate",l.TRANSLATE_CHARACTERS="translateCharacters",l.TRIGGER_EVENT="triggerEvent",l.TRIGGER_EXECUTE="triggerExecute",l.TRIGGER_PROPERTIES="triggerProperties",l.TRIGGER_REFERENCING="triggerReferencing",l.TRIM="trim",l.TRUNC="trunc",l.TRUNCATE_TABLE="truncateTable",l.TRY="try",l.TRY_BASE64_DECODE_BINARY="tryBase64DecodeBinary",l.TRY_BASE64_DECODE_STRING="tryBase64DecodeString",l.TRY_CAST="tryCast",l.TRY_HEX_DECODE_BINARY="tryHexDecodeBinary",l.TRY_HEX_DECODE_STRING="tryHexDecodeString",l.TRY_TO_DECFLOAT="tryToDecfloat",l.TS_OR_DI_TO_DI="tsOrDiToDi",l.TS_OR_DS_ADD="tsOrDsAdd",l.TS_OR_DS_DIFF="tsOrDsDiff",l.TS_OR_DS_TO_DATE="tsOrDsToDate",l.TS_OR_DS_TO_DATETIME="tsOrDsToDatetime",l.TS_OR_DS_TO_DATE_STR="tsOrDsToDateStr",l.TS_OR_DS_TO_TIME="tsOrDsToTime",l.TS_OR_DS_TO_TIMESTAMP="tsOrDsToTimestamp",l.TUPLE="tuple",l.TYPE="type",l.TYPEOF="typeof",l.UDTF="udtf",l.UNARY="unary",l.UNCACHE="uncache",l.UNHEX="unhex",l.UNICODE="unicode",l.UNICODE_STRING="unicodeString",l.UNIFORM="uniform",l.UNION="union",l.UNIQUE_COLUMN_CONSTRAINT="uniqueColumnConstraint",l.UNIQUE_KEY_PROPERTY="uniqueKeyProperty",l.UNIX_DATE="unixDate",l.UNIX_MICROS="unixMicros",l.UNIX_MILLIS="unixMillis",l.UNIX_SECONDS="unixSeconds",l.UNIX_TO_STR="unixToStr",l.UNIX_TO_TIME="unixToTime",l.UNIX_TO_TIME_STR="unixToTimeStr",l.UNLOGGED_PROPERTY="unloggedProperty",l.UNNEST="unnest",l.UNPIVOT_COLUMNS="unpivotColumns",l.UPDATE="update",l.UPPER="upper",l.UPPERCASE_COLUMN_CONSTRAINT="uppercaseColumnConstraint",l.USE="use",l.USER_DEFINED_FUNCTION="userDefinedFunction",l.USING_DATA="usingData",l.USING_TEMPLATE_PROPERTY="usingTemplateProperty",l.UTC_DATE="utcDate",l.UTC_TIME="utcTime",l.UTC_TIMESTAMP="utcTimestamp",l.UUID="uuid",l.VALUES="values",l.VAR="var",l.VARIADIC="variadic",l.VARIANCE="variance",l.VARIANCE_POP="variancePop",l.VAR_MAP="varMap",l.VECTOR_SEARCH="vectorSearch",l.UUID_PROPERTY="uuidProperty",l.VERSION="version",l.VIEW_ATTRIBUTE_PROPERTY="viewAttributeProperty",l.VOLATILE_PROPERTY="volatileProperty",l.WATERMARK_COLUMN_CONSTRAINT="watermarkColumnConstraint",l.WEEK="week",l.WEEK_OF_YEAR="weekOfYear",l.WEEK_START="weekStart",l.WHEN="when",l.WHENS="whens",l.WHERE="where",l.WIDTH_BUCKET="widthBucket",l.WINDOW="window",l.WINDOW_SPEC="windowSpec",l.WITH="with",l.WITHIN_GROUP="withinGroup",l.WITH_DATA_PROPERTY="withDataProperty",l.WITH_FILL="withFill",l.WITH_JOURNAL_TABLE_PROPERTY="withJournalTableProperty",l.WITH_OPERATOR="withOperator",l.WITH_PROCEDURE_OPTIONS="withProcedureOptions",l.WITH_SCHEMA_BINDING_PROPERTY="withSchemaBindingProperty",l.WHILE_BLOCK="whileBlock",l.WITH_SYSTEM_VERSIONING_PROPERTY="withSystemVersioningProperty",l.WITH_TABLE_HINT="withTableHint",l.XML_ELEMENT="xmlElement",l.XML_GET="xmlGet",l.XML_KEY_VALUE_OPTION="xmlKeyValueOption",l.XML_NAMESPACE="xmlNamespace",l.XML_TABLE="xmlTable",l.XOR="xor",l.YEAR="year",l.YEAR_OF_WEEK="yearOfWeek",l.YEAR_OF_WEEK_ISO="yearOfWeekIso",l.ZERO_FILL_COLUMN_CONSTRAINT="zeroFillColumnConstraint",l.ZIPF="zipf",l))(YI||{}),dG=(t=>(t.INCREMENTAL="incremental",t.FULL="full",t))(dG||{}),eA=(h=>(h.TABLE="table",h.VIEW="view",h.INDEX="index",h.SCHEMA="schema",h.DATABASE="database",h.FUNCTION="function",h.PROCEDURE="procedure",h.TRIGGER="trigger",h.SEQUENCE="sequence",h.TEMPORARY_VIEW="temporary view",h))(eA||{}),xG=(i=>(i.TABLE="table",i.VIEW="view",i.SCHEMA="schema",i.FUNCTION="function",i.PROCEDURE="procedure",i))(xG||{}),fG=(t=>(t.CONNECTION="connection",t.QUERY="query",t))(fG||{}),TG=(r=>(r.CURSOR="cursor",r.VARIABLE="variable",r.TABLE="table",r.CONSTANT="constant",r))(TG||{}),SG=(i=>(i.SESSION="session",i.GLOBAL="global",i.LOCAL="local",i.PERSIST="persist",i.PERSIST_ONLY="persistOnly",i))(SG||{}),RG=(t=>(t.BREADTH="breadth",t.DEPTH="depth",t))(RG||{}),OG=(r=>(r.GENERATED="generated",r.STORED="stored",r.VIRTUAL="virtual",r.DEFAULT="default",r))(OG||{}),mG=(s=>(s.TABLE="table",s.COLUMN="column",s.VIEW="view",s))(mG||{}),NG=(o=>(o.PRIMARY_KEY="primaryKey",o.UNIQUE="unique",o.NOT_NULL="notNull",o.CHECK="check",o.DEFAULT="default",o.FOREIGN_KEY="foreignKey",o))(NG||{}),AM=(g=>(g.TABLE="table",g.VIEW="view",g.INDEX="index",g.SCHEMA="schema",g.DATABASE="database",g.FUNCTION="function",g.PROCEDURE="procedure",g.TRIGGER="trigger",g.SEQUENCE="sequence",g.CONSTRAINT="constraint",g.COLUMN="column",g))(AM||{}),IG=(t=>(t.CONDITIONAL="conditional",t.UNCONDITIONAL="unconditional",t))(IG||{}),yG=(t=>(t.GRANT="grant",t.REVOKE="revoke",t))(yG||{}),Vt=(x=>(x.INNER="inner",x.OUTER="outer",x.LEFT="left",x.RIGHT="right",x.FULL="full",x.CROSS="cross",x.SEMI="semi",x.ANTI="anti",x.ANY="any",x.ASOF="asof",x.STRAIGHT_JOIN="straightJoin",x.ARRAY="array",x))(Vt||{}),CG=(r=>(r.USER="user",r.ROLE="role",r.GROUP="group",r.PUBLIC="public",r))(CG||{}),bG=(t=>(t.SYSTEM_TIME="systemTime",t.TRANSACTION_TIME="transactionTime",t))(bG||{}),PG=(s=>(s.ROWS="rows",s.RANGE="range",s.GROUPS="groups",s))(PG||{}),At=(P=>(P.ARRAY="array",P.AGGREGATEFUNCTION="aggregatefunction",P.SIMPLEAGGREGATEFUNCTION="simpleaggregatefunction",P.BIGDECIMAL="bigdecimal",P.BIGINT="bigint",P.BIGNUM="bignum",P.BIGSERIAL="bigserial",P.BINARY="binary",P.BIT="bit",P.BLOB="blob",P.BOOLEAN="boolean",P.BPCHAR="bpchar",P.CHAR="char",P.DATE="date",P.DATE32="date32",P.DATEMULTIRANGE="datemultirange",P.DATERANGE="daterange",P.DATETIME="datetime",P.DATETIME2="datetime2",P.DATETIME64="datetime64",P.DECIMAL="decimal",P.DECIMAL32="decimal32",P.DECIMAL64="decimal64",P.DECIMAL128="decimal128",P.DECIMAL256="decimal256",P.DECFLOAT="decfloat",P.DOUBLE="double",P.DYNAMIC="dynamic",P.ENUM="enum",P.ENUM8="enum8",P.ENUM16="enum16",P.FILE="file",P.FIXEDSTRING="fixedstring",P.FLOAT="float",P.GEOGRAPHY="geography",P.GEOGRAPHYPOINT="geographypoint",P.GEOMETRY="geometry",P.POINT="point",P.RING="ring",P.LINESTRING="linestring",P.MULTILINESTRING="multilinestring",P.POLYGON="polygon",P.MULTIPOLYGON="multipolygon",P.HLLSKETCH="hllsketch",P.HSTORE="hstore",P.IMAGE="image",P.INET="inet",P.INT="int",P.INT128="int128",P.INT256="int256",P.INT4MULTIRANGE="int4multirange",P.INT4RANGE="int4range",P.INT8MULTIRANGE="int8multirange",P.INT8RANGE="int8range",P.INTERVAL="interval",P.IPADDRESS="ipaddress",P.IPPREFIX="ipprefix",P.IPV4="ipv4",P.IPV6="ipv6",P.JSON="json",P.JSONB="jsonb",P.LIST="list",P.LONGBLOB="longblob",P.LONGTEXT="longtext",P.LOWCARDINALITY="lowcardinality",P.MAP="map",P.MEDIUMBLOB="mediumblob",P.MEDIUMINT="mediumint",P.MEDIUMTEXT="mediumtext",P.MONEY="money",P.NAME="name",P.NCHAR="nchar",P.NESTED="nested",P.NOTHING="nothing",P.NULL="null",P.NUMMULTIRANGE="nummultirange",P.NUMRANGE="numrange",P.NVARCHAR="nvarchar",P.OBJECT="object",P.RANGE="range",P.ROWVERSION="rowversion",P.SERIAL="serial",P.SET="set",P.SMALLDATETIME="smalldatetime",P.SMALLINT="smallint",P.SMALLMONEY="smallmoney",P.SMALLSERIAL="smallserial",P.STRUCT="struct",P.SUPER="super",P.TEXT="text",P.TINYBLOB="tinyblob",P.TINYTEXT="tinytext",P.TIME="time",P.TIMETZ="timetz",P.TIME_NS="timeNs",P.TIMESTAMP="timestamp",P.TIMESTAMPNTZ="timestampntz",P.TIMESTAMPLTZ="timestampltz",P.TIMESTAMPTZ="timestamptz",P.TIMESTAMP_S="timestampS",P.TIMESTAMP_MS="timestampMs",P.TIMESTAMP_NS="timestampNs",P.TINYINT="tinyint",P.TSMULTIRANGE="tsmultirange",P.TSRANGE="tsrange",P.TSTZMULTIRANGE="tstzmultirange",P.TSTZRANGE="tstzrange",P.UBIGINT="ubigint",P.UINT="uint",P.UINT128="uint128",P.UINT256="uint256",P.UMEDIUMINT="umediumint",P.UDECIMAL="udecimal",P.UDOUBLE="udouble",P.UNION="union",P.UNKNOWN="unknown",P.USERDEFINED="user-defined",P.USMALLINT="usmallint",P.UTINYINT="utinyint",P.UUID="uuid",P.VARBINARY="varbinary",P.VARCHAR="varchar",P.VARIANT="variant",P.VECTOR="vector",P.XML="xml",P.YEAR="year",P.TDIGEST="tdigest",P))(At||{}),VI=(o=>(o.TABLE="table",o.VIEW="view",o.SCHEMA="schema",o.DATABASE="database",o.INDEX="index",o.COLUMN="column",o))(VI||{}),LG=(s=>(s.STATISTICS="statistics",s.COMPUTE="compute",s.TABLE="table",s))(LG||{}),wG=(s=>(s.ALL="all",s.DEFAULT="default",s.COLUMNS="columns",s))(wG||{}),MG=(t=>(t.PERCENT="percent",t.ROWS="rows",t))(MG||{}),kG=(e=>(e.STATISTICS="statistics",e))(kG||{}),DG=(t=>(t.REF_UPDATE="refUpdate",t.STRUCTURE="structure",t))(DG||{}),qG=(r=>(r.PATH="path",r.EXISTS="exists",r.VALUE="value",r.QUERY="query",r))(qG||{}),UG=(r=>(r.PATH="path",r.EXISTS="exists",r.VALUE="value",r.QUERY="query",r))(UG||{}),vG=(i=>(i.DATABASE="database",i.SCHEMA="schema",i.WAREHOUSE="warehouse",i.ROLE="role",i.CATALOG="catalog",i))(vG||{}),FG=(r=>(r.PRIMARY="primary",r.UNIQUE="unique",r.FULLTEXT="fulltext",r.SPATIAL="spatial",r))(FG||{}),BG=(t=>(t.LOCAL="local",t.REMOTE="remote",t))(BG||{}),$G=(r=>(r.HASH="hash",r.RANGE="range",r.LIST="list",r.REPLICATE="replicate",r))($G||{}),GG=(c=>(c.FLAT="flat",c.HASHED="hashed",c.RANGE_HASHED="rangeHashed",c.CACHE="cache",c.DIRECT="direct",c.IP_TRIE="ipTrie",c.POLYGON="polygon",c))(GG||{}),YG=(r=>(r.DEFAULT="default",r.ALL="all",r.FALLBACK="fallback",r.LOCKING="locking",r))(YG||{}),VG=(r=>(r.ON_COMMIT="onCommit",r.ON_DEMAND="onDemand",r.START_WITH="startWith",r.NEXT="next",r))(VG||{}),tD=(p=>(p.POST_CREATE="postCreate",p.POST_NAME="postName",p.POST_SCHEMA="postSchema",p.POST_WITH="postWith",p.POST_ALIAS="postAlias",p.POST_EXPRESSION="postExpression",p.POST_INDEX="postIndex",p.UNSUPPORTED="unsupported",p))(tD||{}),dM=(i=>(i.UNION="union",i.INTERSECT="intersect",i.EXCEPT="except",i.INNER="inner",i.OUTER="outer",i))(dM||{}),HG=(i=>(i.STRUCT="struct",i.VALUE="value",i.OBJECT="object",i.ALL="all",i.DISTINCT="distinct",i))(HG||{}),_G=(r=>(r.SESSION="session",r.GLOBAL="global",r.LOCAL="local",r.VARIABLE="variable",r))(_G||{}),WG=(i=>(i.POSITIONAL="positional",i.NAMED="named",i.QUESTION="question",i.NUMERIC="numeric",i.DOLLAR="dollar",i))(WG||{}),jG=(t=>(t.START="start",t.END="end",t))(jG||{}),sD=(s=>(s.LEADING="leading",s.TRAILING="trailing",s.BOTH="both",s))(sD||{});var VD={};j_(VD,{ALL_FUNCTIONS:()=>ry,AbsExpr:()=>aP,AcosExpr:()=>Wb,AcoshExpr:()=>jb,AddConstraintExpr:()=>IA,AddExpr:()=>we,AddMonthsExpr:()=>vF,AddPartitionExpr:()=>AC,AdjacentExpr:()=>ph,AggFuncExpr:()=>D,AiAggExpr:()=>u$,AiClassifyExpr:()=>yU,AiSummarizeAggExpr:()=>h$,AlgorithmPropertyExpr:()=>Wn,AliasExpr:()=>Oe,AliasesExpr:()=>Hn,AllExpr:()=>cs,AllowedValuesPropertyExpr:()=>Vn,AlterColumnExpr:()=>ms,AlterDistStyleExpr:()=>SA,AlterExpr:()=>lu,AlterExprKind:()=>VI,AlterIndexExpr:()=>KD,AlterModifySqlSecurityExpr:()=>eq,AlterRenameExpr:()=>Yn,AlterSessionExpr:()=>mA,AlterSetExpr:()=>Ry,AlterSortKeyExpr:()=>RA,AnalyzeColumnsExpr:()=>hu,AnalyzeDeleteExpr:()=>gC,AnalyzeDeleteExprKind:()=>kG,AnalyzeExpr:()=>NA,AnalyzeExprKind:()=>LG,AnalyzeHistogramExpr:()=>lC,AnalyzeListChainedRowsExpr:()=>hC,AnalyzeSampleExpr:()=>uC,AnalyzeSampleExprKind:()=>MG,AnalyzeStatisticsExpr:()=>pC,AnalyzeStatisticsExprKind:()=>wG,AnalyzeValidateExpr:()=>EC,AnalyzeValidateExprKind:()=>DG,AnalyzeWithExpr:()=>uu,AndExpr:()=>Te,AnonymousAggFuncExpr:()=>GM,AnonymousExpr:()=>Qe,AnyExpr:()=>Tt,AnyValueExpr:()=>qL,ApiPropertyExpr:()=>zA,ApplicationPropertyExpr:()=>QA,ApplyExpr:()=>gU,ApproxDistinctExpr:()=>ML,ApproxPercentileAccumulateExpr:()=>b$,ApproxPercentileCombineExpr:()=>t$,ApproxPercentileEstimateExpr:()=>XF,ApproxQuantileExpr:()=>wh,ApproxQuantilesExpr:()=>e$,ApproxTopKAccumulateExpr:()=>QB,ApproxTopKCombineExpr:()=>ZB,ApproxTopKEstimateExpr:()=>oU,ApproxTopKExpr:()=>zB,ApproxTopSumExpr:()=>KB,ApproximateSimilarityExpr:()=>i$,ArgMaxExpr:()=>qA,ArgMinExpr:()=>UA,ArrayAggExpr:()=>Bn,ArrayAllExpr:()=>CU,ArrayAnyExpr:()=>bU,ArrayAppendExpr:()=>sb,ArrayCompactExpr:()=>PU,ArrayConcatAggExpr:()=>kL,ArrayConcatExpr:()=>hh,ArrayConstructCompactExpr:()=>UU,ArrayContainsAllExpr:()=>Fn,ArrayContainsExpr:()=>lP,ArrayDistinctExpr:()=>LU,ArrayExceptExpr:()=>wU,ArrayExpr:()=>ue,ArrayFilterExpr:()=>Va,ArrayFirstExpr:()=>uP,ArrayInsertExpr:()=>DU,ArrayIntersectExpr:()=>MA,ArrayLastExpr:()=>hP,ArrayMaxExpr:()=>MU,ArrayMinExpr:()=>kU,ArrayOverlapsExpr:()=>Fb,ArrayPositionExpr:()=>vU,ArrayPrependExpr:()=>rb,ArrayRemoveAtExpr:()=>qU,ArrayRemoveExpr:()=>uh,ArrayReverseExpr:()=>gP,ArraySizeExpr:()=>Rr,ArraySliceExpr:()=>EP,ArraySortExpr:()=>GU,ArraySumExpr:()=>YU,ArrayToStringExpr:()=>AP,ArrayUnionAggExpr:()=>g$,ArrayUniqueAggExpr:()=>l$,ArraysZipExpr:()=>VU,AsciiExpr:()=>cP,AsinExpr:()=>Xb,AsinhExpr:()=>Jb,AssumeColumnConstraintExpr:()=>Mb,AtIndexExpr:()=>xC,AtTimeZoneExpr:()=>gs,Atan2Expr:()=>Gq,AtanExpr:()=>zb,AtanhExpr:()=>Qb,AttachExpr:()=>WD,AttachOptionExpr:()=>fq,AutoIncrementColumnConstraintExpr:()=>kC,AutoIncrementPropertyExpr:()=>jn,AutoRefreshPropertyExpr:()=>Xn,AvgExpr:()=>DL,BackupPropertyExpr:()=>Jn,Base64DecodeBinaryExpr:()=>Dv,Base64DecodeStringExpr:()=>qv,Base64EncodeExpr:()=>Uv,BetweenExpr:()=>Ss,BinaryExpr:()=>v,BitLengthExpr:()=>eL,BitStringExpr:()=>LC,BitmapBitPositionExpr:()=>tU,BitmapBucketNumberExpr:()=>Kq,BitmapConstructAggExpr:()=>XB,BitmapCountExpr:()=>eU,BitmapOrAggExpr:()=>JB,BitwiseAndAggExpr:()=>HB,BitwiseAndExpr:()=>rh,BitwiseCountExpr:()=>Zq,BitwiseLeftShiftExpr:()=>jC,BitwiseNotExpr:()=>lh,BitwiseOrAggExpr:()=>_B,BitwiseOrExpr:()=>XC,BitwiseRightShiftExpr:()=>ih,BitwiseXorAggExpr:()=>WB,BitwiseXorExpr:()=>JC,BlockCompressionPropertyExpr:()=>qu,BlockExpr:()=>GA,BoolandExpr:()=>iU,BooleanExpr:()=>at,BoolnotExpr:()=>rU,BoolorExpr:()=>nU,BoolxorAggExpr:()=>jB,BracketExpr:()=>wt,BuildPropertyExpr:()=>Mq,ByteLengthExpr:()=>sU,ByteStringExpr:()=>wC,COLUMN_PARTS:()=>U_,CONSTANTS:()=>dD,CacheExpr:()=>ny,CaseExpr:()=>ut,CaseSpecificColumnConstraintExpr:()=>kn,CastExpr:()=>z,CastToStrTypeExpr:()=>ib,CatalogPropertyExpr:()=>ZA,CbrtExpr:()=>Ah,CeilExpr:()=>ti,ChangesExpr:()=>Iy,CharacterSetColumnConstraintExpr:()=>fu,CharacterSetExpr:()=>TA,CharacterSetPropertyExpr:()=>zr,CheckColumnConstraintExpr:()=>qC,CheckExpr:()=>iq,CheckJsonExpr:()=>_U,CheckXmlExpr:()=>WU,ChecksumPropertyExpr:()=>Uu,ChrExpr:()=>gh,CityHash64Expr:()=>cU,CloneExpr:()=>hy,ClusterExpr:()=>rr,ClusteredByPropertyExpr:()=>Ea,ClusteredColumnConstraintExpr:()=>Tu,CoalesceExpr:()=>tt,CodePointsToBytesExpr:()=>OU,CodePointsToStringExpr:()=>NU,CollateColumnConstraintExpr:()=>Su,CollateExpr:()=>kA,CollatePropertyExpr:()=>zn,CollationExpr:()=>jU,ColumnConstraintExpr:()=>yn,ColumnConstraintExprKind:()=>NG,ColumnConstraintKindExpr:()=>ce,ColumnDefExpr:()=>Pe,ColumnDefExprKind:()=>OG,ColumnExpr:()=>$,ColumnPositionExpr:()=>Sy,ColumnPrefixExpr:()=>aq,ColumnsExpr:()=>tb,CombinedAggFuncExpr:()=>H$,CombinedParameterizedAggExpr:()=>_$,CommandExpr:()=>$r,CommentColumnConstraintExpr:()=>Ru,CommentExpr:()=>Oy,CommentExprKind:()=>mG,CommitExpr:()=>oC,ComprehensionExpr:()=>my,CompressColumnConstraintExpr:()=>PA,CompressExpr:()=>jv,ComputePropertyExpr:()=>KA,ComputedColumnConstraintExpr:()=>Dn,ConcatExpr:()=>$t,ConcatWsExpr:()=>Wt,ConditionExpr:()=>be,ConditionalInsertExpr:()=>Dy,ConnectByRootExpr:()=>Eh,ConnectExpr:()=>yy,ConnectorExpr:()=>Ae,ConstraintExpr:()=>Ny,ContainsExpr:()=>SP,ConvertExpr:()=>mU,ConvertTimezoneExpr:()=>vn,ConvertToCharsetExpr:()=>vb,CopyExpr:()=>BC,CopyExprKind:()=>BG,CopyGrantsPropertyExpr:()=>Qn,CopyParameterExpr:()=>Cy,CorrExpr:()=>BB,CosExpr:()=>Kb,CoshExpr:()=>nP,CosineDistanceExpr:()=>jq,CotExpr:()=>Zb,CothExpr:()=>Yq,CountExpr:()=>bh,CountIfExpr:()=>vL,CovarPopExpr:()=>V$,CovarSampExpr:()=>Y$,CreateExpr:()=>ss,CreateExprKind:()=>eA,CredentialsExpr:()=>by,CredentialsPropertyExpr:()=>ld,CscExpr:()=>Vq,CschExpr:()=>Hq,CteExpr:()=>Bt,CubeExpr:()=>Vy,CumeDistExpr:()=>G$,CurrentAccountExpr:()=>XU,CurrentAccountNameExpr:()=>JU,CurrentAvailableRolesExpr:()=>zU,CurrentCatalogExpr:()=>Mh,CurrentClientExpr:()=>QU,CurrentDatabaseExpr:()=>KU,CurrentDateExpr:()=>pr,CurrentDatetimeExpr:()=>OP,CurrentIpAddressExpr:()=>ZU,CurrentOrganizationNameExpr:()=>cv,CurrentOrganizationUserExpr:()=>uv,CurrentRegionExpr:()=>pv,CurrentRoleExpr:()=>ab,CurrentRoleTypeExpr:()=>lv,CurrentSchemaExpr:()=>NP,CurrentSchemasExpr:()=>ev,CurrentSecondaryRolesExpr:()=>tv,CurrentSessionExpr:()=>sv,CurrentStatementExpr:()=>rv,CurrentTimeExpr:()=>si,CurrentTimestampExpr:()=>ri,CurrentTimestampLtzExpr:()=>mP,CurrentTimezoneExpr:()=>ov,CurrentTransactionExpr:()=>iv,CurrentUserExpr:()=>xh,CurrentVersionExpr:()=>RP,CurrentWarehouseExpr:()=>nv,DPipeExpr:()=>jt,DataBlocksizePropertyExpr:()=>vu,DataDeletionPropertyExpr:()=>Fu,DataTypeExpr:()=>N,DataTypeExprKind:()=>At,DataTypeParamExpr:()=>Jr,DatabasePropertyExpr:()=>ed,DateAddExpr:()=>ft,DateBinExpr:()=>hv,DateDiffExpr:()=>_s,DateExpr:()=>pi,DateFormatColumnConstraintExpr:()=>Ou,DateFromPartsExpr:()=>BP,DateFromUnixDateExpr:()=>Ev,DateStrToDateExpr:()=>$P,DateSubExpr:()=>Xt,DateToDateStrExpr:()=>GP,DateToDiExpr:()=>YP,DateTruncExpr:()=>ls,DatetimeAddExpr:()=>Ds,DatetimeDiffExpr:()=>yP,DatetimeExpr:()=>IP,DatetimeSubExpr:()=>Qs,DatetimeTruncExpr:()=>gv,DayExpr:()=>Nr,DayOfMonthExpr:()=>PP,DayOfWeekExpr:()=>CP,DayOfWeekIsoExpr:()=>bP,DayOfYearExpr:()=>LP,DaynameExpr:()=>wP,DdlExpr:()=>dn,DeclareExpr:()=>dy,DeclareItemExpr:()=>xy,DeclareItemExprKind:()=>TG,DecodeCaseExpr:()=>cb,DecodeExpr:()=>ob,DecompressBinaryExpr:()=>Xv,DecompressStringExpr:()=>Jv,DecryptExpr:()=>yv,DecryptRawExpr:()=>Cv,DefaultColumnConstraintExpr:()=>mu,DefinerPropertyExpr:()=>Zn,DegreesExpr:()=>iP,DeleteExpr:()=>Gr,DenseRankExpr:()=>R$,DerivedTableExpr:()=>An,DescribeExpr:()=>Ql,DescribeExprKind:()=>xG,DetachExpr:()=>jD,DiToDateExpr:()=>VP,DictPropertyExpr:()=>Hu,DictPropertyExprKind:()=>GG,DictRangeExpr:()=>_u,DictSubPropertyExpr:()=>GC,DirectoryExpr:()=>su,DirectoryStageExpr:()=>nq,DistKeyPropertyExpr:()=>Kn,DistStylePropertyExpr:()=>ta,DistanceExpr:()=>QC,DistinctExpr:()=>et,DistributeExpr:()=>$C,DistributedByPropertyExpr:()=>ea,DistributedByPropertyExprKind:()=>$G,DivExpr:()=>Mt,DmlExpr:()=>bs,DotExpr:()=>ge,DotProductExpr:()=>Xq,DropExpr:()=>tu,DropExprKind:()=>AM,DropPartitionExpr:()=>dC,DuplicateKeyPropertyExpr:()=>Bu,DynamicPropertyExpr:()=>Aa,EltExpr:()=>Ov,EmptyPropertyExpr:()=>da,EncodeColumnConstraintExpr:()=>Nu,EncodeExpr:()=>bv,EncodePropertyExpr:()=>hd,EncryptExpr:()=>Pv,EncryptRawExpr:()=>Lv,EndStatementExpr:()=>du,EndsWithExpr:()=>EL,EnginePropertyExpr:()=>sa,EnviromentPropertyExpr:()=>ga,EphemeralColumnConstraintExpr:()=>yu,EqExpr:()=>Me,EqualNullExpr:()=>wv,EscapeExpr:()=>Ba,EuclideanDistanceExpr:()=>Jq,ExceptExpr:()=>cr,ExcludeColumnConstraintExpr:()=>Iu,ExecuteAsPropertyExpr:()=>nr,ExecuteExpr:()=>BM,ExecuteSqlExpr:()=>Pq,ExistsExpr:()=>Ys,ExpExpr:()=>HP,ExplodeExpr:()=>Jt,ExplodeOuterExpr:()=>WA,ExplodingGenerateSeriesExpr:()=>p$,ExportExpr:()=>rq,Expression:()=>d,ExpressionKey:()=>YI,ExtendsLeftExpr:()=>nh,ExtendsRightExpr:()=>ah,ExternalPropertyExpr:()=>oa,ExtractExpr:()=>lr,FUNCTION_BY_NAME:()=>jl,FactorialExpr:()=>Mv,FallbackPropertyExpr:()=>$u,FarmFingerprintExpr:()=>pU,FeaturesAtTimeExpr:()=>HF,FetchExpr:()=>hr,FileFormatPropertyExpr:()=>ir,FilterExpr:()=>Xr,FinalExpr:()=>_I,FirstExpr:()=>d$,FirstValueExpr:()=>f$,FlattenExpr:()=>lU,Float64Expr:()=>uU,FloorExpr:()=>fh,ForInExpr:()=>Oq,ForcePropertyExpr:()=>cd,ForeignKeyExpr:()=>Ly,FormatExpr:()=>Kv,FormatJsonExpr:()=>SC,FormatPhraseExpr:()=>Rq,FreespacePropertyExpr:()=>Gu,FromBase32Expr:()=>_P,FromBase64Expr:()=>WP,FromBaseExpr:()=>wB,FromExpr:()=>rt,FromIso8601TimestampExpr:()=>Gv,FromTimeZoneExpr:()=>Sq,FuncExpr:()=>E,GapFillExpr:()=>pb,GenerateDateArrayExpr:()=>ii,GenerateEmbeddingExpr:()=>_F,GenerateSeriesExpr:()=>As,GenerateTimestampArrayExpr:()=>JP,GeneratedAsIdentityColumnConstraintExpr:()=>Jl,GeneratedAsRowColumnConstraintExpr:()=>UC,GeneratorExpr:()=>IU,GetExpr:()=>bb,GetExtractExpr:()=>Yv,GetbitExpr:()=>zP,GlobExpr:()=>wA,GlobalPropertyExpr:()=>ca,GrantExpr:()=>Gy,GrantExprKind:()=>yG,GrantPrincipalExpr:()=>Qy,GrantPrincipalExprKind:()=>CG,GrantPrivilegeExpr:()=>zy,GreatestExpr:()=>ni,GroupConcatExpr:()=>sr,GroupExpr:()=>Yr,GroupingExpr:()=>n$,GroupingIdExpr:()=>a$,GroupingSetsExpr:()=>Hy,GtExpr:()=>je,GteExpr:()=>Je,HandlerPropertyExpr:()=>ra,HashAggExpr:()=>o$,HavingExpr:()=>xs,HavingMaxExpr:()=>gr,HeapPropertyExpr:()=>na,HeredocExpr:()=>fA,HexDecodeStringExpr:()=>Vv,HexEncodeExpr:()=>Hv,HexExpr:()=>$a,HexStringExpr:()=>xu,HintExpr:()=>Ps,HistoricalDataExpr:()=>tC,HistoricalDataExprKind:()=>bG,HllExpr:()=>c$,HostExpr:()=>$F,HourExpr:()=>QP,HybridPropertyExpr:()=>td,ILikeExpr:()=>Gs,INTERVAL_DAY_TIME_RE:()=>yD,INTERVAL_STRING_RE:()=>ID,IcebergPropertyExpr:()=>pa,IdentifierExpr:()=>F,IfBlockExpr:()=>bq,IfExpr:()=>xe,IgnoreNullsExpr:()=>yA,InExpr:()=>lt,InOutColumnConstraintExpr:()=>FC,IncludePropertyExpr:()=>gd,IndexColumnConstraintExpr:()=>Lq,IndexColumnConstraintExprKind:()=>FG,IndexConstraintOptionExpr:()=>tq,IndexExpr:()=>My,IndexParametersExpr:()=>ky,IndexTableHintExpr:()=>eC,InheritsPropertyExpr:()=>la,InitcapExpr:()=>Th,InlineExpr:()=>Ib,InlineLengthColumnConstraintExpr:()=>Cu,InputModelPropertyExpr:()=>ua,InputOutputFormatExpr:()=>Zy,InsertExpr:()=>es,InstallExpr:()=>XD,Int64Expr:()=>Uh,IntDivExpr:()=>Un,IntersectExpr:()=>ei,IntervalExpr:()=>qe,IntervalOpExpr:()=>Zs,IntervalSpanExpr:()=>Wr,IntoExpr:()=>iu,IntroducerExpr:()=>vy,IsArrayExpr:()=>Zv,IsAsciiExpr:()=>zv,IsExpr:()=>ze,IsInfExpr:()=>KP,IsNanExpr:()=>ZP,IsNullValueExpr:()=>Qv,IsolatedLoadingPropertyExpr:()=>Yu,JSON_PATH_PARTS:()=>Hj,JarowinklerSimilarityExpr:()=>Qq,JoinExpr:()=>fe,JoinExprKind:()=>Vt,JoinHintExpr:()=>gn,JournalPropertyExpr:()=>Vu,JsonArrayAggExpr:()=>m$,JsonArrayAppendExpr:()=>gF,JsonArrayContainsExpr:()=>EF,JsonArrayExpr:()=>tF,JsonArrayInsertExpr:()=>AF,JsonBoolExpr:()=>aU,JsonCastExpr:()=>mb,JsonColumnDefExpr:()=>OC,JsonColumnDefExprKind:()=>qG,JsonExistsExpr:()=>sF,JsonExpr:()=>TC,JsonExtractArrayExpr:()=>uF,JsonExtractExpr:()=>Ns,JsonExtractQuoteExpr:()=>Nq,JsonExtractScalarExpr:()=>bn,JsonFormatExpr:()=>hF,JsonKeyValueExpr:()=>RC,JsonKeysAtDepthExpr:()=>eF,JsonKeysExpr:()=>lb,JsonObjectAggExpr:()=>Nb,JsonObjectExpr:()=>Sh,JsonPathExpr:()=>Er,JsonPathFilterExpr:()=>Vs,JsonPathKeyExpr:()=>kt,JsonPathPartExpr:()=>Ut,JsonPathRecursiveExpr:()=>fr,JsonPathRootExpr:()=>Qt,JsonPathScriptExpr:()=>Hs,JsonPathSelectorExpr:()=>ci,JsonPathSliceExpr:()=>Tr,JsonPathSubscriptExpr:()=>ts,JsonPathUnionExpr:()=>Sr,JsonPathWildcardExpr:()=>qt,JsonRemoveExpr:()=>aF,JsonSchemaExpr:()=>mC,JsonSetExpr:()=>rF,JsonStripNullsExpr:()=>iF,JsonTableExpr:()=>ub,JsonTypeExpr:()=>oF,JsonValueArrayExpr:()=>nF,JsonValueExpr:()=>NC,JsonbContainsAllTopKeysExpr:()=>Oh,JsonbContainsAnyTopKeysExpr:()=>Rh,JsonbContainsExpr:()=>gb,JsonbDeleteAtPathExpr:()=>mh,JsonbExistsExpr:()=>lF,JsonbExtractExpr:()=>Nh,JsonbExtractScalarExpr:()=>Eb,JsonbObjectAggExpr:()=>O$,JustifyDaysExpr:()=>xP,JustifyHoursExpr:()=>fP,JustifyIntervalExpr:()=>TP,KillExpr:()=>Ey,KillExprKind:()=>fG,KurtosisExpr:()=>XL,KwargExpr:()=>oh,LagExpr:()=>E$,LambdaExpr:()=>ps,LanguagePropertyExpr:()=>Qr,LastDayExpr:()=>_a,LastExpr:()=>x$,LastValueExpr:()=>UL,LateralExpr:()=>bt,LaxBoolExpr:()=>fv,LaxFloat64Expr:()=>Tv,LaxInt64Expr:()=>Sv,LaxStringExpr:()=>Rv,LeadExpr:()=>A$,LeastExpr:()=>Ih,LeftExpr:()=>OF,LengthExpr:()=>$h,LevenshteinExpr:()=>tL,LikeExpr:()=>Zt,LikePropertyExpr:()=>Wu,LimitExpr:()=>Dt,LimitOptionsExpr:()=>_y,ListExpr:()=>KC,LiteralExpr:()=>I,LnExpr:()=>yh,LoadDataExpr:()=>By,LocaltimeExpr:()=>dh,LocaltimestampExpr:()=>nb,LocationExpr:()=>Eq,LocationPropertyExpr:()=>Zr,LockExpr:()=>$A,LockPropertyExpr:()=>ud,LockingPropertyExpr:()=>ju,LockingPropertyExprKind:()=>YG,LockingStatementExpr:()=>_D,LogExpr:()=>ur,LogPropertyExpr:()=>xa,LogicalAndExpr:()=>BL,LogicalOrExpr:()=>FL,LowerExpr:()=>Ar,LowerHexExpr:()=>Ph,LtExpr:()=>Fe,LteExpr:()=>nt,MakeIntervalExpr:()=>qP,ManhattanDistanceExpr:()=>zq,MapCatExpr:()=>CF,MapContainsKeyExpr:()=>bF,MapDeleteExpr:()=>PF,MapExpr:()=>mn,MapFromEntriesExpr:()=>yF,MapInsertExpr:()=>LF,MapKeysExpr:()=>wF,MapPickExpr:()=>MF,MapSizeExpr:()=>kF,MaskingPolicyColumnConstraintExpr:()=>wq,MaskingPropertyExpr:()=>sd,MatchAgainstExpr:()=>db,MatchExpr:()=>Fq,MatchRecognizeExpr:()=>jy,MatchRecognizeMeasureExpr:()=>Wy,MaterializedPropertyExpr:()=>fa,MaxExpr:()=>$L,Md5DigestExpr:()=>DF,Md5Expr:()=>sL,Md5NumberLower64Expr:()=>qF,Md5NumberUpper64Expr:()=>UF,MedianExpr:()=>N$,MergeBlockRatioPropertyExpr:()=>qn,MergeExpr:()=>YA,MergeTreeTtlActionExpr:()=>In,MergeTreeTtlExpr:()=>Pn,MinExpr:()=>GL,MinhashCombineExpr:()=>r$,MinhashExpr:()=>s$,MinuteExpr:()=>_v,MlForecastExpr:()=>WF,MlTranslateExpr:()=>VF,ModExpr:()=>jr,ModeExpr:()=>I$,ModelAttributeExpr:()=>Iq,ModifyColumnExpr:()=>ZD,MonthExpr:()=>rL,MonthnameExpr:()=>iL,MonthsBetweenExpr:()=>dv,MulExpr:()=>Ts,MultitableInsertsExpr:()=>nu,MultitableInsertsExprKind:()=>IG,NONNULL_CONSTANTS:()=>AD,NationalExpr:()=>Fy,NegExpr:()=>Pt,NeqExpr:()=>xt,NestedJsonSelectExpr:()=>Bq,NetFuncExpr:()=>Yb,NetworkPropertyExpr:()=>rd,NextDayExpr:()=>GB,NextValueForExpr:()=>Ob,NoPrimaryIndexPropertyExpr:()=>Ta,NonClusteredColumnConstraintExpr:()=>bu,NormalExpr:()=>BF,NormalizeExpr:()=>xb,NotExpr:()=>Le,NotForReplicationColumnConstraintExpr:()=>Pu,NotNullColumnConstraintExpr:()=>LA,NthValueExpr:()=>T$,NtileExpr:()=>y$,NullExpr:()=>Lt,NullSafeEqExpr:()=>Ks,NullSafeNeqExpr:()=>Ur,NullifExpr:()=>qh,NumberToStrExpr:()=>LB,Nvl2Expr:()=>FF,ObjectAggExpr:()=>S$,ObjectIdExpr:()=>pF,ObjectIdentifierExpr:()=>_C,ObjectInsertExpr:()=>cF,OffsetExpr:()=>Cn,OnClusterExpr:()=>Dq,OnCommitPropertyExpr:()=>Hr,OnConditionExpr:()=>Uy,OnConflictExpr:()=>qy,OnPropertyExpr:()=>Vr,OnUpdateColumnConstraintExpr:()=>Lu,OpclassExpr:()=>wy,OpenJsonColumnDefExpr:()=>IC,OpenJsonColumnDefExprKind:()=>UG,OpenJsonExpr:()=>hb,OperatorExpr:()=>ch,OrExpr:()=>pt,OrderExpr:()=>ye,OrderedExpr:()=>hs,OutputModelPropertyExpr:()=>ha,OverflowTruncateBehaviorExpr:()=>fC,OverlapsExpr:()=>zC,OverlayExpr:()=>fb,PERCENTILES:()=>MM,POSITION_META_KEYS:()=>v_,PadExpr:()=>eb,ParameterExpr:()=>YC,ParameterStylePropertyExpr:()=>ia,ParameterizedAggExpr:()=>$M,ParenExpr:()=>Re,ParseBignumericExpr:()=>dF,ParseDatetimeExpr:()=>RF,ParseIpExpr:()=>TF,ParseJsonExpr:()=>ai,ParseNumericExpr:()=>xF,ParseTimeExpr:()=>SF,ParseUrlExpr:()=>fF,PartitionBoundSpecExpr:()=>au,PartitionByListPropertyExpr:()=>Uq,PartitionByRangePropertyDynamicExpr:()=>pq,PartitionByRangePropertyExpr:()=>qq,PartitionByTruncateExpr:()=>Ju,PartitionExpr:()=>$y,PartitionIdExpr:()=>cq,PartitionListExpr:()=>uq,PartitionRangeExpr:()=>oq,PartitionedByBucketExpr:()=>Xu,PartitionedByPropertyExpr:()=>Cs,PartitionedOfPropertyExpr:()=>zu,PathColumnConstraintExpr:()=>Du,PercentRankExpr:()=>C$,PercentileContExpr:()=>Ed,PercentileDiscExpr:()=>YM,PeriodForSystemTimeConstraintExpr:()=>DC,PiExpr:()=>nL,PivotAliasExpr:()=>WC,PivotAnyExpr:()=>wn,PivotExpr:()=>Ln,PlaceholderExpr:()=>ar,PlaceholderExprKind:()=>WG,PosexplodeExpr:()=>li,PosexplodeOuterExpr:()=>W$,PositionalColumnExpr:()=>Pb,PowExpr:()=>Gh,PragmaExpr:()=>Ay,PreWhereExpr:()=>nC,PredicateExpr:()=>ke,PredictExpr:()=>YF,PreviousDayExpr:()=>xv,PrimaryKeyColumnConstraintExpr:()=>vC,PrimaryKeyExpr:()=>ru,PriorExpr:()=>Py,ProjectionDefExpr:()=>QD,ProjectionPolicyColumnConstraintExpr:()=>kb,PropertiesExpr:()=>He,PropertiesLocation:()=>tD,PropertyEqExpr:()=>ot,PropertyExpr:()=>w,PseudoTypeExpr:()=>HC,PseudocolumnExpr:()=>WI,PutExpr:()=>XA,QUERY_MODIFIERS:()=>Ij,QualifyExpr:()=>Xs,QuantileExpr:()=>dd,QuarterExpr:()=>aL,QueryBandExpr:()=>JD,QueryExpr:()=>ee,QueryOptionExpr:()=>Aq,QueryTransformExpr:()=>hq,RadiansExpr:()=>oL,RandExpr:()=>vr,RandnExpr:()=>JI,RandstrExpr:()=>JF,RangeBucketExpr:()=>QF,RangeNExpr:()=>zF,RankExpr:()=>P$,RawStringExpr:()=>Mn,ReadCsvExpr:()=>ZF,ReadParquetExpr:()=>KF,RecursiveWithSearchExpr:()=>Ty,RecursiveWithSearchExprKind:()=>RG,ReduceExpr:()=>eB,ReferenceExpr:()=>Ky,RefreshExpr:()=>oy,RefreshExprKind:()=>dG,RefreshTriggerPropertyExpr:()=>qb,RefreshTriggerPropertyExprKind:()=>VG,RegDomainExpr:()=>GF,RegexpCountExpr:()=>aB,RegexpExtractAllExpr:()=>tB,RegexpExtractExpr:()=>ZL,RegexpFullMatchExpr:()=>rB,RegexpILikeExpr:()=>Tb,RegexpInstrExpr:()=>iB,RegexpLikeExpr:()=>Ga,RegexpReplaceExpr:()=>sB,RegexpSplitExpr:()=>nB,RegrAvgxExpr:()=>k$,RegrAvgyExpr:()=>M$,RegrCountExpr:()=>D$,RegrInterceptExpr:()=>q$,RegrR2Expr:()=>U$,RegrSlopeExpr:()=>$$,RegrSxxExpr:()=>v$,RegrSxyExpr:()=>F$,RegrSyyExpr:()=>B$,RegrValxExpr:()=>L$,RegrValyExpr:()=>w$,RemoteWithConnectionModelPropertyExpr:()=>Ra,RenameColumnExpr:()=>FA,RepeatExpr:()=>oB,ReplaceExpr:()=>KL,ReplacePartitionExpr:()=>Tq,RespectNullsExpr:()=>CA,ReturnExpr:()=>ou,ReturningExpr:()=>BA,ReturnsPropertyExpr:()=>Kr,ReverseExpr:()=>NF,RevokeExpr:()=>Yy,RightExpr:()=>mF,RollbackExpr:()=>cC,RollupExpr:()=>OA,RollupIndexExpr:()=>lq,RollupPropertyExpr:()=>Db,RoundExpr:()=>cL,RowAccessPropertyExpr:()=>id,RowFormatDelimitedPropertyExpr:()=>Qu,RowFormatPropertyExpr:()=>ma,RowFormatSerdePropertyExpr:()=>Zu,RowNumberExpr:()=>yb,RtrimmedLengthExpr:()=>IF,SAFE_IDENTIFIER_RE:()=>tw,SQLGLOT_ANONYMOUS:()=>ND,SQLGLOT_META:()=>q_,SafeAddExpr:()=>hB,SafeConvertBytesToStringExpr:()=>dB,SafeDivideExpr:()=>pL,SafeFuncExpr:()=>Ub,SafeMultiplyExpr:()=>gB,SafeNegateExpr:()=>EB,SafeSubtractExpr:()=>AB,SamplePropertyExpr:()=>Na,SchemaCommentPropertyExpr:()=>Ia,SchemaExpr:()=>Rt,ScopeResolutionExpr:()=>bA,SearchExpr:()=>yB,SearchIpExpr:()=>CB,SecExpr:()=>_q,SechExpr:()=>Wq,SecondExpr:()=>Wv,SecurePropertyExpr:()=>La,SecurityIntegrationPropertyExpr:()=>nd,SelectExpr:()=>se,SelectExprKind:()=>HG,SemanticViewExpr:()=>gq,SemicolonExpr:()=>bC,Seq1Expr:()=>cB,Seq2Expr:()=>pB,Seq4Expr:()=>lB,Seq8Expr:()=>uB,SequencePropertiesExpr:()=>Br,SerdePropertiesExpr:()=>Ku,SessionParameterExpr:()=>VC,SessionParameterExprKind:()=>_G,SessionUserExpr:()=>kh,SetConfigPropertyExpr:()=>JA,SetExpr:()=>Zl,SetItemExpr:()=>Xl,SetItemExprKind:()=>SG,SetOperationExpr:()=>Ge,SetOperationExprKind:()=>dM,SetPropertyExpr:()=>_r,SettingsPropertyExpr:()=>Ca,Sha1DigestExpr:()=>xB,Sha2DigestExpr:()=>fB,Sha2Expr:()=>uL,ShaExpr:()=>lL,SharingPropertyExpr:()=>ya,ShowExpr:()=>zD,SignExpr:()=>hL,SimilarToExpr:()=>ZC,SinExpr:()=>eP,SinhExpr:()=>tP,SkewnessExpr:()=>JL,SkipJsonColumnExpr:()=>Jy,SliceExpr:()=>On,SortArrayExpr:()=>gL,SortExpr:()=>zl,SortKeyPropertyExpr:()=>ba,SoundexExpr:()=>TB,SoundexP123Expr:()=>SB,SpaceExpr:()=>AL,SplitExpr:()=>RB,SplitPartExpr:()=>OB,SqlReadWritePropertyExpr:()=>vs,SqlSecurityPropertyExpr:()=>Pa,SqrtExpr:()=>Ch,StDistanceExpr:()=>BU,StPointExpr:()=>FU,StabilityPropertyExpr:()=>Fs,StandardHashExpr:()=>IB,StarExpr:()=>Ne,StarMapExpr:()=>Ab,StartsWithExpr:()=>Vl,StddevExpr:()=>VL,StddevPopExpr:()=>HL,StddevSampExpr:()=>_L,StorageHandlerPropertyExpr:()=>eh,StoredProcedureExpr:()=>Cq,StrPositionExpr:()=>Bs,StrToDateExpr:()=>oi,StrToMapExpr:()=>PB,StrToTimeExpr:()=>ys,StrToUnixExpr:()=>bB,StreamExpr:()=>Eu,StreamingTablePropertyExpr:()=>Sa,StrictPropertyExpr:()=>Oa,StringExpr:()=>dP,StringToArrayExpr:()=>$U,StrtokExpr:()=>mB,StructExpr:()=>Es,StructExtractExpr:()=>MB,StuffExpr:()=>kB,SubExpr:()=>Ce,SubqueryExpr:()=>he,SubqueryPredicateExpr:()=>Us,SubstringExpr:()=>Is,SubstringIndexExpr:()=>NB,SumExpr:()=>YL,SummarizeExpr:()=>gy,SwapTableExpr:()=>Kl,SystimestampExpr:()=>av,TABLE_PARTS:()=>X$,TIMESTAMP_PARTS:()=>yj,TableAliasExpr:()=>pe,TableColumnExpr:()=>Gl,TableExpr:()=>W,TableFromRowsExpr:()=>_l,TableSampleExpr:()=>rC,TagExpr:()=>dq,TagsExpr:()=>ad,TanExpr:()=>sP,TanhExpr:()=>rP,TemporaryPropertyExpr:()=>$s,TimeAddExpr:()=>Bh,TimeDiffExpr:()=>FP,TimeExpr:()=>dL,TimeFromPartsExpr:()=>Iv,TimeSliceExpr:()=>mv,TimeSliceExprKind:()=>jG,TimeStrToDateExpr:()=>fL,TimeStrToTimeExpr:()=>Yh,TimeStrToUnixExpr:()=>qB,TimeSubExpr:()=>vP,TimeToStrExpr:()=>Or,TimeToTimeStrExpr:()=>xL,TimeToUnixExpr:()=>DB,TimeTruncExpr:()=>Nv,TimeUnitExpr:()=>te,TimestampAddExpr:()=>Fh,TimestampDiffExpr:()=>Dh,TimestampExpr:()=>Lh,TimestampFromPartsExpr:()=>vM,TimestampLtzFromPartsExpr:()=>PL,TimestampSubExpr:()=>UP,TimestampTruncExpr:()=>Sn,TimestampTzFromPartsExpr:()=>LL,TitleColumnConstraintExpr:()=>wu,ToArrayExpr:()=>EU,ToBase32Expr:()=>jP,ToBase64Expr:()=>XP,ToBinaryExpr:()=>kv,ToBooleanExpr:()=>AU,ToCharExpr:()=>QL,ToCodePointsExpr:()=>xU,ToDaysExpr:()=>Av,ToDecfloatExpr:()=>TU,ToDoubleExpr:()=>pP,ToFileExpr:()=>RU,ToMapExpr:()=>vh,ToNumberExpr:()=>fU,ToTablePropertyExpr:()=>aa,ToVariantExpr:()=>dU,TransactionExpr:()=>aC,TransformExpr:()=>hU,TransformModelPropertyExpr:()=>wa,TransientPropertyExpr:()=>Ma,TranslateCharactersExpr:()=>mq,TranslateExpr:()=>oP,TriggerEventExpr:()=>py,TriggerExecuteExpr:()=>cy,TriggerPropertiesExpr:()=>Gn,TriggerReferencingExpr:()=>ly,TrimExpr:()=>Ya,TrimPosition:()=>sD,TruncExpr:()=>ew,TruncateTableExpr:()=>uy,TryBase64DecodeBinaryExpr:()=>vv,TryBase64DecodeStringExpr:()=>Fv,TryCastExpr:()=>Gt,TryExpr:()=>HU,TryHexDecodeBinaryExpr:()=>Bv,TryHexDecodeStringExpr:()=>$v,TryToDecfloatExpr:()=>SU,TsOrDiToDiExpr:()=>SL,TsOrDsAddExpr:()=>Vh,TsOrDsDiffExpr:()=>UB,TsOrDsToDateExpr:()=>os,TsOrDsToDateStrExpr:()=>TL,TsOrDsToDatetimeExpr:()=>Vb,TsOrDsToTimeExpr:()=>Hb,TsOrDsToTimestampExpr:()=>_b,TupleExpr:()=>Ze,TypeExpr:()=>xq,TypeofExpr:()=>$q,UNWRAPPED_QUERIES:()=>Ls,UdtfExpr:()=>Ct,UnaryExpr:()=>qs,UncacheExpr:()=>ay,UnhexExpr:()=>vB,UnicodeExpr:()=>RL,UnicodeStringExpr:()=>MC,UniformExpr:()=>FB,UnionExpr:()=>or,UniqueColumnConstraintExpr:()=>Mu,UniqueKeyPropertyExpr:()=>vq,UnixDateExpr:()=>OL,UnixMicrosExpr:()=>CL,UnixMillisExpr:()=>bL,UnixSecondsExpr:()=>yL,UnixToStrExpr:()=>mL,UnixToTimeExpr:()=>NL,UnixToTimeStrExpr:()=>IL,UnloggedPropertyExpr:()=>ka,UnnestExpr:()=>Ee,UnpivotColumnsExpr:()=>iC,UpdateExpr:()=>us,UpperExpr:()=>dr,UppercaseColumnConstraintExpr:()=>ku,UseExpr:()=>CC,UseExprKind:()=>vG,UserDefinedFunctionExpr:()=>fy,UsingDataExpr:()=>gu,UsingTemplatePropertyExpr:()=>od,UtcDateExpr:()=>Bb,UtcTimeExpr:()=>$b,UtcTimestampExpr:()=>Gb,UuidExpr:()=>DA,UuidPropertyExpr:()=>kq,ValuesExpr:()=>tr,VarExpr:()=>Ve,VarMapExpr:()=>Rs,VariadicExpr:()=>Lb,VarianceExpr:()=>WL,VariancePopExpr:()=>jL,VectorSearchExpr:()=>jF,VersionExpr:()=>sC,ViewAttributePropertyExpr:()=>Da,VolatilePropertyExpr:()=>qa,WatermarkColumnConstraintExpr:()=>sq,WeekExpr:()=>Ad,WeekOfYearExpr:()=>MP,WeekStartExpr:()=>zL,WhenExpr:()=>_n,WhensExpr:()=>Au,WhereExpr:()=>St,WhileBlockExpr:()=>PC,WidthBucketExpr:()=>$B,WindowExpr:()=>Ue,WindowSpecExpr:()=>pu,WindowSpecExprKind:()=>PG,WithDataPropertyExpr:()=>th,WithExpr:()=>dt,WithFillExpr:()=>Xy,WithJournalTablePropertyExpr:()=>Ua,WithOperatorExpr:()=>eu,WithProcedureOptionsExpr:()=>Fa,WithSchemaBindingPropertyExpr:()=>va,WithSystemVersioningPropertyExpr:()=>sh,WithTableHintExpr:()=>cu,WithinGroupExpr:()=>ns,XmlElementExpr:()=>Sb,XmlGetExpr:()=>YB,XmlKeyValueOptionExpr:()=>yq,XmlNamespaceExpr:()=>yC,XmlTableExpr:()=>Rb,XorExpr:()=>hA,YearExpr:()=>wL,YearOfWeekExpr:()=>kP,YearOfWeekIsoExpr:()=>DP,ZeroFillColumnConstraintExpr:()=>wb,ZipfExpr:()=>VB,alias:()=>Be,and:()=>ve,array:()=>vA,case_:()=>qD,cast:()=>X,column:()=>$n,columnTableNames:()=>wM,combine:()=>HA,condition:()=>G_,convert:()=>ht,delete_:()=>Mj,except:()=>$_,expand:()=>Vj,false_:()=>it,findTables:()=>qj,from:()=>Pj,func:()=>_A,insert:()=>wj,intersect:()=>B_,isType:()=>Rn,literal:()=>Hl,maybeCopy:()=>$e,maybeParse:()=>j,merge:()=>Dj,normalizeTableName:()=>aM,not:()=>ks,null_:()=>le,or:()=>Ht,paren:()=>zs,parseIdentifier:()=>sy,renameColumn:()=>Fj,renameTable:()=>vj,replaceChildren:()=>SM,replacePlaceholders:()=>Yj,replaceTables:()=>Gj,replaceTree:()=>$j,select:()=>Ye,subquery:()=>DD,table:()=>F_,tableName:()=>Bj,table_:()=>Cj,toColumn:()=>j$,toIdentifier:()=>Z,toInterval:()=>bj,toTable:()=>vI,true_:()=>We,tuple:()=>Uj,union:()=>jA,update:()=>kj,values:()=>Lj,var_:()=>Q,wrap:()=>mr,xor:()=>ED});import{DateTime as D_}from"luxon";import{DateTime as UY}from"luxon";import{DateTime as Tn,Duration as xn}from"luxon";var tA=class tA{constructor(e){this._collected=!1;let{expression:t,sources:s,outerColumns:r,parent:i,scopeType:o="root",lateralSources:c,cteSources:p,canBeCorrelated:u}=e;this.expression=t,this.sources=s||new Map,this.lateralSources=c||new Map,this.cteSources=p||new Map;for(let[h,g]of this.lateralSources)this.sources.set(h,g);for(let[h,g]of this.cteSources)this.sources.set(h,g);this.outerColumns=r||[],this.parent=i,this.scopeType=o,this.subqueryScopes=[],this.derivedTableScopes=[],this.tableScopes=[],this.cteScopes=[],this.unionScopes=[],this.udtfScopes=[],this.canBeCorrelated=u??!1,this.clearCache()}clearCache(){this._collected=!1,this._rawColumns=void 0,this._tableColumns=void 0,this._stars=void 0,this._derivedTables=void 0,this._udtfs=void 0,this._tables=void 0,this._ctes=void 0,this._subqueries=void 0,this._selectedSources=void 0,this._columns=void 0,this._externalColumns=void 0,this._localColumns=void 0,this._joinHints=void 0,this._pivots=void 0,this._references=void 0,this._semiAntiJoinTables=void 0,this._columnIndex=void 0}branch(e){let{expression:t,scopeType:s,sources:r,cteSources:i,lateralSources:o,...c}=e,p=new Map(this.cteSources);if(i)for(let[u,h]of i)p.set(u,h);return new tA({expression:t.unnest(),sources:r?new Map(r):void 0,parent:this,scopeType:s,cteSources:p,lateralSources:o?new Map(o):void 0,canBeCorrelated:this.canBeCorrelated||s==="subquery"||s==="udtf",...c})}collect(){this._tables=[],this._ctes=[],this._subqueries=[],this._derivedTables=[],this._udtfs=[],this._rawColumns=[],this._tableColumns=[],this._stars=[],this._joinHints=[],this._semiAntiJoinTables=new Set,this._columnIndex=new WeakSet;for(let e of this.walk({bfs:!1}))if(e!==this.expression)if(e instanceof ge&&e.isStar)this._stars.push(e);else if(e instanceof $&&!(e instanceof WI))this._columnIndex.add(e),e.args.this instanceof Ne?this._stars.push(e):this._rawColumns.push(e);else if(e instanceof W&&!(e.parent instanceof gn)){let t=e.parent;if(t instanceof fe){let s=t;(s.args.kind==="semi"||s.args.kind==="anti")&&this._semiAntiJoinTables.add(e.aliasOrName)}this._tables.push(e)}else if(e instanceof gn)this._joinHints.push(e);else if(e instanceof Ct)this._udtfs.push(e);else if(e instanceof Bt)this._ctes.push(e);else if(e instanceof he){let t=JG(e);rD(e)&&t&&this._derivedTables.push(e)}else Ls.some(t=>e instanceof t)&&!JG(e)?this._subqueries.push(e):e instanceof Gl&&this._tableColumns.push(e);this._collected=!0}ensureCollected(){this._collected||this.collect()}walk(e={}){return rA(this.expression,e)}find(...e){return LW(this.expression,e,{bfs:!0})}findAll(...e){return Dr(this.expression,e,{bfs:!0})}replace(e,t){e.replace(t),this.clearCache()}get tables(){return this.ensureCollected(),this._tables??[]}get ctes(){return this.ensureCollected(),this._ctes??[]}get derivedTables(){return this.ensureCollected(),this._derivedTables??[]}get udtfs(){return this.ensureCollected(),this._udtfs??[]}get subqueries(){return this.ensureCollected(),this._subqueries??[]}get stars(){return this.ensureCollected(),this._stars??[]}get columnIndex(){return this.ensureCollected(),this._columnIndex??new WeakSet}get isSubquery(){return this.scopeType==="subquery"}get isDerivedTable(){return this.scopeType==="derivedTable"}get isUnion(){return this.scopeType==="union"}get isCte(){return this.scopeType==="cte"}get isRoot(){return this.scopeType==="root"}get isUdtf(){return this.scopeType==="udtf"}get isCorrelatedSubquery(){return!!(this.canBeCorrelated&&0<this.externalColumns.length)}get columns(){if(this._columns===void 0){this.ensureCollected();let e=this._rawColumns??[],t=[];for(let r of[...this.subqueryScopes,...this.udtfScopes,...this.derivedTableScopes.filter(i=>i.canBeCorrelated)])t.push(...r.externalColumns);let s=new Set(this.expression.namedSelects);this._columns=[];for(let r of[...e,...t]){let i=r.findAncestor(se,Xs,ye,xs,Ps,W,Ne,et);(!i||r.table||i instanceof se||i instanceof W&&!(i.args.this instanceof E)||(i instanceof ye||i instanceof et)&&(i.parent instanceof Ue||i.parent instanceof ns||!(i.parent instanceof se)||!s.has(r.name))||i instanceof Ne&&r.argKey!=="except")&&this._columns.push(r)}}return this._columns}get tableColumns(){return this._tableColumns===void 0&&this.ensureCollected(),this._tableColumns??[]}get externalColumns(){if(this._externalColumns===void 0)if(this.expression instanceof Ge){let[e,t]=this.unionScopes;this._externalColumns=[...e.externalColumns,...t.externalColumns]}else{let e=new Set(this.references.map(([t])=>t));this._externalColumns=this.columns.filter(t=>!e.has(t.table)&&!this.semiOrAntiJoinTables.has(t.table))}return this._externalColumns}get localColumns(){if(this._localColumns===void 0){let e=new Set(this.externalColumns);this._localColumns=this.columns.filter(t=>!e.has(t))}return this._localColumns}get unqualifiedColumns(){return this.columns.filter(e=>!e.table)}get joinHints(){return this._joinHints===void 0?[]:this._joinHints}get pivots(){if(!this._pivots){this._pivots=[];for(let[,e]of this.references){let t=e.args.pivots;t&&Array.isArray(t)&&this._pivots.push(...t)}}return this._pivots}get semiOrAntiJoinTables(){return this._semiAntiJoinTables||new Set}get references(){if(this._references===void 0){this._references=[];for(let e of this.tables)this._references.push([e.aliasOrName,e]);for(let e of[...this.derivedTables,...this.udtfs]){let t=iD(e),s=e.getArgKey("pivots")?e:e.unnest();this._references.push([t,s])}}return this._references}get selectedSources(){if(this._selectedSources===void 0){this._selectedSources={};for(let[e,t]of this.references){if(this.semiOrAntiJoinTables.has(e))continue;if(e in this._selectedSources)throw new $l(`Alias already used: ${e}`);let s=this.sources.get(e);s!==void 0&&(this._selectedSources[e]=[t,s])}}return this._selectedSources}sourceColumns(e){return this.columns.filter(t=>t.table===e)}renameSource(e,t){let s=e||"",r=this.sources.get(s);r!==void 0&&(this.sources.delete(s),this.sources.set(t,r))}addSource(e,t){this.sources.set(e,t),this.clearCache()}removeSource(e){this.sources.delete(e),this.clearCache()}*traverse(){let e=[this],t=[];for(;0<e.length;){let s=e.pop();t.push(s),e.push(...s.cteScopes,...s.unionScopes,...s.tableScopes,...s.subqueryScopes)}for(let s=t.length-1;0<=s;s--)yield t[s]}refCount(){let e=new Map;for(let t of this.traverse()){for(let[,s]of Object.values(t.selectedSources))s instanceof tA&&e.set(s,(e.get(s)||0)+1);for(let s of t.semiOrAntiJoinTables){let r=t.sources.get(s);r!==void 0&&r instanceof tA&&e.set(r,(e.get(r)||0)+1)}}return e}toString(){return`<Scope ${this.scopeType}>`}};n(tA,"Scope");var js=tA;function sA(a){if(![ee,dn,bs].some(s=>a instanceof s))return[];let t=[];for(let s of hn(new js({expression:a})))t.push(s);return t}n(sA,"traverseScope");function*hn(a){let e=a.expression;if(e instanceof se)yield*XG(a);else if(e instanceof Ge){yield*HI(a),yield*bW(a);return}else if(e instanceof he)a.isRoot?yield*XG(a):yield*QG(a);else if(e instanceof W)yield*zG(a);else if(e instanceof Ct)yield*PW(a);else if(e instanceof dn){e.args.expression instanceof ee&&(yield*HI(a),yield*hn(new js({expression:e.args.expression,cteSources:a.cteSources})));return}else if(e instanceof bs){yield*HI(a);for(let t of Dr(e,[ee])){let s=t.parent;s&&!(s instanceof Bt)&&!(s instanceof he)&&(yield*hn(new js({expression:t,cteSources:a.cteSources})))}return}else return;yield a}n(hn,"_traverseScope");function*XG(a){yield*HI(a),yield*zG(a),yield*QG(a)}n(XG,"traverseSelect");function*bW(a){let e,t=[a],s=a.expression,r=[s.right,s.left];for(;0<r.length;){let i=r.pop(),o=t[t.length-1],c=o.branch({expression:i,outerColumns:o.outerColumns,scopeType:"union"});if(i instanceof Ge){yield*HI(c),t.push(c),r.push(i.right),r.push(i.left);continue}let p;for(let u of hn(c))yield u,p=u;e&&p?(t.pop(),o.unionScopes=[e,p],e=o,yield o):e=p}}n(bW,"traverseUnion");function*HI(a){let e=new Map;for(let t of a.ctes){let s=t.alias,r=a.expression.args.with;if(r&&Y(r,dt)&&r.args.recursive){let c=t.args.this;c instanceof Ge&&c.args.this&&e.set(s,a.branch({expression:c.args.this,scopeType:"cte"}))}let i=t.args.this;if(!i)continue;let o;for(let c of hn(a.branch({expression:i,cteSources:e,outerColumns:t.aliasColumnNames||[],scopeType:"cte"})))yield c,o=c;o&&(e.set(s,o),a.cteScopes.push(o))}for(let[t,s]of e)a.sources.set(t,s),a.cteSources.set(t,s)}n(HI,"traverseCtes");function rD(a){return!!(a instanceof he&&(a.alias||Ls.some(e=>a.args.this instanceof e)))}n(rD,"isDerivedTable");function JG(a){let e=a.parent;for(;e instanceof he;)e=e.parent;return e instanceof rt||e instanceof fe}n(JG,"_isFromOrJoin");function iD(a){let e=a.getArgKey("alias"),t=a.alias;return!t&&e instanceof pe&&e.columns.length===1&&(t=e.columns[0].name),t}n(iD,"getSourceAlias");function*zG(a){let e=new Map,t=[],s=a.expression.getArgKey("from");s?.args.this&&t.push(s.args.this);for(let i of a.expression.getArgKey("joins")||[])i.args.this&&t.push(i.args.this);a.expression instanceof W&&t.push(a.expression);for(let i of a.expression.getArgKey("laterals")||[])t.push(i);let r=0;for(;r<t.length;){let i=t[r++];if(i instanceof _I&&(i=i.getArgKey("this")),i instanceof W){let h=i.name,g=i.aliasOrName;if(a.sources.has(h)&&!i.db){let x=i.args.pivots;x&&0<x.length?e.set(x[0].alias,i):e.set(g,a.sources.get(h))}else e.has(g)?e.set(En(Array.from(e.keys()),h),i):e.set(g,i);if(i!==a.expression)for(let x of i.args.joins||[])Y(x.args.this,d)&&t.push(x.args.this);continue}if(!(i instanceof An))continue;let o,c,p;if(i instanceof Ct)o=e,c="udtf",p=a.udtfScopes;else if(i instanceof he&&rD(i)){o=void 0,c="derivedTable",p=a.derivedTableScopes;for(let h of i.getArgKey("joins")||[])h.args.this&&t.push(h.args.this)}else{t.push(i.getArgKey("this"));for(let h of i.getArgKey("joins")||[])h.args.this&&t.push(h.args.this);continue}let u;for(let h of hn(a.branch({expression:i,lateralSources:o,outerColumns:i.aliasColumnNames||[],scopeType:c})))yield h,u=h,e.set(iD(i),u);u&&(p.push(u),a.tableScopes.push(u))}for(let[i,o]of e)a.sources.set(i,o)}n(zG,"traverseTables");function*QG(a){for(let e of a.subqueries){let t;for(let s of hn(a.branch({expression:e,scopeType:"subquery"})))yield s,t=s;t&&a.subqueryScopes.push(t)}}n(QG,"traverseSubqueries");function*PW(a){let e;a.expression instanceof Ee?e=a.expression.args.expressions??[]:a.expression instanceof bt&&a.expression.args.this?e=[a.expression.args.this]:e=[];let t=new Map;for(let s of e){if(!(s instanceof he))continue;let r;for(let i of hn(a.branch({expression:s,scopeType:"subquery",outerColumns:s.aliasColumnNames||[]})))yield i,r=i,t.set(iD(s),i);r&&a.subqueryScopes.push(r)}for(let[s,r]of t)a.sources.set(s,r)}n(PW,"traverseUdtfs");function GX(a){let e=sA(a);return k(e,-1)}n(GX,"buildScope");function*rA(a,e={}){let{bfs:t=!0,prune:s}=e,r=!1;for(let i of a.walk({bfs:t,prune:n(o=>r||(s?s(o):!1),"prune")}))if(r=!1,yield i,i!==a&&(i instanceof Bt||(i.parent instanceof rt||i.parent instanceof fe)&&rD(i)||i.parent instanceof Ct&&i instanceof ee||Ls.some(o=>i instanceof o))&&(r=!0,i instanceof he||i instanceof Ct))for(let o of["joins","laterals","pivots"]){let c=i.getArgKey(o);if(Array.isArray(c))for(let p of c)yield*rA(p,{bfs:t})}}n(rA,"walkInScope");function Dr(a,e,t={}){let{bfs:s=!0}=t,r=[];for(let i of rA(a,{bfs:s}))for(let o of e)if(i instanceof o){r.push(i);break}return r}n(Dr,"findAllInScope");function LW(a,e,t={}){let{bfs:s=!0}=t;for(let r of rA(a,{bfs:s}))for(let i of J(e))if(r instanceof i)return r}n(LW,"findInScope");function JX(a,e={}){let{dnf:t=!1,maxDistance:s=128}=e,r=new nA({annotateNewExpressions:!1}),i=[];for(let o of a.walk({prune:n(c=>c instanceof Ae,"prune")}))o instanceof Ae&&i.push(o);for(let o of i){if(fM(o,{dnf:t}))continue;let c=o===a,p=o.copy();o.transform(h=>r.rewriteBetween(h),{copy:!1});let u=ZG(o,{dnf:t,max:s});if(s<u)return a;try{let h=TM(o,g=>KG(g,{dnf:t,maxDistance:s,simplifier:r}));o=o.replace(h)}catch(h){if(h instanceof $l)return o.replace(p),c?p:a;throw h}c&&(a=o)}return a}n(JX,"normalize");function fM(a,e={}){let{dnf:t=!1}=e,[s,r]=t?[Te,pt]:[pt,Te];return!Dr(a,[r]).some(i=>i.findAncestor(s))}n(fM,"normalized");function ZG(a,e={}){let{dnf:t=!1,max:s=1/0}=e,r=-1;for(let i of a.findAll(Ae))r-=1;for(let i of jI(a,{dnf:t,max:s}))if(r+=i,s<r)return r;return r}n(ZG,"normalizationDistance");function*jI(a,e){let{dnf:t,max:s=1/0,depth:r=0}=e;if(s<r){yield r;return}let i=a.unnest();if(!(i instanceof Ae)){yield 1;return}let o=r+1,c=i.left,p=i.right;if(!c||!p){yield 1;return}if(i instanceof(t?Te:pt))for(let h of jI(c,{dnf:t,max:s,depth:o}))for(let g of jI(p,{dnf:t,max:s,depth:o}))yield h+g;else yield*jI(c,{dnf:t,max:s,depth:o}),yield*jI(p,{dnf:t,max:s,depth:o})}n(jI,"predicateLengths");function KG(a,e){let{dnf:t,maxDistance:s,simplifier:r}=e;if(fM(a,{dnf:t}))return a;let i=ZG(a,{dnf:t,max:s});if(s<i)throw new $l(`Normalization distance ${i} exceeds max ${s}`);SM(a,f=>KG(f,e));let[o,c]=t?[pt,Te]:[Te,pt];if(!(a instanceof c))return a;let[p,u]=a.unnestOperands();if(!p||!u)return a;let h=c===Te?ve:Ht,g=o===Te?ve:Ht,x=r??new nA({annotateNewExpressions:!1});if(p instanceof o&&u instanceof o){let f=Array.from(p.findAll(Ae)).length;return Array.from(u.findAll(Ae)).length<f?xM(p,u,h,g,x):xM(u,p,h,g,x)}return p instanceof o?xM(u,p,h,g,x):u instanceof o?xM(p,u,h,g,x):a}n(KG,"distributiveLaw");function xM(a,e,t,s,r){let i=e.left,o=e.right;if(!i||!o)return a;if(a instanceof Ae)return SM(a,u=>{let h=iA(t([u,i])),g=iA(t([u,o]));return s([r.uniqSort(h),r.uniqSort(g)],{copy:!1})}),a;let c=iA(t([a,i])),p=iA(t([a,o]));return s([r.uniqSort(c),r.uniqSort(p)],{copy:!1})}n(xM,"distribute");var fn="final";function IM(a,e={}){let{constantPropagation:t=!1,coalesceSimplification:s=!1,dialect:r}=e;return new nA({dialect:r}).simplify(a,{constantPropagation:t,coalesceSimplification:s})}n(IM,"simplify");var hD=class hD extends Error{constructor(e){super(e),this.name="UnsupportedUnit"}};n(hD,"UnsupportedUnit");var Ms=hD;function aA(...a){return function(e,t){return function(...s){try{return e.apply(this,s)}catch(r){if(a.some(i=>r instanceof i))return s[0];throw r}}}}n(aA,"catch_");function Js(a,e){return function(...t){let s=t[0],r=a.apply(this,t);if(r===void 0)return r;if(this.annotateNewExpressions&&s!==r&&r instanceof d){this._annotator.clear();let i=this._annotator.annotate(r,{annotateScope:!1});return i.type=s.type,i}return r}}n(Js,"annotateTypesOnChange");function iA(a){if(!(a instanceof Ae))return a;let e=a.args,t=Object.values(e);for(let s of t){if(!(s instanceof d))continue;let r=s.unnest();r._constructor===a._constructor&&s.replace(r)}return a}n(iA,"flatten");function wW(a,e){if(!(a instanceof Re))return a;let t=a.args.this,s=a.parent,r=s instanceof ke;return t instanceof se||s instanceof Us||s instanceof wt||ae.getOrRaise(e)._constructor.REQUIRES_PARENTHESIZED_STRUCT_ACCESS&&s instanceof ge&&(s.right instanceof F||s.right instanceof Ne)?a:t instanceof ke&&!(r||s instanceof Pt||s instanceof v&&!(s instanceof Ae))||!(s instanceof be||s instanceof v)||s instanceof Re||!(t instanceof v)&&!((t instanceof Le||t instanceof ze)&&r)||t instanceof we&&s instanceof we||t instanceof Ts&&s instanceof Ts||t instanceof Ts&&(s instanceof we||s instanceof Ce)?t??a:a}n(wW,"simplifyParens");function MW(a,e={}){let{root:t=!0}=e;if(a instanceof Te&&(t||!a.sameParent)&&fM(a,{dnf:!0})){let s=new Map;for(let r of rA(a,{prune:n(i=>i instanceof xe,"prune")}))if(r instanceof Me){let i=r.left,o=r.right;i instanceof $&&o instanceof I?s.set(i.sql(),[i,o]):o instanceof $&&i instanceof I&&s.set(o.sql(),[o,i])}if(0<s.size)for(let r of Dr(a,[$])){let i=r.parent,o=s.get(r.sql()),[c,p]=o||[void 0,void 0];c!==void 0&&r!==c&&!(i instanceof ze&&i.args.expression instanceof Lt)&&r.replace(p.copy())}}return a}n(MW,"propagateConstants");function kW(a,e,t=28){let s=n(y=>{let b=y.indexOf("."),m=b===-1?0:b-y.length+1;return[BigInt(y.replace(".","")),m]},"parse"),[r,i]=s(a),[o,c]=s(e),p=r*10n**BigInt(t+1)/o,h=p.toString().length-t,g;if(h<=0)g=p;else if(h===1)g=p/10n+(5n<=p%10n?1n:0n);else{let y=10n**BigInt(h),b=10n**BigInt(h-1)*5n;g=p/y+(b<=p%y?1n:0n)}let x=g.toString(),f=x.length+(i-c-t-1+h),T;return f<=0?T="0."+"0".repeat(-f)+x:x.length<=f?T=x+"0".repeat(f-x.length):T=x.slice(0,f)+"."+x.slice(f),T.includes(".")?T.replace(/\.?0+$/,"")||"0":T}n(kW,"decimalDiv");function eY(a){return a instanceof d&&a.isNumber}n(eY,"isNumber");function DW(a){return a instanceof qe&&cD(a)!==void 0}n(DW,"isInterval");function qW(a){return AD.some(e=>a instanceof e)||qr(a)}n(qW,"isNonnullConstant");function XI(a){return dD.some(e=>a instanceof e)||qr(a)}n(XI,"isConstant");function uD(a,e,t){let s=lA(a,e,t);if(a.toMillis()===s.toMillis())return[s,s.plus(uA(e))]}n(uD,"dateTruncRange");function UW(a){if(a.length===0)return[];let e=[...a].sort((s,r)=>s[0].toMillis()-r[0].toMillis()),t=[e[0]];for(let[s,r]of e.slice(1)){let i=t[t.length-1];s.toMillis()<=i[1].toMillis()?t[t.length-1]=[i[0],i[1].toMillis()<r.toMillis()?r:i[1]]:t.push([s,r])}return t}n(UW,"mergeRanges");function MY(a,e,t){return ve([new Je({this:a,expression:fs(e[0],t)}),new Fe({this:a,expression:fs(e[1],t)})],{copy:!1})}n(MY,"dateTruncEqExpression");function vW(a,e,t,s,r){let i=uD(e,t,s);if(i)return MY(a,i,r)}n(vW,"dateTruncEq");function FW(a,e,t,s,r){let i=uD(e,t,s);if(i)return ve([new Fe({this:a,expression:fs(i[0],r)}),new Je({this:a,expression:fs(i[1],r)})],{copy:!1})}n(FW,"dateTruncNeq");function as(a){return a instanceof at&&a.args.this||a instanceof I&&a.isNumber&&!mM(a)}n(as,"alwaysTrue");function RM(a){return pA(a)||_t(a)||mM(a)}n(RM,"alwaysFalse");function mM(a){return a instanceof I&&a.toValue()===0}n(mM,"isZero");function pA(a){return a instanceof at&&!a.args.this}n(pA,"isFalse");function _t(a){return a instanceof Lt}n(_t,"isNull");function nD(a,e,t){if(a instanceof Me||a instanceof ze)return cA(e===t);if(a instanceof xt)return cA(e!==t);if(a instanceof je)return cA(t<e);if(a instanceof Je)return cA(t<=e);if(a instanceof Fe)return cA(e<t);if(a instanceof nt)return cA(e<=t)}n(nD,"evalBoolean");function kY(a){let e=Tn.fromISO(a,{zone:"utc"});return e.isValid?e:Tn.fromSQL(a,{zone:"utc"})}n(kY,"parseDateTime");function BW(a){if(Tn.isDateTime(a))return a.toUTC().startOf("day");let e=typeof a=="string"?kY(a):Tn.fromMillis(a,{zone:"utc"});return e.isValid?e.startOf("day"):void 0}n(BW,"castAsDate");function oD(a){if(Tn.isDateTime(a))return a.toUTC();let e=typeof a=="string"?kY(a):Tn.fromMillis(a,{zone:"utc"});return e.isValid?e:void 0}n(oD,"castAsDatetime");function $W(a,e){if(a){if(e.isType("date"))return BW(a);if(e.isType(Array.from(N.TEMPORAL_TYPES)))return oD(a)}}n($W,"castValue");function ws(a){let e;if(a instanceof z&&a.to instanceof N)e=a.to;else if(a instanceof os&&!a.args.format)e=new N({this:"date"});else return;let t,s=a.args.this;if(s instanceof I)t=s.name;else if(s instanceof z||s instanceof os)t=ws(s);else return;return $W(t,e)}n(ws,"extractDate");function qr(a){return ws(a)!==void 0}n(qr,"isDateLiteral");function cD(a){if(a.args.this!==void 0)try{let e=parseInt(String(a.args.this.toValue())),t=a.text("unit").toLowerCase();return uA(t,e)}catch(e){if(e instanceof Ms||e instanceof Error)return;throw e}}n(cD,"extractInterval");function oA(...a){let e;for(let t of a){if(t instanceof z){let s=t.to;e=Y(s,N)||Y(s,Pe)?s:void 0}else{let s=t.type;e=Y(s,N)||Y(s,Pe)?s:void 0}if(e)break}return e}n(oA,"extractType");function fs(a,e){let t;!e||!e.isType(Array.from(N.TEMPORAL_TYPES))?t=a.hour===0&&a.minute===0&&a.second===0?"date":"datetime":t=e.args.this;let s=t==="date"?a.toISODate():a.toFormat("yyyy-MM-dd HH:mm:ss");return new z({this:I.string(s),to:new N({this:t})})}n(fs,"dateLiteral");function uA(a,e=1){switch(a.toLowerCase()){case"year":return xn.fromObject({years:e});case"quarter":return xn.fromObject({months:3*e});case"month":return xn.fromObject({months:e});case"week":return xn.fromObject({weeks:e});case"day":return xn.fromObject({days:e});case"hour":return xn.fromObject({hours:e});case"minute":return xn.fromObject({minutes:e});case"second":return xn.fromObject({seconds:e});default:throw new Ms(`Unsupported unit: ${a}`)}}n(uA,"interval");function lA(a,e,t){switch(e.toLowerCase()){case"year":return a.set({month:1,day:1,hour:0,minute:0,second:0,millisecond:0});case"quarter":{let s=Math.floor((a.month-1)/3)*3+1;return a.set({month:s,day:1,hour:0,minute:0,second:0,millisecond:0})}case"month":return a.set({day:1,hour:0,minute:0,second:0,millisecond:0});case"week":return a.startOf("week").plus({days:t._constructor.WEEK_OFFSET||0});case"day":return a;default:throw new Ms(`Unsupported unit: ${e}`)}}n(lA,"dateFloor");function GW(a,e,t){let s=lA(a,e,t);return s.toMillis()===a.toMillis()?a:s.plus(uA(e))}n(GW,"dateCeil");function cA(a){return a?We():it()}n(cA,"booleanLiteral");var tY,sY,rY,iY,nY,aY,oY,cY,pY,lY,uY,hY,gY,EY,AY,dY,xY,fY,TY,SY,RY,OY,mY,NY,IY,yY,CY,bY,PY,LY,wY,de;wY=[O],LY=[O],PY=[O],bY=[O],CY=[O],yY=[O],IY=[O],NY=[O],mY=[O],OY=[O],RY=[O],SY=[O],TY=[O],fY=[O],xY=[O],dY=[O],AY=[O],EY=[O],gY=[aA(Ms)],hY=[Js],uY=[Js],lY=[Js,aA(Ms)],pY=[Js,aA(Ms)],cY=[aA(Ms)],oY=[Js],aY=[Js],nY=[aA(Ms)],iY=[Js,aA(Ms)],rY=[Js],sY=[Js],tY=[Js];var G=class G{constructor(e={}){yt(de,5,this);this.dialect=void 0;this.annotateNewExpressions=void 0;this._annotator=void 0;let{dialect:t,annotateNewExpressions:s=!0}=e;this.dialect=ae.getOrRaise(t),this.annotateNewExpressions=s,this._annotator=new Yl({schema:NM(void 0,{dialect:this.dialect}),overwriteTypes:!1})}static get SIMPLIFIABLE(){return[v,E,ps,ke,qs]}static get COMPLEMENT_COMPARISONS(){return{[Fe.key]:Je,[je.key]:nt,[nt.key]:je,[Je.key]:Fe,[Me.key]:xt,[xt.key]:Me}}static get COMPLEMENT_SUBQUERY_PREDICATES(){return{[cs.key]:Tt,[Tt.key]:cs}}static get LT_LTE(){return[Fe,nt]}static get GT_GTE(){return[je,Je]}static get COMPARISONS(){return[...G.LT_LTE,...G.GT_GTE,Me,xt,ze]}static get INVERSE_COMPARISONS(){return{[Fe.key]:je,[je.key]:Fe,[nt.key]:Je,[Je.key]:nt}}static get NONDETERMINISTIC(){return[vr,JI]}static get AND_OR(){return[Te,pt]}static get INVERSE_DATE_OPS(){return{[ft.key]:Ce,[Xt.key]:we,[Ds.key]:Ce,[Qs.key]:we}}static get INVERSE_OPS(){return{...G.INVERSE_DATE_OPS,[we.key]:Ce,[Ce.key]:we}}static get NULL_OK(){return[Ks,Ur,ot]}static get CONCATS(){return[$t,jt]}static get DATETRUNC_BINARY_COMPARISONS(){return{[Fe.key]:(e,t,s,r,i)=>{let o=lA(t,s,r),c=t.toMillis()===o.toMillis()?t:o.plus(uA(s));return new Fe({this:e,expression:fs(c,i)})},[je.key]:(e,t,s,r,i)=>{let o=lA(t,s,r);return new Je({this:e,expression:fs(o.plus(uA(s)),i)})},[nt.key]:(e,t,s,r,i)=>{let o=lA(t,s,r);return new Fe({this:e,expression:fs(o.plus(uA(s)),i)})},[Je.key]:(e,t,s,r,i)=>{let o=GW(t,s,r);return new Je({this:e,expression:fs(o,i)})},[Me.key]:vW,[xt.key]:FW}}static get DATETRUNC_COMPARISONS(){return new Set([lt.key,...Object.keys(G.DATETRUNC_BINARY_COMPARISONS)])}static get DATETRUNCS(){return[ls,Sn]}static get SAFE_CONNECTOR_ELIMINATION_RESULT(){return[Ae,at]}static get JOINS(){return[["",""],["","inner"],["right",""],["right","outer"]]}simplify(e,t={}){let{constantPropagation:s=!1,coalesceSimplification:r=!1}=t,i=[],o=[];for(let c of e.walk({prune:n(p=>p instanceof be?!0:!!p.meta[fn],"prune")})){if(c.meta[fn])continue;let p=c.getArgKey("group");if(p instanceof d&&c instanceof se){let u=p.args.expressions;if(u){let h=new Set(u.map(f=>f.hash()));p.meta[fn]=!0;let g=c.selects;for(let f of g)for(let T of f.walk({prune:n(y=>!!y.meta[fn],"prune")}))if(h.has(T.hash())){f.meta[fn]=!0;break}let x=c.args.having;if(x){for(let f of x.walk())if(h.has(f.hash())){x.meta[fn]=!0;break}}}}if(c instanceof be){let u=TM(c,h=>this._simplify(h,{constantPropagation:s,coalesceSimplification:r}));c===e&&(e=u)}else if(c instanceof St)i.push(c);else if(c instanceof fe){let u=c.args.matchCondition;u&&(u.meta[fn]=!0),o.push(c)}}for(let c of i)as(c.args.this)&&c.pop();for(let c of o){let p=c.args.on,u=c.args.using,h=c.args.method,g=c.args.side||"",x=c.args.kind||"";p&&as(p)&&!u&&!h&&G.JOINS.some(([f,T])=>f===g&&T===x)&&(p.pop(),c.setArgKey("side",void 0),c.setArgKey("kind","cross"))}return e}_simplify(e,t){let{constantPropagation:s,coalesceSimplification:r}=t,i=[e],o=[];for(;0<i.length;){let p=i.pop();if(!p)continue;let u=p;if(!G.SIMPLIFIABLE.some(x=>u instanceof x)){u instanceof ee&&this.simplify(u,{constantPropagation:s,coalesceSimplification:r});continue}let h=u.parent,g=u===e;u=this.rewriteBetween(u),u=this.uniqSort(u,{root:g}),u=this.absorbAndEliminate(u,{root:g}),u=this.simplifyConcat(u),u=this.simplifyConditionals(u),s&&(u=MW(u,{root:g})),u!==p&&p?.replace(u);for(let x of u.iterExpressions({reverse:!0}))x.meta[fn]||i.push(x);o.push([u,h])}let c=e;for(;0<o.length;){let[p,u]=o.pop(),h=p===e;for(let[x,f]of Object.entries(p.args))p?.setArgKey(x,f);let g=this.simplifyNot(p);g=iA(g),g=this.simplifyConnectors(g,{root:h}),g=this.removeComplements(g,{root:h}),r&&(g=this.simplifyCoalesce(g)),g.parent=u,g=this.simplifyLiterals(g,{root:h}),g=this.simplifyEquality(g),g=wW(g,this.dialect),g=this.simplifyDateTrunc(g),g=this.sortComparison(g),g=this.simplifyStartsWith(g),g!==p&&p.replace(g),c=g}return c}absorbAndEliminate(e,t={}){let{root:s=!0}=t;if(G.AND_OR.some(r=>e instanceof r)&&(s||!e.sameParent)){let r=e instanceof Te?pt:Te,i=Array.from(e.flatten()),o=new Set,c=new Map,p=new Map;for(let u of i){let h=this.genSql(u);if(o.add(h),!(u instanceof r)){let T=c.get(h);T||(T=[],c.set(h,T)),T.push(new Set([h]));continue}let g=new Set(Array.from(u.flatten()).map(T=>this.genSql(T)));for(let T of g){let y=c.get(T);y||(y=[],c.set(T,y)),y.push(g)}let[x,f]=u.unnestOperands();if(x&&f){if(x instanceof Le&&x.args.this instanceof d){let T=`${this.genSql(x.args.this)}|${this.genSql(f)}`;p.has(T)||p.set(T,[]),p.get(T).push([u,f])}if(f instanceof Le&&f.args.this instanceof d){let T=`${this.genSql(f.args.this)}|${this.genSql(x)}`;p.has(T)||p.set(T,[]),p.get(T).push([u,x])}}}for(let u of i){if(!(u instanceof r))continue;let[h,g]=u.unnestOperands();if(!h||!g)continue;if(h instanceof Le&&h.args.this instanceof d&&o.has(this.genSql(h.args.this))){h.replace(r===Te?We():it());continue}if(g instanceof Le&&g.args.this instanceof d&&o.has(this.genSql(g.args.this))){g.replace(r===Te?We():it());continue}let x=new Set(Array.from(u.flatten()).map(C=>this.genSql(C)));if(Array.from(x).some(C=>{let q=c.get(C);return q?q.some(U=>{if(x.size<=U.size)return!1;for(let _ of U)if(!x.has(_))return!1;return!0}):!1})){u.replace(r===Te?it():We());continue}let T=this.genSql(h),y=this.genSql(g),b=`${T}|${y}`,m=`${y}|${T}`;for(let[C,q]of[...p.get(b)||[],...p.get(m)||[]])u.replace(q),C.replace(q)}}return e}simplifyConcat(e){if(!G.CONCATS.some(u=>e instanceof u))return e;if(e instanceof Wt){let[u]=e.args.expressions??[];if(!(u instanceof d)||!u.isString)return e}let t,s,r,i,o;if(e instanceof Wt){let[u,...h]=e.args.expressions??[];t=u,s=h,r=t.name,i=Wt,o={}}else s=e.args.expressions??[],r="",i=$t,o={safe:e.args.safe,coalesce:e.args.coalesce};let c=[],p=[];for(let u of 0<s.length?s:Array.from(e.flatten()))u instanceof d&&(u.isString?p.push(u.name):(0<p.length&&(c.push(I.string(p.join(r))),p=[]),c.push(u)));return 0<p.length&&c.push(I.string(p.join(r))),c.length===1&&c[0].isString?c[0]:i===Wt&&t?new Wt({expressions:[t,...c]}):e instanceof jt?c.reduce((u,h)=>new jt({this:u,expression:h})):new i({expressions:c,...o})}simplifyConditionals(e){if(e instanceof ut){let t=e.args.this;for(let s of e.args.ifs||[]){let r=s.args.this;if(t&&(r=r.replace(t.pop().eq(r))),as(r))return s.getArgKey("true");if(RM(r)){s.pop();let i=e.args.ifs;if(!i||i.length===0)return e.args.default||le()}}}else if(e instanceof xe&&!(e.parent instanceof ut)){let t=e.args.this;if(as(t))return ct(e.args.true,d)??e;if(RM(t))return ct(e.args.false,d)??le()}return e}simplifyNot(e){if(e instanceof Le){let t=e.args.this;if(_t(t))return ve([le(),We()],{copy:!1});if(t instanceof d){let s=G.COMPLEMENT_COMPARISONS[t._constructor.key];if(s){let r=t.args.expression;if(r instanceof d){let i=G.COMPLEMENT_SUBQUERY_PREDICATES[r._constructor.key];i&&(r=new i({this:r.args.this}))}return new s({this:t.args.this,expression:r})}}if(t instanceof Re){let s=t.unnest();if(s instanceof Te)return zs(Ht([ks(s.args.this!==void 0?OM(s.args.this):void 0,{copy:!1}),ks(s.args.expression!==void 0?OM(s.args.expression):void 0,{copy:!1})],{copy:!1}),{copy:!1});if(s instanceof pt)return zs(ve([ks(s.args.this,{copy:!1}),ks(s.args.expression!==void 0?OM(s.args.expression):void 0,{copy:!1})],{copy:!1}),{copy:!1});if(_t(s))return ve([le(),We()],{copy:!1})}if(as(t))return it();if(pA(t))return We();if(t instanceof Le&&this.dialect._constructor.SAFE_TO_ELIMINATE_DOUBLE_NEGATION){let s=t.args.this;if(Rn(s,"boolean"))return s??e}}return e}simplifyConnectors(e,t={}){let{root:s=!0}=t;if(e instanceof Ae){let r=e.parent;if(e=this.flatSimplify(e,(i,o,c)=>{if(i instanceof Te)return pA(o)||pA(c)?it():mM(o)||mM(c)?it():_t(o)&&_t(c)||_t(o)&&as(c)||as(o)&&_t(c)?le():as(o)&&as(c)?We():as(o)?c:as(c)?o:this.simplifyComparison(i,o,c,{or:!1});if(i instanceof pt)return as(o)||as(c)?We():_t(o)&&_t(c)||_t(o)&&RM(c)||RM(o)&&_t(c)?le():pA(o)?c:pA(c)?o:this.simplifyComparison(i,o,c,{or:!0})},{root:s}),!G.SAFE_CONNECTOR_ELIMINATION_RESULT.some(i=>e instanceof i)&&!e.isType("boolean")){let i=r;for(;!(i instanceof Ae);){if(!(i instanceof Re)){e=ve([e,We()],{copy:!1});break}i=i.parent}}}return e}simplifyComparison(e,t,s,r){let{or:i=!1}=r;if(G.COMPARISONS.some(o=>t instanceof o)&&G.COMPARISONS.some(o=>s instanceof o)){let o=t.args.this,c=t.args.expression,p=s.args.this,u=s.args.expression;if(!o||!c||!p||!u)return;let h=[o,c],g=[p,u],x=new Map(h.map(m=>[ct(m,d)?.hash(),m])),f=new Map(g.map(m=>[ct(m,d)?.hash(),m])),T=new Set([...x.keys()].filter(m=>f.has(m))),y=[...T].map(m=>x.get(m)).filter(m=>!XI(m)&&!ct(m,d)?.find(G.NONDETERMINISTIC)),b=new Set(y.map(m=>ct(m,d)?.hash()));if(0<T.size&&0<y.length){let m=h.filter(Se=>!b.has(ct(Se,d)?.hash())),C=g.filter(Se=>!b.has(ct(Se,d)?.hash()));if(m.length===0||C.length===0)return e;let q,U;try{q=lD(m),U=lD(C)}catch{return e}if(!(q instanceof d)||!(U instanceof d))return;let _=q,ne=U,K,H;if(_.isNumber&&ne.isNumber)K=_.toValue(),H=ne.toValue();else if(_.isString&&ne.isString)K=_.name,H=ne.name;else{let Se=ws(_);if(!Se)return;let Ot=ws(ne);if(!Ot)return;K=oD(Se),H=oD(Ot)}let Ie=[[[t,K],[s,H]],[[s,H],[t,K]]];for(let[[Se,Ot],[gt,ds]]of Ie){let mt=typeof Ot=="number"?Ot:Tn.isDateTime(Ot)?Ot.toMillis():String(Ot),Xe=typeof ds=="number"?ds:Tn.isDateTime(ds)?ds.toMillis():String(ds);if(G.LT_LTE.some(Nt=>Se instanceof Nt)&&G.LT_LTE.some(Nt=>gt instanceof Nt))return i?Xe<mt?t:s:mt<=Xe?t:s;if(G.GT_GTE.some(Nt=>Se instanceof Nt)&&G.GT_GTE.some(Nt=>gt instanceof Nt))return i?mt<Xe?t:s:Xe<=mt?t:s;if(!i){if(Se instanceof Fe&&G.GT_GTE.some(Nt=>gt instanceof Nt)){if(mt<=Xe)return it()}else if(Se instanceof je&&G.LT_LTE.some(Nt=>gt instanceof Nt)){if(Xe<=mt)return it()}else if(Se instanceof Me){if(gt instanceof Fe)return Xe<=mt?it():Se;if(gt instanceof nt)return Xe<mt?it():Se;if(gt instanceof je)return mt<=Xe?it():Se;if(gt instanceof Je)return mt<Xe?it():Se;if(gt instanceof xt)return mt===Xe?it():Se}}}}}}flatSimplify(e,t,s){let{root:r}=s;if(!r&&e.sameParent)return e;let i=[],o=Array.from(e.flatten({unnest:!1})),c=o.length;for(;o.length;){let p=o.shift(),u=!1;for(let h of o){let g=t(e,p,h);if(g&&g!==e){o.splice(o.indexOf(h),1),o.unshift(g),u=!0;break}}u||i.push(p)}return i.length<c?i.reduce((p,u)=>new e._constructor({this:p,expression:u})):e}removeComplements(e,t={}){let{root:s=!0}=t;if(G.AND_OR.some(r=>e instanceof r)&&(s||!e.sameParent)){let r=Array.from(e.flatten()),i=new Set(r.map(o=>o.hash()));for(let o of r)if(o instanceof Le){let c=o.args.this;if(c&&i.has(c.hash())&&e.meta.nonnull===!0)return e instanceof Te?it():We()}}return e}simplifyCoalesce(e){if(e instanceof tt&&(e.args.expressions?.length===0||qW(e.args.this))&&!(e.parent instanceof Ps))return e.args.this;if(this.dialect._constructor.COALESCE_COMPARISON_NON_STANDARD||!G.COMPARISONS.some(u=>e instanceof u))return e;let t,s,r=e.args.this,i=e.args.expression;if(r instanceof tt)t=r,s=i;else if(i instanceof tt)t=i,s=r;else return e;if(!XI(s))return e;let o=-1;for(let u=0;u<(t.args.expressions?.length??0);u++){let h=t.args.expressions?.[u];if(XI(h)){o=u;break}}if(o===-1)return e;let c=t.args.expressions?.[o];t.setArgKey("expressions",t.args.expressions?.slice(0,o));let p=0<(t.args.expressions?.length??0)?t:t.args.this;return zs(Ht([ve([ks(p?.is(le()),{copy:!1}),e.copy()],{copy:!1}),ve([p?.is(le()),new e._constructor({this:c.copy(),expression:s.copy()})],{copy:!1})],{copy:!1}),{copy:!1})}simplifyLiterals(e,t={}){let{root:s=!0}=t;if(e instanceof v&&!(e instanceof Ae))return this.flatSimplify(e,(r,i,o)=>this.simplifyBinary(r,i,o),{root:s});if(e instanceof Pt&&e.args.this instanceof Pt)return e.args.this.args.this??e;if(G.INVERSE_DATE_OPS[e._constructor.key]){let r=e.args.this;if(r instanceof d&&e instanceof Zs)return this.simplifyBinary(e,r,e.interval())||e}return e}simplifyIntegerCast(e){if(!(e instanceof z))return e;let t=e.args.this,s;if(t instanceof z?s=this.simplifyIntegerCast(t):s=t,s instanceof d&&s.isInteger){let r=s.toValue(),i=e.args.to;if(!i)return e;if(i instanceof d&&(G.TINYINT_MIN<=r&&r<=G.TINYINT_MAX&&i.args.this&&N.SIGNED_INTEGER_TYPES.has(i.args.this)||G.UTINYINT_MIN<=r&&r<=G.UTINYINT_MAX&&i.args.this&&N.UNSIGNED_INTEGER_TYPES.has(i.args.this)))return s}return e}simplifyBinary(e,t,s){if(G.COMPARISONS.some(r=>e instanceof r)&&(t=this.simplifyIntegerCast(t),s=this.simplifyIntegerCast(s)),e instanceof ze){let r,i;if(s instanceof Le?(r=s.args.this,i=!0):(r=s,i=!1),_t(r)){if(t instanceof I)return i?We():it();if(_t(t))return i?it():We()}}else{if(G.NULL_OK.some(r=>e instanceof r))return;if((_t(t)||_t(s))&&e.parent instanceof xe)return le()}if(t.isNumber&&s.isNumber){let r=t.toValue(),i=s.toValue(),o=n(f=>{let T=f.match(/[eE]([+-]?\d+)/),y=T?parseInt(T[1]):0,b=f.replace(/[eE][+-]?\d+/,"").match(/\.(\d+)/),m=b?b[1].length:0;return Math.max(0,m-y)},"decimalPlaces"),c=String(t.args.this??""),p=String(s.args.this??""),u=o(c),h=o(p),g=n((f,T)=>0<T?f.toFixed(T):String(f),"fmt");if(e instanceof we)return I.number(g(r+i,Math.max(u,h)));if(e instanceof Ts)return I.number(g(r*i,u+h));if(e instanceof Ce)return t.parent===s.parent?I.number(g(r-i,Math.max(u,h))):void 0;if(e instanceof Mt){let f=!c.includes(".")&&!c.toLowerCase().includes("e"),T=!p.includes(".")&&!p.toLowerCase().includes("e");return f&&T||t.parent!==s.parent?void 0:I.number(kW(c,p))}let x=nD(e,r,i);if(x)return x}else if(t.isString&&s.isString){let r=t.args.this,i=s.args.this,o=nD(e,r,i);if(o)return o}else if(qr(t)&&s instanceof qe){let r=ws(t),i=cD(s);if(r&&i!==void 0){if(e instanceof we||e instanceof ft||e instanceof Ds)return fs(r.plus(i),oA(t));if(e instanceof Ce||e instanceof Xt||e instanceof Qs)return fs(r.minus(i),oA(t))}}else if(t instanceof qe&&qr(s)){let r=cD(t),i=ws(s);if(r!==void 0&&i&&e instanceof we)return fs(i.plus(r),oA(s))}else if(qr(t)&&qr(s)&&e instanceof ke){let r=ws(t),i=ws(s);if(r&&i){let o=nD(e,r.toMillis(),i.toMillis());if(o)return o}}}simplifyEquality(e){if(G.COMPARISONS.some(t=>e instanceof t)){let t=e.args.this,s=e.args.expression;if(!(t instanceof d)||!(s instanceof d))return e;let r=G.INVERSE_OPS[t._constructor.key];if(!r)return e;let i,o;if(s.isNumber)i=eY,o=eY;else if(qr(s))i=qr,o=DW;else return e;let c,p;if(G.INVERSE_DATE_OPS[t._constructor.key]?(c=t.args.this,p=t.interval()):(c=t.args.this,p=t.args.expression),!c||!p)return e;if(!(!i(c)&&o(p)))if(!i(p)&&o(c))[c,p]=[p,c];else return e;return new e._constructor({this:c,expression:new r({this:s,expression:p})})}return e}isDatetruncPredicate(e,t){return G.DATETRUNCS.some(s=>e instanceof s)&&qr(t)}simplifyDateTrunc(e){let t=e._constructor;if(G.DATETRUNCS.some(s=>e instanceof s)){let s=e,r=s.args.this,i=r&&oA(r),o=ws(r);if(o&&s.args.unit){let c=s.args.unit.name.toLowerCase();return fs(lA(o,c,this.dialect),i)}}else if(!G.DATETRUNC_COMPARISONS.has(t.key))return e;if(e instanceof v){let s=e.args.this,r=e.args.expression;if(!this.isDatetruncPredicate(s,r))return e;let i=s.args.unit.name.toLowerCase(),o=s.args.this,c=ws(r);return c&&G.DATETRUNC_BINARY_COMPARISONS[t.key]?.(o,c,i,this.dialect,oA(r))||e}if(e instanceof lt){let s=e.args.this,r=e.args.expressions;if(r&&r.every(i=>this.isDatetruncPredicate(s,i))){let i=s.args.unit.name.toLowerCase(),o=[];for(let u of r){let h=ws(u);if(!h)return e;let g=uD(h,i,this.dialect);g&&o.push(g)}if(o.length===0)return e;let c=UW(o),p=oA(...r.filter(u=>u instanceof d));return Ht(c.map(u=>MY(s,u,p)),{copy:!1})}}return e}sortComparison(e){if(Object.values(G.COMPLEMENT_COMPARISONS).some(t=>e instanceof t)){let t=e.args.this,s=e.args.expression,r=t instanceof $,i=s instanceof $,o=XI(t),c=XI(s);if(r&&!i||c&&!o||s instanceof Us)return e;if(i&&!r||o&&!c||aD(s)<aD(t)){let p=G.INVERSE_COMPARISONS[e._constructor.key]||e._constructor;return new p({this:s,expression:t})}}return e}simplifyStartsWith(e){return e instanceof Vl&&e.args.this instanceof d&&e.args.expression instanceof d&&e.args.this.isString&&e.args.expression.isString?e.args.this.name.startsWith(e.args.expression.name)?We():it():e}rewriteBetween(e){if(!(e instanceof Ss))return e;let s=e.parent instanceof Le,r=e.args.this,i=e.args.low,o=e.args.high;if(!(r instanceof d)||!(i instanceof d)||!(o instanceof d))return e;let c=ve([new Je({this:r.copy(),expression:i}),new nt({this:r.copy(),expression:o})],{copy:!1});return s&&(c=zs(c,{copy:!1})),c}uniqSort(e,t={}){let{root:s=!0}=t;if(!(e instanceof Ae)||!s&&e.sameParent)return e;let r=Array.from(e.flatten()),i,o,c;if(e instanceof hA)i=ED,o=void 0,c=r.map(p=>[this.genSql(p),p]);else{i=e instanceof Te?ve:Ht,o=new Map;for(let p of r){let u=this.genSql(p);o.has(u)||o.set(u,p)}c=Array.from(o.entries())}for(let p=1;p<c.length;p++)if(c[p][0]<c[p-1][0]){let u=c.sort((h,g)=>h[0]<g[0]?-1:g[0]<h[0]?1:0);return e=i(u.map(([,h])=>h),{copy:!1}),e}if(o&&o.size<r.length){let p=r[0];o.size===1?p instanceof d&&(e=ve([p,We()],{copy:!1})):e=i(Array.from(o.values()),{copy:!1})}return e}genSql(e){return aD(e)}};de=Ft(null),R(de,10,"SIMPLIFIABLE",wY,G),R(de,10,"COMPLEMENT_COMPARISONS",LY,G),R(de,10,"COMPLEMENT_SUBQUERY_PREDICATES",PY,G),R(de,10,"LT_LTE",bY,G),R(de,10,"GT_GTE",CY,G),R(de,10,"COMPARISONS",yY,G),R(de,10,"INVERSE_COMPARISONS",IY,G),R(de,10,"NONDETERMINISTIC",NY,G),R(de,10,"AND_OR",mY,G),R(de,10,"INVERSE_DATE_OPS",OY,G),R(de,10,"INVERSE_OPS",RY,G),R(de,10,"NULL_OK",SY,G),R(de,10,"CONCATS",TY,G),R(de,10,"DATETRUNC_BINARY_COMPARISONS",fY,G),R(de,10,"DATETRUNC_COMPARISONS",xY,G),R(de,10,"DATETRUNCS",dY,G),R(de,10,"SAFE_CONNECTOR_ELIMINATION_RESULT",AY,G),R(de,10,"JOINS",EY,G),R(de,1,"absorbAndEliminate",gY,G),R(de,1,"simplifyConcat",hY,G),R(de,1,"simplifyConditionals",uY,G),R(de,1,"simplifyNot",lY,G),R(de,1,"simplifyConnectors",pY,G),R(de,1,"removeComplements",cY,G),R(de,1,"simplifyCoalesce",oY,G),R(de,1,"simplifyLiterals",aY,G),R(de,1,"simplifyEquality",nY,G),R(de,1,"simplifyDateTrunc",iY,G),R(de,1,"sortComparison",rY,G),R(de,1,"simplifyStartsWith",sY,G),R(de,1,"uniqSort",tY,G),It(de,G),yt(de,3,G),n(G,"Simplifier"),G.TINYINT_MIN=-128,G.TINYINT_MAX=127,G.UTINYINT_MIN=0,G.UTINYINT_MAX=255;var nA=G;function aD(a,e={}){return new pD().gen(a,e)}n(aD,"gen");var gD=class gD{constructor(){this.stack=[];this.sqls=[]}gen(e,t={}){let{comments:s=!1}=t;for(this.stack=[e],this.sqls=[];0<this.stack.length;){let r=this.stack.pop();if(r instanceof d){s&&r.comments&&0<r.comments.length&&this.stack.push(` /*${r.comments.join(",")}*/`);let i=`${r._constructor.key}Sql`;if(typeof this[i]=="function")this[i].call(this,r);else if(r instanceof E)this.function(r);else{let o=r._constructor.key.toUpperCase();this.stack.push(this.args(r)?`${o} `:o)}}else if(Array.isArray(r)){let i=!1;for(let o=r.length-1;0<=o;o--){let c=r[o];if(c!=null)if(Array.isArray(c)&&typeof c[0]=="string"&&c[0].startsWith(":")){let[p,u]=c;this.stack.push(u),this.stack.push(p),i=!1}else Array.isArray(c)?(this.stack.push(c),this.stack.push(","),i=!0):(this.stack.push(c),this.stack.push(","),i=!0)}i&&this.stack.pop()}else r!=null&&this.sqls.push(String(r))}return this.sqls.join("")}addDql(e){this.binary(e," + ")}aliasSql(e){this.stack.push(e.args.alias," AS ",e.args.this)}andSql(e){this.binary(e," AND ")}anonymousSql(e){let t=e.args.this,s;if(typeof t=="string")s=t.toUpperCase();else if(t instanceof F){let r=t.args.this;s=t.args.quoted?`"${r}"`:String(r).toUpperCase()}else throw new Error(`Anonymous.args.this expects a string or an Identifier, got '${t?._constructor?.name||typeof t}'.`);this.stack.push(")",e.args.expressions||[],"(",s)}betweenSql(e){this.stack.push(e.args.high," AND ",e.args.low," BETWEEN ",e.args.this)}booleanSql(e){this.stack.push(e.args.this?"TRUE":"FALSE")}bracketSql(e){this.stack.push("]",e.args.expressions||[],"[",e.args.this)}columnSql(e){let t=e.parts;for(let s=t.length-1;0<=s;s--)this.stack.push(t[s],".");this.stack.pop()}dataTypeSql(e){this.args(e,1);let t=e.args.this,s=typeof t=="string"?t:String(t);this.stack.push(`${s} `)}divSql(e){this.binary(e," / ")}dotSql(e){this.binary(e,".")}eqSql(e){this.binary(e," = ")}fromSql(e){this.stack.push(e.args.this,"FROM ")}gtSql(e){this.binary(e," > ")}gteSql(e){this.binary(e," >= ")}identifierSql(e){let t=e.args.this,s=String(t);this.stack.push(e.args.quoted?`"${s}"`:s)}iLikeSql(e){this.binary(e," ILIKE ")}inSql(e){this.stack.push(")"),this.args(e,1),this.stack.push("("," IN ",e.args.this)}intdivSql(e){this.binary(e," DIV ")}isSql(e){this.binary(e," IS ")}likeSql(e){this.binary(e," LIKE ")}literalSql(e){let t=e.args.this;this.stack.push(e.isString?`'${t}'`:String(t))}ltSql(e){this.binary(e," < ")}lteSql(e){this.binary(e," <= ")}modSql(e){this.binary(e," % ")}mulSql(e){this.binary(e," * ")}negSql(e){this.unary(e,"-")}neqSql(e){this.binary(e," <> ")}notSql(e){this.unary(e,"NOT ")}nullSql(e){this.stack.push("NULL")}orSql(e){this.binary(e," OR ")}parenSql(e){this.stack.push(")",e.args.this,"(")}subSql(e){this.binary(e," - ")}subquerySql(e){this.args(e,2);let t=e.args.alias;t&&this.stack.push(t),this.stack.push(")",e.args.this,"(")}tableSql(e){this.args(e,4);let t=e.args.alias;t&&this.stack.push(t);let s=e.parts;for(let r=s.length-1;0<=r;r--)this.stack.push(s[r],".");this.stack.pop()}tableAliasSql(e){let t=e.columns;t&&0<t.length&&this.stack.push(")",t,"("),this.stack.push(e.args.this||[]," AS ")}varSql(e){this.stack.push(String(e.args.this))}binary(e,t){this.stack.push(e.args.expression,t,e.args.this)}unary(e,t){this.stack.push(e.args.this,t)}function(e){this.stack.push(")",Object.values(e.args),"(",e._constructor.sqlName())}args(e,t=0){let s=[],r=Array.from(e._constructor.availableArgs||[]),i=0<t?r.slice(t):r;for(let o of i){let c=e.getArgKey(o);c!=null&&s.push([`:${o}`,c])}return 0<s.length?(this.stack.push(s),!0):!1}};n(gD,"Gen");var pD=gD;function xD(a,e,t){let s=YW(e,t,1),r=k(s,0),i=r?` Did you mean ${r}?`:"";throw new Error(`Unknown ${a} '${e}'.${i}`)}n(xD,"suggestClosestMatchAndFail");function k(a,e){if(Array.isArray(a)){let r=e<0?a.length+e:e;return 0<=r&&r<a.length?a[r]:void 0}let t=[...a],s=e<0?t.length+e:e;return 0<=s&&s<t.length?t[s]:void 0}n(k,"seqGet");function OM(a){return typeof a=="boolean"||typeof a=="number"?String(a):a}n(OM,"expressionValueToOrString");function J(a){return a===void 0?[]:a instanceof d?[a]:typeof a!="string"&&GI(a)?[...a]:[a]}n(J,"ensureList");function zI(a,e={}){let{sep:t=", "}=e,s=[];for(let r of a)r&&s.push(r);return s.join(t??", ")}n(zI,"csv");function YW(a,e,t,s=.6){let r=[];for(let i of e){let o=VW(a,i);s<=o&&r.push({match:i,ratio:o})}return r.sort((i,o)=>o.ratio-i.ratio),r.slice(0,t).map(i=>i.match)}n(YW,"getCloseMatches");function VW(a,e){let t=e.length<a.length?a:e,s=e.length<a.length?e:a;if(t.length===0)return 1;let r=HW(s,t);return(t.length-r)/t.length}n(VW,"similarity");function HW(a,e){let t=[];for(let s=0;s<=e.length;s++)t[s]=[s];for(let s=0;s<=a.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let r=1;r<=a.length;r++)e.charAt(s-1)===a.charAt(r-1)?t[s][r]=t[s-1][r-1]:t[s][r]=Math.min(t[s-1][r-1]+1,t[s][r-1]+1,t[s-1][r]+1);return t[e.length][a.length]}n(HW,"levenshteinDistance");function yM(a){return a.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}n(yM,"snakeToCamelCase");function TM(a,e){let t=a;for(;;){let s=DY(t);t=e(t);let r=DY(t);if(s===r)break}return t}n(TM,"whileChanging");function DY(a){return a instanceof d?a.sql():JSON.stringify(a)}n(DY,"hashObject");function vY(a){let e=[],t=new Map(a);for(let[s,r]of Array.from(a.entries()))for(let i of Array.from(r))t.has(i)||t.set(i,new Set);for(;0<t.size;){let s=new Set;for(let[r,i]of Array.from(t.entries()))i.size===0&&s.add(r);if(s.size===0)throw new Error("Cycle error");for(let r of Array.from(s))t.delete(r);for(let r of Array.from(t.values()))for(let i of Array.from(s))r.delete(i);e.push(...Array.from(s).sort())}return e}n(vY,"tsort");function En(a,e){let t=new Set(a);if(!t.has(e))return e;let s=2,r=`${e}_${s}`;for(;t.has(r);)s++,r=`${e}_${s}`;return r}n(En,"findNewName");function FY(a){return a?_W(a,e=>{let t=Number(e);return Number.isInteger(t)}):!1}n(FY,"isInt");function _W(a,e){try{return e(a)}catch{return!1}}n(_W,"isType");function CM(a){let e=0;return()=>`${a}${e++}`}n(CM,"nameSequence");function BY(a,e,t,s={}){let{fillFromStart:r=!0}=s,i=a.split(e),o=Math.max(0,t-i.length);return r?[...Array(o).fill(void 0),...i]:[...i,...Array(o).fill(void 0)]}n(BY,"splitNumWords");function gA(a){try{if(typeof a!="object"||a===null||a.constructor!==Object)return 0;let e=Object.values(a);return e.length===0?1:1+gA(e[0])}catch{return 0}}n(gA,"objectDepth");function lD(a){for(let e of a)return e;throw new Error("Iterable is empty")}n(lD,"first");function $Y(a){if(typeof a=="boolean"||a===void 0)return a;let e=a.toLowerCase();return e==="true"||e==="1"?!0:e==="false"||e==="0"?!1:a}n($Y,"toBool");function EA(a){return UY.fromISO(a).isValid&&/^\d{4}-\d{2}-\d{2}$/.test(a)}n(EA,"isIsoDate");function QI(a){return UY.fromSQL(a).isValid}n(QI,"isIsoDatetime");var WW=new Set(["day","week","month","quarter","year","year_month"]);function AA(a){return a!==void 0&&WW.has(a.name.toLowerCase())}n(AA,"isDateUnit");var fD=class fD{constructor(e,t){this._keys=new Set(e),this._value=t}get(e){return this._keys.has(e)?this._value:void 0}has(e){return this._keys.has(e)}get size(){return this._keys.size}*[Symbol.iterator](){for(let e of Array.from(this._keys))yield[e,this._value]}*entries(){for(let e of Array.from(this._keys))yield[e,this._value]}keys(){return this._keys.values()}*values(){for(let e of Array.from(this._keys))yield this._value}forEach(e,t){for(let s of Array.from(this._keys))e.call(t,this._value,s,this)}clear(){throw new Error("Method not supported")}delete(e){throw new Error("Method not supported")}set(e,t){throw new Error("Method not supported")}get[Symbol.toStringTag](){return"SingleValuedMapping"}};n(fD,"SingleValuedMapping");var qY=fD;function dA(a,e,t,s){let r=[...e];if(!t||r.length!==1)return r;let i=r[0];a.type||Kt(a,{dialect:s?.dialect});let o=a.type;if(o?.args.this!=="unknown"&&o?.args.this!=="array")return r;i.type||Kt(i,{dialect:s?.dialect});let c=i.type;if(c?.args.this&&N.INTEGER_TYPES?.has(c.args.this)){console.info(`Applying array index offset (${t})`);let p=new we({this:i,expression:Hl(t)});return[IM(p)]}return r}n(dA,"applyIndexOffset");function GY(a,e){return a instanceof d?e==="name"?a.name:e==="sql"?a.sql():e(a):a}n(GY,"mapOnExpression");function bM(a){return a.replace(/([A-Z])/g,"_$1").toUpperCase()}n(bM,"camelToScreamingSnakeCase");var jW=new Set(["EPOCH_SECOND","EPOCH_MILLISECOND","EPOCH_MICROSECOND","EPOCH_NANOSECOND","NANOSECOND"]);function Kt(a,e={}){let{schema:t,expressionMetadata:s,coercesTo:r,dialect:i,overwriteTypes:o=!0}=e,c=NM(t,{dialect:i});return new Yl({schema:c,expressionMetadata:s,coercesTo:r,overwriteTypes:o}).annotate(a)}n(Kt,"annotateTypes");function YY(a,e){let t=a.name,s=EA(t);return s&&AA(e)?"date":s||QI(t)?"datetime":"unknown"}n(YY,"coerceDateLiteral");function VY(a,e){if(!AA(e))return"datetime";let t=a.type?.args.this;return typeof t=="string"?t:t instanceof F?t.args.this:"unknown"}n(VY,"coerceDate");function XW(a){return(e,t)=>a(t,e)}n(XW,"swapArgs");function JW(a){let e=new KE;for(let[[t,s],r]of a)e.set(t,s,r),e.set(s,t,XW(r));return e}n(JW,"swapAll");var HY,_Y,WY,ZI;WY=[O],_Y=[O],HY=[O];var er=class er{constructor(e){this.schema=void 0;this.dialect=void 0;this.overwriteTypes=void 0;this.expressionMetadata=void 0;this.coercesTo=void 0;this.binaryCoercions=void 0;this.visited=void 0;this.nullExpressions=void 0;this.supportsNullType=void 0;this.setopColumnTypes=void 0;this.scopeSelects=void 0;let{schema:t,expressionMetadata:s,coercesTo:r,binaryCoercions:i,overwriteTypes:o=!0}=e;if(this.schema=t,this.dialect=t.dialect||new ae,this.overwriteTypes=o,this.expressionMetadata=s??this.dialect._constructor.EXPRESSION_METADATA,r)this.coercesTo=r;else{let c=this.dialect._constructor.COERCES_TO;c instanceof Map&&0<c.size?this.coercesTo=c:!(c instanceof Map)&&0<Object.keys(c).length?this.coercesTo=new Map(Object.entries(c).map(([p,u])=>[p,new Set(u)])):this.coercesTo=er.COERCES_TO}this.binaryCoercions=i??er.BINARY_COERCIONS,this.visited=new Set,this.nullExpressions=new Map,this.supportsNullType=this.dialect._constructor.SUPPORTS_NULL_TYPE,this.setopColumnTypes=new Map,this.scopeSelects=new Map}static get NESTED_TYPES(){return new Set(["array"])}static get COERCES_TO(){let e=new Map,t=["text","nvarchar","varchar","nchar","char"],s=["decfloat","double","float","bigdecimal","decimal","bigint","int","smallint","tinyint"],r=["timestampltz","timestamptz","timestamp","datetime","date"];for(let i of[t,s,r]){let o=new Set;for(let c of i)e.set(c,new Set(o)),o.add(c)}return e}static get BINARY_COERCIONS(){return JW((()=>{let e=new KE;for(let t of N.TEXT_TYPES)e.set(t,"interval",(s,r)=>YY(s,r.unit));for(let t of N.TEXT_TYPES)for(let s of N.NUMERIC_TYPES)e.set(t,s,(r,i)=>{let o=r.type?.args.this;return N.NUMERIC_TYPES.has(o)?o:i.type?.args.this});return e.set("date","interval",(t,s)=>VY(t,s.unit)),e})())}clear(){this.visited.clear(),this.nullExpressions.clear(),this.setopColumnTypes.clear(),this.scopeSelects.clear()}annotate(e,t={}){let{annotateScope:s=!0}=t;if(s)for(let i of sA(e))this.annotateScope(i);this.annotateExpression(e);let r=this.dialect._constructor.DEFAULT_NULL_TYPE;for(let[,i]of this.nullExpressions)i.type=r;return e}annotateScope(e){if(this.schema instanceof KI)for(let t of e.tableColumns){let s=e.sources.get(t.name);if(s instanceof W){let r=this.schema.find(s,{raiseOnMissing:!1,ensureDataTypes:!0});if(typeof r!="object"||!r)continue;let i=new N({this:"struct",expressions:Object.entries(r).map(([o,c])=>new Pe({this:Z(o),kind:c})),nested:!0});this.setType(t,i)}else s instanceof js&&s.expression instanceof ee&&(s.expression.meta.queryType||N.build("unknown")).isType("struct")&&this.setType(t,s.expression.meta.queryType)}if(this.annotateExpression(e.expression,e),this.fixupOrderByAliases(e),this.dialect._constructor.QUERY_RESULTS_ARE_STRUCTS&&e.expression instanceof ee){let t=new N({this:"struct",expressions:e.expression.selects.map(s=>new Pe({this:Z(s.outputName),kind:s.type instanceof d?s.type.name:s.type||""})),nested:!0});t.args.expressions?.some(s=>{let r=s.args.kind;return r?typeof r=="string"?r==="unknown":r.isType("unknown"):!0})||(e.expression.meta.queryType=t)}}getScopeSelects(e){let t=this.scopeSelects.get(e);if(t!==void 0)return t;let s=new Map;for(let[r,i]of e.sources){if(!(i instanceof js))continue;let o=i.expression;if(o instanceof Ct&&!(o instanceof _l)){let c=[];if(o instanceof bt){let u=o.args.this;u instanceof Jt&&(c=[u.args.this])}else if(o instanceof Ee)c=[o];else{let u=k(o.args.expressions??[],0);u&&(c=u instanceof d?u.args.expressions:[])}if(c.length===0)continue;let p=o.aliasColumnNames;if(o instanceof Ee&&o.type instanceof d&&o.type.isType("struct")){let u={};for(let h of o.type.args.expressions||[]){let g=h.name,x=h.args.kind;g&&(u[g]=x)}s.set(r,u)}else{let u={};for(let h=0;h<p.length&&h<c.length;h++){let g=c[h].type;u[p[h]]=Y(g,N)||Y(g,Pe)?g:void 0}s.set(r,u)}}else if(o instanceof Ge&&Y(o.left,ee)&&Y(o.right,ee)&&o.left.selects.length===o.right.selects.length)s.set(r,this.getSetopColumnTypes(o));else{let c={};for(let p of o.selects){let u=p.type;c[p.aliasOrName]=Y(u,N)||Y(u,Pe)?u:void 0}s.set(r,c)}}return this.scopeSelects.set(e,s),s}getSetopColumnTypes(e){let t=this.setopColumnTypes.get(e);if(t!==void 0)return t;let s={},r=e.left,i=e.right;if(!Y(r,ee)||!Y(i,ee)||!r.selects.length||!i.selects.length||r.selects.length!==i.selects.length)return s;for(let o of e.walk({prune:n(c=>!(c instanceof Ge)&&!(c instanceof he),"prune")})){if(!(o instanceof Ge))continue;let c,p=o.left,u=o.right;if(re(p,ee),re(u,ee),o.args.byName){let h={};for(let g of u.selects){let x=g.type;h[g.aliasOrName]=Y(x,N)||Y(x,Pe)?x:void 0}c={};for(let g of p.selects){let x=g.type,f=(Y(x,N)?x:void 0)??"unknown",T=h[g.aliasOrName]??"unknown";c[g.aliasOrName]=this.maybeCoerce(f,T)}}else{c={};for(let h=0;h<p.selects.length;h++){let g=p.selects[h],x=u.selects[h],f=g.type,T=x.type,y=(Y(f,N)?f:void 0)??"unknown",b=(Y(T,N)?T:void 0)??"unknown";c[g.aliasOrName]=this.maybeCoerce(y,b)}}for(let[h,g]of Object.entries(c)){let x=s[h]??"null";s[h]=this.maybeCoerce(g,x)}}return this.setopColumnTypes.set(e,s),s}annotateExpression(e,t){let s=[[e,!1]];for(;0<s.length;){let[r,i]=s.pop();if(this.visited.has(r)||!this.overwriteTypes&&r.type&&!r.isType("unknown"))continue;if(!i){s.push([r,!0]);for(let c of r.iterExpressions())s.push([c,!1]);continue}if(t&&r instanceof $&&r.args.table){let c,p=t;for(;p&&!c;)c=p.sources.get(r.table),c||(p=p.parent);if(c instanceof W)this.setType(r,this.schema.getColumnType?.(c,r));else if(c){let u=p?this.getScopeSelects(p).get(r.table)?.[r.name]:void 0;if(u)this.setType(r,u);else if(c.expression instanceof Ee){let h=c.expression.type;this.setType(r,Y(h,N)?h:void 0)}else this.setType(r,"unknown")}else this.setType(r,"unknown");r.type?.getArgKey("nullable")===!1&&(r.meta.nonnull=!0);continue}let o=this.expressionMetadata.get(r._constructor);if(o){if(o.annotator){o.annotator(this,r);continue}if(o.returns!==void 0){this.setType(r,o.returns);continue}}if(r instanceof wt){this.annotateBracket(r);continue}if(r instanceof v){this.annotateBinary(r);continue}if(r instanceof qs){this.annotateUnary(r);continue}r instanceof z||r instanceof Gt||this.setType(r,"unknown")}}fixupOrderByAliases(e){let t=e.expression;if(!(t instanceof ee))return;let s=t.getArgKey("order");if(!s)return;let r=new Map;for(let i of t.selects)i instanceof Oe&&i.args.this instanceof d&&i.args.this.type&&!Rn(i.args.this,"unknown")&&r.set(i.alias,i.args.this.type);if(r.size)for(let i of s.args.expressions??[]){let o=[...i.findAll($)].filter(c=>!c.table&&r.has(c.name));for(let c of o)this.setType(c,r.get(c.name));if(o.length){for(let c of i.walk({prune:n(p=>p instanceof he,"prune")}))!(c instanceof $)&&!(c instanceof I)&&this.visited.delete(c);this.annotateExpression(i,e)}}}maybeCoerce(e,t){let s;if(e instanceof N){if(e.args.expressions&&0<e.args.expressions.length)return e;s=e.args.this}else s=e??"unknown";let r;if(t instanceof N){if(t.args.expressions&&0<t.args.expressions.length)return t;r=t.args.this}else r=t??"unknown";return s==="unknown"||r==="unknown"?"unknown":s==="null"?r:r==="null"?s:this.coercesTo.get(s)?.has(r)?r:s}setType(e,t){let s=e.type;if(e.type=t??"unknown",this.visited.add(e),!this.supportsNullType&&e.type?.args.this==="null"?this.nullExpressions.set(e,e):s?.isType("null")&&this.nullExpressions.delete(e),e instanceof $&&e.isType("json")&&e.meta.dotParts){let i=e.meta.dotParts[Symbol.iterator](),o=e.parent;for(;o instanceof ge;){let c=i.next();c.done||o.setArgKey("expression",Z(c.value,{quoted:!0})),o=o.parent}delete e.meta.dotParts}return e}annotateBinary(e){let t=e.left,s=e.right;if(!t||!s){this.setType(e);return}let r=t.type?.args.this?.toString(),i=s.type?.args.this?.toString();if(e instanceof Ae||e instanceof ke)this.setType(e,"boolean");else{let o=this.binaryCoercions.get(r,i);o?this.setType(e,o(t,s)):this.annotateByArgs(e,[t,s])}(e instanceof ze||t.meta.nonnull===!0&&s.meta.nonnull===!0)&&(e.meta.nonnull=!0)}annotateUnary(e){if(e instanceof Le)this.setType(e,"boolean");else{let r=e.args.this?.type;this.setType(e,r)}e.args.this?.meta.nonnull===!0&&(e.meta.nonnull=!0)}annotateLiteral(e){e.args.isString?this.setType(e,"varchar"):e.isInteger?this.setType(e,"int"):this.setType(e,"double"),e.meta.nonnull=!0}annotateByArgs(e,t,s={}){let{promote:r=!1,array:i=!1}=s,o,c,p;e:for(let h of t){let g;if(typeof h=="string"){let x=e.args[h];g=J(x)}else Array.isArray(h)?g=h:g=[h];for(let x of g){if(!(x instanceof d))continue;let f=x.type;if(!f)continue;let T=Y(f,N)||Y(f,Pe)?f:void 0;if(T){if(T.getArgKey("nested")){p=T;break e}x instanceof I?o=this.maybeCoerce(o??T,T):c=this.maybeCoerce(c??T,T)}}}let u;if(p)u=p;else if(o!==void 0&&c!==void 0){if(this.dialect._constructor.PRIORITIZE_NON_LITERAL_TYPES){let h=o instanceof N?o.args.this:o,g=c instanceof N?c.args.this:c;(N.INTEGER_TYPES.has(h)&&N.INTEGER_TYPES.has(g)||N.REAL_TYPES.has(h)&&N.REAL_TYPES.has(g))&&(u=c)}}else u=o??c??"unknown";if(this.setType(e,u??this.maybeCoerce(c??void 0,o??void 0)),r){let h=e.type?.args.this;N.INTEGER_TYPES.has(h)?this.setType(e,"bigint"):N.FLOAT_TYPES.has(h)&&this.setType(e,"double")}if(i){let h=e.type?.copy()??new N({this:"unknown"});this.setType(e,new N({this:"array",expressions:[h],nested:!0}))}}annotateTimeunit(e){let t=e.args.this;if(!t?.type){this.setType(e,"unknown");return}let s=t.type.args.this,r;if(N.TEXT_TYPES.has(s)){let i=e.unit;r=YY(t,i)}else if(N.TEMPORAL_TYPES.has(s)){let i=e.unit;r=VY(t,i)}else r="unknown";this.setType(e,r)}annotateBracket(e){let t=k(e.args.expressions??[],0),s=e.args.this;if(t instanceof On){let r=s.type;this.setType(e,Y(r,N)?r:void 0)}else if(s.type?.isType("array")){let r=k(s.type.args.expressions??[],0);this.setType(e,r)}else if(s instanceof mn||s instanceof Rs){let r=s.keys;if(t){let i=r.findIndex(o=>o instanceof d&&o.equals(t));if(0<=i){let o=s.values,c=k(o,i),p=c instanceof d?c.type:void 0;this.setType(e,Y(p,N)?p:void 0)}else this.setType(e,"unknown")}else this.setType(e,"unknown")}else this.setType(e,"unknown")}annotateDiv(e){let t=e.left,s=e.right,r=t?.type?.args.this,i=s?.type?.args.this;if(e.args.typed&&N.INTEGER_TYPES.has(r)&&N.INTEGER_TYPES.has(i))this.setType(e,"bigint");else{this.setType(e,this.maybeCoerce(r,i));let o=e.type?.args.this;if(!N.REAL_TYPES.has(o)){let c=e.type;this.setType(e,this.maybeCoerce(Y(c,N)?c:void 0,"double"))}}}annotateDot(e){this.setType(e);let t=e.args.expression;if(t instanceof Qe){let r=t.type;this.setType(e,Y(r,N)?r:void 0);return}let s=e.args.this?.type;if(Rn(s,"struct")){for(let r of s?.args.expressions||[])if(r.name===t?.name){let i=r.args.kind;this.setType(e,i);break}}}annotateExtract(e){let t=e.name?.toUpperCase();t==="TIME"?this.setType(e,"time"):t==="DATE"?this.setType(e,"date"):t&&jW.has(t)?this.setType(e,"bigint"):this.setType(e,"int")}annotateExplode(e){let t=e.args.this,s=k(t?.type?.args.expressions??[],0);this.setType(e,s)}annotateUnnest(e){let t=k(e.args.expressions??[],0),s;t instanceof d&&t.isType("array")&&(s=k(t.type?.args.expressions??[],0)),this.setType(e,s)}annotateSubquery(e){let t=e.unnest();if(t instanceof ee){let s=t.selects;if(s.length===1){let r=s[0].type;this.setType(e,Y(r,N)||Y(r,Pe)?r:void 0);return}}this.setType(e,"unknown")}annotateStructValue(e){let t,s=e.type,r=Y(s,N)||Y(s,Pe)?s:void 0,i=e.args.alias;if(i instanceof d)t=i.copy();else if(e.args.expression instanceof d){t=e.args.this?.copy();let o=e.args.expression?.type;r=Y(o,N)||Y(o,Pe)?o:void 0}else e instanceof $&&(t=e.args.this?.copy());if(!(Y(r,N)&&r.isType("unknown")))return t?new Pe({this:t,kind:r}):r??"unknown"}annotateStruct(e){let t=[];for(let s of e.args.expressions){let r=this.annotateStructValue(s);if(r===void 0){this.setType(e);return}t.push(r)}this.setType(e,new N({this:"struct",expressions:t,nested:!0}))}annotateMap(e){let t,s;if(e instanceof Rs)t=e.args.keys,s=e.args.values;else{let i=e.args.keys,o=e.args.values;t=i?.[0]instanceof ue?i[0]:void 0,s=o?.[0]instanceof ue?o[0]:void 0}let r=new N({this:"map"});if(t instanceof ue&&s instanceof ue){let i=k(t.type?.args.expressions??[],0),o=k(s.type?.args.expressions??[],0),c=i instanceof N?i.args.this:i,p=o instanceof N?o.args.this:o;c!=="unknown"&&p!=="unknown"&&(r.setArgKey("expressions",[i??new N({this:"unknown"}),o??new N({this:"unknown"})]),r.setArgKey("nested",!0))}this.setType(e,r)}annotateToMap(e){let t=new N({this:"map"}),s=e.args.this;if(s?.isType("struct")&&s.type instanceof d)for(let r of s.type.args.expressions||[]){let i=r.args.kind,o=i instanceof N?i.args.this:i;if(o!=="unknown"){let c=N.build("varchar");t.setArgKey("expressions",[...c?[c]:[],i instanceof N?i:new N({this:o??"unknown"})]),t.args.nested=!0;break}}this.setType(e,t)}annotateByArrayElement(e){let t=e.args.this;if(t?.type?.isType("array")){let s=k(t.type.args.expressions??[],0);this.setType(e,s??"unknown")}else this.setType(e,"unknown")}};ZI=Ft(null),R(ZI,10,"NESTED_TYPES",WY,er),R(ZI,10,"COERCES_TO",_Y,er),R(ZI,10,"BINARY_COERCIONS",HY,er),It(ZI,er),yt(ZI,3,er),n(er,"TypeAnnotator");var Yl=er;function Yt(a,e){let t=e??{};for(let s of a){let r=t;for(let i of s)r[i]||(r[i]={}),r=r[i];r["\0"]=!0}return t}n(Yt,"newTrie");function Nn(a,e){let t=Array.from(e);if(!t.length)return[0,a];let s=a;for(let r of t){if(!s[r])return[0,s];s=s[r]}return s["\0"]?[2,s]:[1,s]}n(Nn,"inTrie");var PM=(A=>(A.L_PAREN="lParen",A.R_PAREN="rParen",A.L_BRACKET="lBracket",A.R_BRACKET="rBracket",A.L_BRACE="lBrace",A.R_BRACE="rBrace",A.COMMA="comma",A.DOT="dot",A.DASH="dash",A.PLUS="plus",A.COLON="colon",A.DOTCOLON="dotcolon",A.DOTCARET="dotcaret",A.DCOLON="dcolon",A.DCOLONDOLLAR="dcolondollar",A.DCOLONPERCENT="dcolonpercent",A.DCOLONQMARK="dcolonqmark",A.DQMARK="dqmark",A.SEMICOLON="semicolon",A.STAR="star",A.BACKSLASH="backslash",A.SLASH="slash",A.LT="lt",A.LTE="lte",A.GT="gt",A.GTE="gte",A.NOT="not",A.EQ="eq",A.NEQ="neq",A.NULLSAFE_EQ="nullsafeEq",A.COLON_EQ="colonEq",A.COLON_GT="colonGt",A.NCOLON_GT="ncolonGt",A.AND="and",A.OR="or",A.AMP="amp",A.DPIPE="dpipe",A.PIPE_GT="pipeGt",A.PIPE="pipe",A.PIPE_SLASH="pipeSlash",A.DPIPE_SLASH="dpipeSlash",A.CARET="caret",A.CARET_AT="caretAt",A.TILDE="tilde",A.ARROW="arrow",A.DARROW="darrow",A.FARROW="farrow",A.HASH="hash",A.HASH_ARROW="hashArrow",A.DHASH_ARROW="dhashArrow",A.LR_ARROW="lrArrow",A.DAT="dat",A.LT_AT="ltAt",A.AT_GT="atGt",A.DOLLAR="dollar",A.PARAMETER="parameter",A.SESSION="session",A.SESSION_PARAMETER="sessionParameter",A.SESSION_USER="sessionUser",A.DAMP="damp",A.AMP_LT="ampLt",A.AMP_GT="ampGt",A.ADJACENT="adjacent",A.XOR="xor",A.DSTAR="dstar",A.QMARK_AMP="qmarkAmp",A.QMARK_PIPE="qmarkPipe",A.HASH_DASH="hashDash",A.EXCLAMATION="exclamation",A.URI_START="uriStart",A.BLOCK_START="blockStart",A.BLOCK_END="blockEnd",A.SPACE="space",A.BREAK="break",A.STRING="string",A.NUMBER="number",A.IDENTIFIER="identifier",A.DATABASE="database",A.COLUMN="column",A.COLUMN_DEF="columnDef",A.SCHEMA="schema",A.TABLE="table",A.WAREHOUSE="warehouse",A.STAGE="stage",A.STREAM="stream",A.STREAMLIT="streamlit",A.VAR="var",A.BIT_STRING="bitString",A.HEX_STRING="hexString",A.BYTE_STRING="byteString",A.NATIONAL_STRING="nationalString",A.RAW_STRING="rawString",A.HEREDOC_STRING="heredocString",A.UNICODE_STRING="unicodeString",A.BIT="bit",A.BOOLEAN="boolean",A.TINYINT="tinyint",A.UTINYINT="utinyint",A.SMALLINT="smallint",A.USMALLINT="usmallint",A.MEDIUMINT="mediumint",A.UMEDIUMINT="umediumint",A.INT="int",A.UINT="uint",A.BIGINT="bigint",A.UBIGINT="ubigint",A.BIGNUM="bignum",A.INT128="int128",A.UINT128="uint128",A.INT256="int256",A.UINT256="uint256",A.FLOAT="float",A.DOUBLE="double",A.UDOUBLE="udouble",A.DECIMAL="decimal",A.DECIMAL32="decimal32",A.DECIMAL64="decimal64",A.DECIMAL128="decimal128",A.DECIMAL256="decimal256",A.DECFLOAT="decfloat",A.UDECIMAL="udecimal",A.BIGDECIMAL="bigdecimal",A.CHAR="char",A.NCHAR="nchar",A.VARCHAR="varchar",A.NVARCHAR="nvarchar",A.BPCHAR="bpchar",A.TEXT="text",A.MEDIUMTEXT="mediumtext",A.LONGTEXT="longtext",A.BLOB="blob",A.MEDIUMBLOB="mediumblob",A.LONGBLOB="longblob",A.TINYBLOB="tinyblob",A.TINYTEXT="tinytext",A.NAME="name",A.BINARY="binary",A.VARBINARY="varbinary",A.JSON="json",A.JSONB="jsonb",A.TIME="time",A.TIMETZ="timetz",A.TIME_NS="timeNs",A.TIMESTAMP="timestamp",A.TIMESTAMPTZ="timestamptz",A.TIMESTAMPLTZ="timestampltz",A.TIMESTAMPNTZ="timestampntz",A.TIMESTAMP_S="timestampS",A.TIMESTAMP_MS="timestampMs",A.TIMESTAMP_NS="timestampNs",A.DATETIME="datetime",A.DATETIME2="datetime2",A.DATETIME64="datetime64",A.SMALLDATETIME="smalldatetime",A.DATE="date",A.DATE32="date32",A.INT4RANGE="int4range",A.INT4MULTIRANGE="int4multirange",A.INT8RANGE="int8range",A.INT8MULTIRANGE="int8multirange",A.NUMRANGE="numrange",A.NUMMULTIRANGE="nummultirange",A.TSRANGE="tsrange",A.TSMULTIRANGE="tsmultirange",A.TSTZRANGE="tstzrange",A.TSTZMULTIRANGE="tstzmultirange",A.DATERANGE="daterange",A.DATEMULTIRANGE="datemultirange",A.UUID="uuid",A.GEOGRAPHY="geography",A.GEOGRAPHYPOINT="geographypoint",A.NULLABLE="nullable",A.GEOMETRY="geometry",A.POINT="point",A.RING="ring",A.LINESTRING="linestring",A.LOCALTIME="localtime",A.LOCALTIMESTAMP="localtimestamp",A.SYSTIMESTAMP="systimestamp",A.MULTILINESTRING="multilinestring",A.POLYGON="polygon",A.MULTIPOLYGON="multipolygon",A.HLLSKETCH="hllsketch",A.HSTORE="hstore",A.SUPER="super",A.SERIAL="serial",A.SMALLSERIAL="smallserial",A.BIGSERIAL="bigserial",A.XML="xml",A.YEAR="year",A.USERDEFINED="userdefined",A.MONEY="money",A.SMALLMONEY="smallmoney",A.ROWVERSION="rowversion",A.IMAGE="image",A.VARIANT="variant",A.OBJECT="object",A.INET="inet",A.IPADDRESS="ipaddress",A.IPPREFIX="ipprefix",A.IPV4="ipv4",A.IPV6="ipv6",A.ENUM="enum",A.ENUM8="enum8",A.ENUM16="enum16",A.FIXEDSTRING="fixedstring",A.LOWCARDINALITY="lowcardinality",A.NESTED="nested",A.AGGREGATEFUNCTION="aggregatefunction",A.SIMPLEAGGREGATEFUNCTION="simpleaggregatefunction",A.TDIGEST="tdigest",A.UNKNOWN="unknown",A.VECTOR="vector",A.DYNAMIC="dynamic",A.VOID="void",A.ALIAS="alias",A.ALTER="alter",A.ALL="all",A.ANTI="anti",A.ANY="any",A.APPLY="apply",A.ARRAY="array",A.ASC="asc",A.ASOF="asof",A.ATTACH="attach",A.AUTO_INCREMENT="autoIncrement",A.BEGIN="begin",A.BETWEEN="between",A.BULK_COLLECT_INTO="bulkCollectInto",A.CACHE="cache",A.CASE="case",A.CHARACTER_SET="characterSet",A.CLUSTER_BY="clusterBy",A.COLLATE="collate",A.COMMAND="command",A.COMMENT="comment",A.COMMIT="commit",A.CONNECT_BY="connectBy",A.CONSTRAINT="constraint",A.COPY="copy",A.CREATE="create",A.CROSS="cross",A.CUBE="cube",A.CURRENT_DATE="currentDate",A.CURRENT_DATETIME="currentDatetime",A.CURRENT_SCHEMA="currentSchema",A.CURRENT_TIME="currentTime",A.CURRENT_TIMESTAMP="currentTimestamp",A.CURRENT_USER="currentUser",A.CURRENT_ROLE="currentRole",A.CURRENT_CATALOG="currentCatalog",A.DECLARE="declare",A.DEFAULT="default",A.DELETE="delete",A.DESC="desc",A.DESCRIBE="describe",A.DETACH="detach",A.DICTIONARY="dictionary",A.DISTINCT="distinct",A.DISTRIBUTE_BY="distributeBy",A.DIV="div",A.DROP="drop",A.ELSE="else",A.END="end",A.ESCAPE="escape",A.EXCEPT="except",A.EXECUTE="execute",A.EXISTS="exists",A.FALSE="false",A.FETCH="fetch",A.FILE="file",A.FILE_FORMAT="fileFormat",A.FILTER="filter",A.FINAL="final",A.FIRST="first",A.FOR="for",A.FORCE="force",A.FOREIGN_KEY="foreignKey",A.FORMAT="format",A.FROM="from",A.FULL="full",A.FUNCTION="function",A.GET="get",A.GLOB="glob",A.GLOBAL="global",A.GRANT="grant",A.GROUP_BY="groupBy",A.GROUPING_SETS="groupingSets",A.HAVING="having",A.HINT="hint",A.IGNORE="ignore",A.ILIKE="ilike",A.IN="in",A.INDEX="index",A.INDEXED_BY="indexedBy",A.INNER="inner",A.INSERT="insert",A.INSTALL="install",A.INTEGRATION="integration",A.INTERSECT="intersect",A.INTERVAL="interval",A.INTO="into",A.INTRODUCER="introducer",A.IRLIKE="irlike",A.IS="is",A.ISNULL="isnull",A.JOIN="join",A.JOIN_MARKER="joinMarker",A.KEEP="keep",A.KEY="key",A.KILL="kill",A.LANGUAGE="language",A.LATERAL="lateral",A.LEFT="left",A.LIKE="like",A.LIMIT="limit",A.LIST="list",A.LOAD="load",A.LOCK="lock",A.MAP="map",A.MATCH="match",A.MATCH_CONDITION="matchCondition",A.MATCH_RECOGNIZE="matchRecognize",A.MEMBER_OF="memberOf",A.MERGE="merge",A.MOD="mod",A.MODEL="model",A.NATURAL="natural",A.NEXT="next",A.NOTHING="nothing",A.NOTNULL="notnull",A.NULL="null",A.OBJECT_IDENTIFIER="objectIdentifier",A.OFFSET="offset",A.ON="on",A.ONLY="only",A.OPERATOR="operator",A.ORDER_BY="orderBy",A.ORDER_SIBLINGS_BY="orderSiblingsBy",A.ORDERED="ordered",A.ORDINALITY="ordinality",A.OUT="out",A.INOUT="inout",A.OUTER="outer",A.OVER="over",A.OVERLAPS="overlaps",A.OVERWRITE="overwrite",A.PACKAGE="package",A.PARTITION="partition",A.PARTITION_BY="partitionBy",A.PERCENT="percent",A.PIVOT="pivot",A.PLACEHOLDER="placeholder",A.POLICY="policy",A.POOL="pool",A.POSITIONAL="positional",A.PRAGMA="pragma",A.PREWHERE="prewhere",A.PRIMARY_KEY="primaryKey",A.PROCEDURE="procedure",A.PROPERTIES="properties",A.PSEUDO_TYPE="pseudoType",A.PUT="put",A.QUALIFY="qualify",A.QUOTE="quote",A.QDCOLON="qdcolon",A.RANGE="range",A.RECURSIVE="recursive",A.REFRESH="refresh",A.RENAME="rename",A.REPLACE="replace",A.RETURNING="returning",A.REVOKE="revoke",A.REFERENCES="references",A.RIGHT="right",A.RLIKE="rlike",A.ROLE="role",A.ROLLBACK="rollback",A.ROLLUP="rollup",A.ROW="row",A.RULE="rule",A.ROWS="rows",A.SELECT="select",A.SEMI="semi",A.SEPARATOR="separator",A.SEQUENCE="sequence",A.SERDE_PROPERTIES="serdeProperties",A.SET="set",A.SETTINGS="settings",A.SHOW="show",A.SIMILAR_TO="similarTo",A.SOME="some",A.SORT_BY="sortBy",A.SOUNDS_LIKE="soundsLike",A.SQL_SECURITY="sqlSecurity",A.START_WITH="startWith",A.STORAGE_INTEGRATION="storageIntegration",A.STRAIGHT_JOIN="straightJoin",A.STRUCT="struct",A.SUMMARIZE="summarize",A.TABLE_SAMPLE="tableSample",A.TAG="tag",A.TEMPORARY="temporary",A.TOP="top",A.THEN="then",A.TRUE="true",A.TRIGGER="trigger",A.TRUNCATE="truncate",A.TYPE="type",A.UNCACHE="uncache",A.UNION="union",A.UNNEST="unnest",A.UNPIVOT="unpivot",A.UPDATE="update",A.USE="use",A.USING="using",A.VALUES="values",A.VARIADIC="variadic",A.VIEW="view",A.SEMANTIC_VIEW="semanticView",A.VOLATILE="volatile",A.VOLUME="volume",A.WHEN="when",A.WHERE="where",A.WINDOW="window",A.WITH="with",A.UNIQUE="unique",A.UTC_DATE="utcDate",A.UTC_TIME="utcTime",A.UTC_TIMESTAMP="utcTimestamp",A.VERSION_SNAPSHOT="versionSnapshot",A.TIMESTAMP_SNAPSHOT="timestampSnapshot",A.OPTION="option",A.SINK="sink",A.SOURCE="source",A.ANALYZE="analyze",A.NAMESPACE="namespace",A.EXPORT="export",A.HIVE_TOKEN_STREAM="hiveTokenStream",A))(PM||{}),xA=class xA{static number(e){return new xA("number",String(e))}static string(e){return new xA("string",e)}static identifier(e){return new xA("identifier",e)}constructor(e,t,s=1,r=1,i=0,o=0,c=[]){this.tokenType=e,this.text=t,this.line=s,this.col=r,this.start=i,this.end=o,this.comments=c}};n(xA,"Token");var ey=xA,jY,XY,JY,zY,QY,ZY,KY,eV,tV,sV,Os;sV=[O],tV=[O],eV=[O],KY=[O],ZY=[O],QY=[O],zY=[O],JY=[O],XY=[O],jY=[O];var ie=class ie{constructor(e={}){this.sql="";this.size=0;this.tokens=[];this.dialect=void 0;this._start=0;this._current=0;this.line=1;this._col=0;this.comments=[];this.char="";this._end=!1;this.peek="";this.prevTokenLine=-1;let{dialect:t}=e;this.dialect=ae.getOrRaise(t),this.reset()}static get BYTE_STRING_ESCAPES(){return this.STRING_ESCAPES}static get _COMMENTS(){let e={};for(let t of this.COMMENTS)typeof t=="string"?e[t]=void 0:e[t[0]]=t[1];return e["{#"]="#}",this.HINT_START in this.KEYWORDS&&(e[this.HINT_START]="*/"),e}static get _FORMAT_STRINGS(){let e={};for(let[t,s]of Object.entries(this._QUOTES))for(let r of["n","N"])e[r+t]=[s,"nationalString"];return{...e,...this.quotesToFormat("bitString",this.BIT_STRINGS),...this.quotesToFormat("byteString",this.BYTE_STRINGS),...this.quotesToFormat("hexString",this.HEX_STRINGS),...this.quotesToFormat("rawString",this.RAW_STRINGS),...this.quotesToFormat("heredocString",this.HEREDOC_STRINGS),...this.quotesToFormat("unicodeString",this.UNICODE_STRINGS)}}static get _IDENTIFIERS(){return this.convertQuotes(this.IDENTIFIERS)}static get _IDENTIFIER_ESCAPES(){return new Set(this.IDENTIFIER_ESCAPES)}static get _QUOTES(){return this.convertQuotes(this.QUOTES)}static get _STRING_ESCAPES(){return new Set(this.STRING_ESCAPES)}static get _BYTE_STRING_ESCAPES(){return new Set(this.BYTE_STRING_ESCAPES)}static get _ESCAPE_FOLLOW_CHARS(){return new Set(this.ESCAPE_FOLLOW_CHARS)}static get _KEYWORD_TRIE(){let e=Object.keys(this.SINGLE_TOKENS),t=[...Object.keys(this.KEYWORDS),...Object.keys(this._COMMENTS),...Object.keys(this._QUOTES),...Object.keys(this._FORMAT_STRINGS)];return Yt(t.filter(s=>s.includes(" ")||e.some(r=>s.includes(r))).map(s=>Array.from(s.toUpperCase())))}static get KEYWORDS(){return this.ORIGINAL_KEYWORDS}reset(){this.sql="",this.size=0,this.tokens=[],this._start=0,this._current=0,this.line=1,this._col=0,this.comments=[],this.char="",this._end=!1,this.peek="",this.prevTokenLine=-1}tokenize(e){this.reset(),this.sql=e,this.size=e.length;try{this.scan()}catch{let t=Math.max(this._current-50,0),s=Math.min(this._current+50,this.size-1),r=this.sql.slice(t,s);throw new ZE(`Error tokenizing '${r}'`)}return this.tokens}scan(e){for(;this.size&&!this._end;){let t=this._current;for(;t<this.size;){let r=this.sql[t];if(this.isWhitespace(r)&&(r===" "||r===" "))t++;else break}let s=this._current<t?t-this._current:1;if(this._start=t,this.advance({i:s}),this.isWhitespace(this.char)||(this.isDigit(this.char)?this.scanNumber():this.char in this._constructor._IDENTIFIERS?this.scanIdentifier(this._constructor._IDENTIFIERS[this.char]):this.scanKeywords()),e?.())break}this.tokens.length&&this.comments.length&&this.tokens[this.tokens.length-1].comments.push(...this.comments)}chars(e){if(e===1)return this.char;let t=this._current-1,s=t+e;return s<=this.size?this.sql.slice(t,s):""}advance(e={}){let{i:t=1,alnum:s=!1}=e;if(this._constructor.WHITE_SPACE[this.char]==="break"?this.char==="\r"&&this.peek===`
|
|
4
|
+
`||(this._col=t,this.line+=1):this._col+=t,this._current+=t,this._end=this.size<=this._current,this.char=this.sql[this._current-1],this.char===void 0)throw new Error("Index out of bound");if(this.peek=this._end?"":this.sql[this._current],s&&this.isAlnum(this.char)){let{_col:i,_current:o,_end:c,peek:p}=this;for(;this.isAlnum(p);)i+=1,o+=1,c=this.size<=o,p=c?"":this.sql[o];this._col=i,this._current=o,this._end=c,this.peek=p,this.char=this.sql[o-1]}}get text(){return this.sql.slice(this._start,this._current)}add(e,t){this.prevTokenLine=this.line,this.comments.length&&e==="semicolon"&&this.tokens.length&&(this.tokens[this.tokens.length-1].comments.push(...this.comments),this.comments=[]),this.tokens.push(new ey(e,t??this.text,this.line,this._col,this._start,this._current-1,this.comments)),this.comments=[];let s=this._constructor;if(s.COMMANDS.has(e)&&this.peek!==";"&&(this.tokens.length===1||s.COMMAND_PREFIX_TOKENS.has(this.tokens[this.tokens.length-2].tokenType))){let r=this._current,i=this.tokens.length;this.scan(()=>this.peek===";"),this.tokens=this.tokens.slice(0,i);let o=this.sql.slice(r,this._current).trim();o&&this.add("string",o)}}scanKeywords(){let e=0,t,s=this.text,r=s,i=!1,o=!1,c=this._constructor,p=c._KEYWORD_TRIE,u=r in this._constructor.SINGLE_TOKENS;for(;s;){let g;if(o?g=1:[g,p]=Nn(p,Array.from(r.toUpperCase())),g===0)break;g===2&&(t=s);let x=this._current+e;if(e+=1,x<this.size){r=this.sql[x],u=u||r in this._constructor.SINGLE_TOKENS;let f=this.isWhitespace(r);!f||!i?(f&&(r=" "),s+=r,i=f,o=!1):o=!0}else{r="";break}}if(t){if(this.scanString(t)||this.scanComment(t))return;if(i||u||!r){this.advance({i:e-1});let g=t.toUpperCase();this.add(c.KEYWORDS[g],g);return}}let h=this._constructor.SINGLE_TOKENS[this.char];if(h!==void 0){this.add(h,this.char);return}this.scanVar()}scanComment(e){let t=this._constructor;if(!(e in t._COMMENTS))return!1;let s=this.line,r=e.length,i=t._COMMENTS[e];if(i){this.advance({i:r});let o=1,c=i.length;for(;!this._end&&!(this.chars(c)===i&&(o-=1,!o));)this.advance({alnum:!0}),t.NESTED_COMMENTS&&!this._end&&this.chars(r)===e&&(this.advance({i:r}),o+=1);this.comments.push(this.text.slice(r,-c+1)),this.advance({i:c-1})}else{for(;!this._end&&t.WHITE_SPACE[this.peek]!=="break";)this.advance({i:1,alnum:!0});this.comments.push(this.text.slice(r))}return e===t.HINT_START&&this.tokens.length&&t.TOKENS_PRECEDING_HINT.has(this.tokens[this.tokens.length-1].tokenType)&&this.add("hint"),s===this.prevTokenLine&&(this.tokens[this.tokens.length-1].comments.push(...this.comments),this.comments=[],this.prevTokenLine=this.line),!0}scanNumber(){let e=this._constructor;if(this.char==="0"){let p=this.peek.toUpperCase();if(p==="B")return e.BIT_STRINGS.length?this.scanBits():this.add("number");if(p==="X")return e.HEX_STRINGS.length?this.scanHex():this.add("number")}let t=!1,s=0,r=!1,i="",o="",c;for(;;)if(this.isDigit(this.peek))this.advance();else if(this.peek==="."&&!t){if(this.tokens.length&&this.tokens[this.tokens.length-1].tokenType==="parameter")break;t=!0,this.advance()}else if(["-","+"].includes(this.peek)&&s===1)if(this._current+1<this.size&&this.isDigit(this.sql[this._current+1]))s+=1,this.advance();else break;else if(this.peek.toUpperCase()==="E"&&!s)s+=1,this.advance();else if(this.peek==="_"&&this.dialect._constructor.NUMBERS_CAN_BE_UNDERSCORE_SEPARATED)r=!0,this.advance();else if(this.isIdentifierChar(this.peek)){for(i=this.text;this.peek.trim()&&!this._constructor.SINGLE_TOKENS[this.peek];)o+=this.peek,this.advance();if(c=e.KEYWORDS[e.NUMERIC_LITERALS[o.toUpperCase()]||""],c)break;if(this.dialect._constructor.IDENTIFIERS_CAN_START_WITH_DIGIT)return this.add("var");this.advance({i:-o.length});break}else break;i=i||this.sql.slice(this._start,this._current),r&&(i=i.replaceAll("_","")),this.add("number",i),c&&(this.add("dcolon","::"),this.add(c,o))}scanBits(){this.advance();let e=this.extractValue();Number.isNaN(parseInt(e,2))?this.add("identifier"):this.add("bitString",e.slice(2))}scanHex(){this.advance();let e=this.extractValue();Number.isNaN(parseInt(e,16))?this.add("identifier"):this.add("hexString",e.slice(2))}extractValue(){for(;;){let e=this.peek.trim();if(e&&!this._constructor.SINGLE_TOKENS[e])this.advance({i:1,alnum:!0});else break}return this.text}scanString(e){let t=this._constructor,s,r="string",i;if(e in t._QUOTES)i=t._QUOTES[e];else if(e in t._FORMAT_STRINGS){if([i,r]=t._FORMAT_STRINGS[e],r==="hexString")s=16;else if(r==="bitString")s=2;else if(r==="heredocString"){this.advance();let c;if(this.char===i?c="":c=this.extractString(i,void 0,{rawString:!0,raiseUnmatched:!t.HEREDOC_TAG_IS_IDENTIFIER}),c&&t.HEREDOC_TAG_IS_IDENTIFIER&&(this._end||this.isDigit(c)||this.isWhitespace(c)))return this._end||this.advance({i:-1}),this.advance({i:-c.length}),this.add(t.HEREDOC_STRING_ALTERNATIVE),!0;i=`${e}${c}${i}`}}else return!1;this.advance({i:e.length});let o=this.extractString(i,r==="byteString"?t._BYTE_STRING_ESCAPES:t._STRING_ESCAPES,{rawString:r==="rawString"});if(s&&o&&Number.isNaN(parseInt(o,s)))throw new Error(`Numeric string contains invalid characters from ${this.line}:${this._start}`);return this.add(r,o),!0}scanIdentifier(e){this.advance();let t=this._constructor,s=new Set([...Array.from(t._IDENTIFIER_ESCAPES),e]),r=this.extractString(e,s);this.add("identifier",r)}scanVar(){let e=this._constructor;for(;;){let t=this.peek.trim();if(t&&(e.VAR_SINGLE_TOKENS.has(t)||!this._constructor.SINGLE_TOKENS[t]))this.advance({i:1,alnum:!0});else break}this.add(this.tokens.length&&this.tokens[this.tokens.length-1].tokenType==="parameter"?"var":e.KEYWORDS[this.text.toUpperCase()]||"var")}extractString(e,t=void 0,s={}){let{rawString:r=!1,raiseUnmatched:i=!0}=s,o=this._constructor,c="",p=e.length;for(t=t===void 0?o._STRING_ESCAPES:t;;){if(!r&&this.dialect._constructor.UNESCAPED_SEQUENCES&&this.peek&&t.has(this.char)){let h=this.dialect._constructor.UNESCAPED_SEQUENCES[this.char+this.peek];if(h){this.advance({i:2}),c+=h;continue}}let u=o.ESCAPE_FOLLOW_CHARS.length&&this.char==="\\"&&!o.ESCAPE_FOLLOW_CHARS.includes(this.peek);if((o.STRING_ESCAPES_ALLOWED_IN_RAW_STRINGS||!r)&&t.has(this.char)&&(this.peek===e||t.has(this.peek)||u)&&(!(this.char in o._QUOTES)||this.char===this.peek))if(this.peek===e?c+=this.peek:u&&this.char!==this.peek?c+=this.peek:c+=this.char+this.peek,this._current+1<this.size)this.advance({i:2});else throw new ZE(`Missing ${e} from ${this.line}:${this._current}`);else{if(this.chars(p)===e){1<p&&this.advance({i:p-1});break}if(this._end){if(!i)return c+this.char;throw new ZE(`Missing ${e} from ${this.line}:${this._start}`)}let h=this._current-1;this.advance({i:1,alnum:!0}),c+=this.sql.slice(h,this._current-1)}}return c}static convertQuotes(e){let t={};for(let s of e){let r=typeof s=="string"?s:s[0],i=typeof s=="string"?s:s[1];t[r]=i}return t}static quotesToFormat(e,t){let s=this.convertQuotes(t),r={};for(let[i,o]of Object.entries(s))r[i]=[o,e];return r}isWhitespace(e){return/\s/.test(e)}isDigit(e){return/\d/.test(e)}isAlnum(e){return/[a-zA-Z0-9]/.test(e)}isIdentifierChar(e){return/[a-zA-Z_]/.test(e)}get _constructor(){return this.constructor}};Os=Ft(null),R(Os,10,"_COMMENTS",sV,ie),R(Os,10,"_FORMAT_STRINGS",tV,ie),R(Os,10,"_IDENTIFIERS",eV,ie),R(Os,10,"_IDENTIFIER_ESCAPES",KY,ie),R(Os,10,"_QUOTES",ZY,ie),R(Os,10,"_STRING_ESCAPES",QY,ie),R(Os,10,"_BYTE_STRING_ESCAPES",zY,ie),R(Os,10,"_ESCAPE_FOLLOW_CHARS",JY,ie),R(Os,10,"_KEYWORD_TRIE",XY,ie),R(Os,10,"KEYWORDS",jY,ie),It(Os,ie),yt(Os,3,ie),n(ie,"Tokenizer"),ie.SINGLE_TOKENS={"(":"lParen",")":"rParen","[":"lBracket","]":"rBracket","{":"lBrace","}":"rBrace","&":"amp","^":"caret",":":"colon",",":"comma",".":"dot","-":"dash","=":"eq",">":"gt","<":"lt","%":"mod","!":"not","|":"pipe","+":"plus",";":"semicolon","/":"slash","\\":"backslash","*":"star","~":"tilde","?":"placeholder","@":"parameter","#":"hash","'":"unknown","`":"unknown",'"':"unknown"},ie.BIT_STRINGS=[],ie.BYTE_STRINGS=[],ie.HEX_STRINGS=[],ie.RAW_STRINGS=[],ie.HEREDOC_STRINGS=[],ie.IDENTIFIERS=['"'],ie.QUOTES=["'"],ie.UNICODE_STRINGS=[],ie.STRING_ESCAPES=["'"],ie.VAR_SINGLE_TOKENS=new Set,ie.ESCAPE_FOLLOW_CHARS=[],ie.IDENTIFIER_ESCAPES=[],ie.HEREDOC_TAG_IS_IDENTIFIER=!1,ie.HEREDOC_STRING_ALTERNATIVE="var",ie.STRING_ESCAPES_ALLOWED_IN_RAW_STRINGS=!0,ie.NESTED_COMMENTS=!0,ie.HINT_START="/*+",ie.TOKENS_PRECEDING_HINT=new Set(["select","insert","update","delete"]),ie.ORIGINAL_KEYWORDS={"{%":"blockStart","{%+":"blockStart","{%-":"blockStart","%}":"blockEnd","+%}":"blockEnd","-%}":"blockEnd","{{+":"blockStart","{{-":"blockStart","+}}":"blockEnd","-}}":"blockEnd",[ie.HINT_START]:"hint","&<":"ampLt","&>":"ampGt","==":"eq","::":"dcolon","?::":"qdcolon","||":"dpipe","|>":"pipeGt",">=":"gte","<=":"lte","<>":"neq","!=":"neq",":=":"colonEq","<=>":"nullsafeEq","->":"arrow","->>":"darrow","=>":"farrow","#>":"hashArrow","#>>":"dhashArrow","<->":"lrArrow","&&":"damp","??":"dqmark","~~~":"glob","~~":"like","~~*":"ilike","~*":"irlike","-|-":"adjacent",ALL:"all",AND:"and",ANTI:"anti",ANY:"any",ASC:"asc",AS:"alias",ASOF:"asof",AUTOINCREMENT:"autoIncrement",AUTO_INCREMENT:"autoIncrement",BEGIN:"begin",BETWEEN:"between",CACHE:"cache",UNCACHE:"uncache",CASE:"case","CHARACTER SET":"characterSet","CLUSTER BY":"clusterBy",COLLATE:"collate",COLUMN:"column",COMMIT:"commit","CONNECT BY":"connectBy",CONSTRAINT:"constraint",COPY:"copy",CREATE:"create",CROSS:"cross",CUBE:"cube",CURRENT_DATE:"currentDate",CURRENT_SCHEMA:"currentSchema",CURRENT_TIME:"currentTime",CURRENT_TIMESTAMP:"currentTimestamp",CURRENT_USER:"currentUser",CURRENT_CATALOG:"currentCatalog",DATABASE:"database",DEFAULT:"default",DELETE:"delete",DESC:"desc",DESCRIBE:"describe",DISTINCT:"distinct","DISTRIBUTE BY":"distributeBy",DIV:"div",DROP:"drop",ELSE:"else",END:"end",ENUM:"enum",ESCAPE:"escape",EXCEPT:"except",EXECUTE:"execute",EXISTS:"exists",FALSE:"false",FETCH:"fetch",FILTER:"filter",FILE:"file",FIRST:"first",FULL:"full",FUNCTION:"function",FOR:"for","FOREIGN KEY":"foreignKey",FORMAT:"format",FROM:"from",GEOGRAPHY:"geography",GEOMETRY:"geometry",GLOB:"glob","GROUP BY":"groupBy","GROUPING SETS":"groupingSets",HAVING:"having",ILIKE:"ilike",IN:"in",INDEX:"index",INET:"inet",INNER:"inner",INSERT:"insert",INTERVAL:"interval",INTERSECT:"intersect",INTO:"into",IS:"is",ISNULL:"isnull",JOIN:"join",KEEP:"keep",KILL:"kill",LATERAL:"lateral",LEFT:"left",LIKE:"like",LIMIT:"limit",LOAD:"load",LOCALTIME:"localtime",LOCALTIMESTAMP:"localtimestamp",LOCK:"lock",MERGE:"merge",NAMESPACE:"namespace",NATURAL:"natural",NEXT:"next",NOT:"not",NOTNULL:"notnull",NULL:"null",OBJECT:"object",OFFSET:"offset",ON:"on",OR:"or",XOR:"xor","ORDER BY":"orderBy",ORDINALITY:"ordinality",OUT:"out",OUTER:"outer",OVER:"over",OVERLAPS:"overlaps",OVERWRITE:"overwrite",PARTITION:"partition","PARTITION BY":"partitionBy","PARTITIONED BY":"partitionBy",PARTITIONED_BY:"partitionBy",PERCENT:"percent",PIVOT:"pivot",PRAGMA:"pragma","PRIMARY KEY":"primaryKey",PROCEDURE:"procedure",OPERATOR:"operator",QUALIFY:"qualify",RANGE:"range",RECURSIVE:"recursive",REGEXP:"rlike",RENAME:"rename",REPLACE:"replace",RETURNING:"returning",REFERENCES:"references",RIGHT:"right",RLIKE:"rlike",ROLLBACK:"rollback",ROLLUP:"rollup",ROW:"row",ROWS:"rows",SCHEMA:"schema",SELECT:"select",SEMI:"semi",SESSION:"session",SESSION_USER:"sessionUser",SET:"set",SETTINGS:"settings",SHOW:"show","SIMILAR TO":"similarTo",SOME:"some","SORT BY":"sortBy","SQL SECURITY":"sqlSecurity","START WITH":"startWith",STRAIGHT_JOIN:"straightJoin",TABLE:"table",TABLESAMPLE:"tableSample",TEMP:"temporary",TEMPORARY:"temporary",THEN:"then",TRUE:"true",TRIGGER:"trigger",TRUNCATE:"truncate",UNION:"union",UNKNOWN:"unknown",UNNEST:"unnest",UNPIVOT:"unpivot",UPDATE:"update",USE:"use",USING:"using",UUID:"uuid",VALUES:"values",VIEW:"view",VOLATILE:"volatile",WHEN:"when",WHERE:"where",WINDOW:"window",WITH:"with",APPLY:"apply",ARRAY:"array",BIT:"bit",BOOL:"boolean",BOOLEAN:"boolean",BYTE:"tinyint",MEDIUMINT:"mediumint",INT1:"tinyint",TINYINT:"tinyint",INT16:"smallint",SHORT:"smallint",SMALLINT:"smallint",HUGEINT:"int128",UHUGEINT:"uint128",INT2:"smallint",INTEGER:"int",INT:"int",INT4:"int",INT32:"int",INT64:"bigint",INT128:"int128",INT256:"int256",LONG:"bigint",BIGINT:"bigint",INT8:"tinyint",UINT:"uint",UINT128:"uint128",UINT256:"uint256",DEC:"decimal",DECIMAL:"decimal",DECIMAL32:"decimal32",DECIMAL64:"decimal64",DECIMAL128:"decimal128",DECIMAL256:"decimal256",DECFLOAT:"decfloat",BIGDECIMAL:"bigdecimal",BIGNUMERIC:"bigdecimal",BIGNUM:"bignum",LIST:"list",MAP:"map",NULLABLE:"nullable",NUMBER:"decimal",NUMERIC:"decimal",FIXED:"decimal",REAL:"float",FLOAT:"float",FLOAT4:"float",FLOAT8:"double",DOUBLE:"double","DOUBLE PRECISION":"double",JSON:"json",JSONB:"jsonb",CHAR:"char",CHARACTER:"char","CHAR VARYING":"varchar","CHARACTER VARYING":"varchar",NCHAR:"nchar",VARCHAR:"varchar",VARCHAR2:"varchar",NVARCHAR:"nvarchar",NVARCHAR2:"nvarchar",BPCHAR:"bpchar",STR:"text",STRING:"text",TEXT:"text",LONGTEXT:"longtext",MEDIUMTEXT:"mediumtext",TINYTEXT:"tinytext",CLOB:"text",LONGVARCHAR:"text",BINARY:"binary",BLOB:"varbinary",LONGBLOB:"longblob",MEDIUMBLOB:"mediumblob",TINYBLOB:"tinyblob",BYTEA:"varbinary",VARBINARY:"varbinary",TIME:"time",TIMETZ:"timetz",TIME_NS:"timeNs",TIMESTAMP:"timestamp",TIMESTAMPTZ:"timestamptz",TIMESTAMPLTZ:"timestampltz",TIMESTAMP_LTZ:"timestampltz",TIMESTAMPNTZ:"timestampntz",TIMESTAMP_NTZ:"timestampntz",DATE:"date",DATETIME:"datetime",INT4RANGE:"int4range",INT4MULTIRANGE:"int4multirange",INT8RANGE:"int8range",INT8MULTIRANGE:"int8multirange",NUMRANGE:"numrange",NUMMULTIRANGE:"nummultirange",TSRANGE:"tsrange",TSMULTIRANGE:"tsmultirange",TSTZRANGE:"tstzrange",TSTZMULTIRANGE:"tstzmultirange",DATERANGE:"daterange",DATEMULTIRANGE:"datemultirange",UNIQUE:"unique",VECTOR:"vector",STRUCT:"struct",SEQUENCE:"sequence",VARIANT:"variant",ALTER:"alter",ANALYZE:"analyze",CALL:"command",COMMENT:"comment",EXPLAIN:"command",GRANT:"grant",REVOKE:"revoke",OPTIMIZE:"command",PREPARE:"command",VACUUM:"command","USER-DEFINED":"userdefined","FOR VERSION":"versionSnapshot","FOR TIMESTAMP":"timestampSnapshot"},ie.WHITE_SPACE={" ":"space"," ":"space","\n":"break","\r":"break"},ie.COMMANDS=new Set(["command","execute","fetch","show","rename"]),ie.COMMAND_PREFIX_TOKENS=new Set(["semicolon","begin"]),ie.NUMERIC_LITERALS={},ie.COMMENTS=["--",["/*","*/"]];var Fr=ie;function Wl(a,e,t){if(!a)return;let s=0,r=1,i=a.length,o=t??Yt(Object.keys(e).map(h=>Array.from(h))),c=o,p=[],u;for(;r<=i;){let h=a.substring(s,r),[g,x]=Nn(c,[h[h.length-1]]);c=x,g===0?(u?(r-=1,h=u,u=void 0):(h=h[0],r=s+1),s+=h.length,p.push(h),c=o):g===2&&(u=h),r+=1,g!==0&&i<r&&p.push(h)}return p.map(h=>e[h]??h).join("")}n(Wl,"formatTime");var SD=new Set(["africa/abidjan","africa/accra","africa/addis_ababa","africa/algiers","africa/asmara","africa/asmera","africa/bamako","africa/bangui","africa/banjul","africa/bissau","africa/blantyre","africa/brazzaville","africa/bujumbura","africa/cairo","africa/casablanca","africa/ceuta","africa/conakry","africa/dakar","africa/dar_es_salaam","africa/djibouti","africa/douala","africa/el_aaiun","africa/freetown","africa/gaborone","africa/harare","africa/johannesburg","africa/juba","africa/kampala","africa/khartoum","africa/kigali","africa/kinshasa","africa/lagos","africa/libreville","africa/lome","africa/luanda","africa/lubumbashi","africa/lusaka","africa/malabo","africa/maputo","africa/maseru","africa/mbabane","africa/mogadishu","africa/monrovia","africa/nairobi","africa/ndjamena","africa/niamey","africa/nouakchott","africa/ouagadougou","africa/porto-novo","africa/sao_tome","africa/timbuktu","africa/tripoli","africa/tunis","africa/windhoek","america/adak","america/anchorage","america/anguilla","america/antigua","america/araguaina","america/argentina/buenos_aires","america/argentina/catamarca","america/argentina/comodrivadavia","america/argentina/cordoba","america/argentina/jujuy","america/argentina/la_rioja","america/argentina/mendoza","america/argentina/rio_gallegos","america/argentina/salta","america/argentina/san_juan","america/argentina/san_luis","america/argentina/tucuman","america/argentina/ushuaia","america/aruba","america/asuncion","america/atikokan","america/atka","america/bahia","america/bahia_banderas","america/barbados","america/belem","america/belize","america/blanc-sablon","america/boa_vista","america/bogota","america/boise","america/buenos_aires","america/cambridge_bay","america/campo_grande","america/cancun","america/caracas","america/catamarca","america/cayenne","america/cayman","america/chicago","america/chihuahua","america/ciudad_juarez","america/coral_harbour","america/cordoba","america/costa_rica","america/creston","america/cuiaba","america/curacao","america/danmarkshavn","america/dawson","america/dawson_creek","america/denver","america/detroit","america/dominica","america/edmonton","america/eirunepe","america/el_salvador","america/ensenada","america/fort_nelson","america/fort_wayne","america/fortaleza","america/glace_bay","america/godthab","america/goose_bay","america/grand_turk","america/grenada","america/guadeloupe","america/guatemala","america/guayaquil","america/guyana","america/halifax","america/havana","america/hermosillo","america/indiana/indianapolis","america/indiana/knox","america/indiana/marengo","america/indiana/petersburg","america/indiana/tell_city","america/indiana/vevay","america/indiana/vincennes","america/indiana/winamac","america/indianapolis","america/inuvik","america/iqaluit","america/jamaica","america/jujuy","america/juneau","america/kentucky/louisville","america/kentucky/monticello","america/knox_in","america/kralendijk","america/la_paz","america/lima","america/los_angeles","america/louisville","america/lower_princes","america/maceio","america/managua","america/manaus","america/marigot","america/martinique","america/matamoros","america/mazatlan","america/mendoza","america/menominee","america/merida","america/metlakatla","america/mexico_city","america/miquelon","america/moncton","america/monterrey","america/montevideo","america/montreal","america/montserrat","america/nassau","america/new_york","america/nipigon","america/nome","america/noronha","america/north_dakota/beulah","america/north_dakota/center","america/north_dakota/new_salem","america/nuuk","america/ojinaga","america/panama","america/pangnirtung","america/paramaribo","america/phoenix","america/port-au-prince","america/port_of_spain","america/porto_acre","america/porto_velho","america/puerto_rico","america/punta_arenas","america/rainy_river","america/rankin_inlet","america/recife","america/regina","america/resolute","america/rio_branco","america/rosario","america/santa_isabel","america/santarem","america/santiago","america/santo_domingo","america/sao_paulo","america/scoresbysund","america/shiprock","america/sitka","america/st_barthelemy","america/st_johns","america/st_kitts","america/st_lucia","america/st_thomas","america/st_vincent","america/swift_current","america/tegucigalpa","america/thule","america/thunder_bay","america/tijuana","america/toronto","america/tortola","america/vancouver","america/virgin","america/whitehorse","america/winnipeg","america/yakutat","america/yellowknife","antarctica/casey","antarctica/davis","antarctica/dumontdurville","antarctica/macquarie","antarctica/mawson","antarctica/mcmurdo","antarctica/palmer","antarctica/rothera","antarctica/south_pole","antarctica/syowa","antarctica/troll","antarctica/vostok","arctic/longyearbyen","asia/aden","asia/almaty","asia/amman","asia/anadyr","asia/aqtau","asia/aqtobe","asia/ashgabat","asia/ashkhabad","asia/atyrau","asia/baghdad","asia/bahrain","asia/baku","asia/bangkok","asia/barnaul","asia/beirut","asia/bishkek","asia/brunei","asia/calcutta","asia/chita","asia/choibalsan","asia/chongqing","asia/chungking","asia/colombo","asia/dacca","asia/damascus","asia/dhaka","asia/dili","asia/dubai","asia/dushanbe","asia/famagusta","asia/gaza","asia/harbin","asia/hebron","asia/ho_chi_minh","asia/hong_kong","asia/hovd","asia/irkutsk","asia/istanbul","asia/jakarta","asia/jayapura","asia/jerusalem","asia/kabul","asia/kamchatka","asia/karachi","asia/kashgar","asia/kathmandu","asia/katmandu","asia/khandyga","asia/kolkata","asia/krasnoyarsk","asia/kuala_lumpur","asia/kuching","asia/kuwait","asia/macao","asia/macau","asia/magadan","asia/makassar","asia/manila","asia/muscat","asia/nicosia","asia/novokuznetsk","asia/novosibirsk","asia/omsk","asia/oral","asia/phnom_penh","asia/pontianak","asia/pyongyang","asia/qatar","asia/qostanay","asia/qyzylorda","asia/rangoon","asia/riyadh","asia/saigon","asia/sakhalin","asia/samarkand","asia/seoul","asia/shanghai","asia/singapore","asia/srednekolymsk","asia/taipei","asia/tashkent","asia/tbilisi","asia/tehran","asia/tel_aviv","asia/thimbu","asia/thimphu","asia/tokyo","asia/tomsk","asia/ujung_pandang","asia/ulaanbaatar","asia/ulan_bator","asia/urumqi","asia/ust-nera","asia/vientiane","asia/vladivostok","asia/yakutsk","asia/yangon","asia/yekaterinburg","asia/yerevan","atlantic/azores","atlantic/bermuda","atlantic/canary","atlantic/cape_verde","atlantic/faeroe","atlantic/faroe","atlantic/jan_mayen","atlantic/madeira","atlantic/reykjavik","atlantic/south_georgia","atlantic/st_helena","atlantic/stanley","australia/act","australia/adelaide","australia/brisbane","australia/broken_hill","australia/canberra","australia/currie","australia/darwin","australia/eucla","australia/hobart","australia/lhi","australia/lindeman","australia/lord_howe","australia/melbourne","australia/nsw","australia/north","australia/perth","australia/queensland","australia/south","australia/sydney","australia/tasmania","australia/victoria","australia/west","australia/yancowinna","brazil/acre","brazil/denoronha","brazil/east","brazil/west","cet","cst6cdt","canada/atlantic","canada/central","canada/eastern","canada/mountain","canada/newfoundland","canada/pacific","canada/saskatchewan","canada/yukon","chile/continental","chile/easterisland","cuba","eet","est","est5edt","egypt","eire","etc/gmt","etc/gmt+0","etc/gmt+1","etc/gmt+10","etc/gmt+11","etc/gmt+12","etc/gmt+2","etc/gmt+3","etc/gmt+4","etc/gmt+5","etc/gmt+6","etc/gmt+7","etc/gmt+8","etc/gmt+9","etc/gmt-0","etc/gmt-1","etc/gmt-10","etc/gmt-11","etc/gmt-12","etc/gmt-13","etc/gmt-14","etc/gmt-2","etc/gmt-3","etc/gmt-4","etc/gmt-5","etc/gmt-6","etc/gmt-7","etc/gmt-8","etc/gmt-9","etc/gmt0","etc/greenwich","etc/uct","etc/utc","etc/universal","etc/zulu","europe/amsterdam","europe/andorra","europe/astrakhan","europe/athens","europe/belfast","europe/belgrade","europe/berlin","europe/bratislava","europe/brussels","europe/bucharest","europe/budapest","europe/busingen","europe/chisinau","europe/copenhagen","europe/dublin","europe/gibraltar","europe/guernsey","europe/helsinki","europe/isle_of_man","europe/istanbul","europe/jersey","europe/kaliningrad","europe/kiev","europe/kirov","europe/kyiv","europe/lisbon","europe/ljubljana","europe/london","europe/luxembourg","europe/madrid","europe/malta","europe/mariehamn","europe/minsk","europe/monaco","europe/moscow","europe/nicosia","europe/oslo","europe/paris","europe/podgorica","europe/prague","europe/riga","europe/rome","europe/samara","europe/san_marino","europe/sarajevo","europe/saratov","europe/simferopol","europe/skopje","europe/sofia","europe/stockholm","europe/tallinn","europe/tirane","europe/tiraspol","europe/ulyanovsk","europe/uzhgorod","europe/vaduz","europe/vatican","europe/vienna","europe/vilnius","europe/volgograd","europe/warsaw","europe/zagreb","europe/zaporozhye","europe/zurich","gb","gb-eire","gmt","gmt+0","gmt-0","gmt0","greenwich","hst","hongkong","iceland","indian/antananarivo","indian/chagos","indian/christmas","indian/cocos","indian/comoro","indian/kerguelen","indian/mahe","indian/maldives","indian/mauritius","indian/mayotte","indian/reunion","iran","israel","jamaica","japan","kwajalein","libya","met","mst","mst7mdt","mexico/bajanorte","mexico/bajasur","mexico/general","nz","nz-chat","navajo","prc","pst8pdt","pacific/apia","pacific/auckland","pacific/bougainville","pacific/chatham","pacific/chuuk","pacific/easter","pacific/efate","pacific/enderbury","pacific/fakaofo","pacific/fiji","pacific/funafuti","pacific/galapagos","pacific/gambier","pacific/guadalcanal","pacific/guam","pacific/honolulu","pacific/johnston","pacific/kanton","pacific/kiritimati","pacific/kosrae","pacific/kwajalein","pacific/majuro","pacific/marquesas","pacific/midway","pacific/nauru","pacific/niue","pacific/norfolk","pacific/noumea","pacific/pago_pago","pacific/palau","pacific/pitcairn","pacific/pohnpei","pacific/ponape","pacific/port_moresby","pacific/rarotonga","pacific/saipan","pacific/samoa","pacific/tahiti","pacific/tarawa","pacific/tongatapu","pacific/truk","pacific/wake","pacific/wallis","pacific/yap","poland","portugal","roc","rok","singapore","turkey","uct","us/alaska","us/aleutian","us/arizona","us/central","us/east-indiana","us/eastern","us/hawaii","us/indiana-starke","us/michigan","us/mountain","us/pacific","us/samoa","utc","universal","w-su","wet","zulu"]);function rV(a){try{let e=a.match(/\.(\d+)/);if(!e)return 0;let s=e[1].replace(/0+$/,"").length;return 3<s?6:0<s?3:0}catch{return 0}}n(rV,"subsecondPrecision");function ty(a,e={}){let{dialect:t,storeOriginalColumnIdentifiers:s=!1}=e,r=ae.getOrRaise(t),i;typeof a=="string"?i=sy(a,{dialect:r}):i=a;for(let o of i.walk({prune:n(c=>!!c.meta?.caseSensitive,"prune")}))if(!o.meta?.caseSensitive){if(s&&o instanceof $){let c=o;for(;c&&c.parent instanceof ge;)c=c.parent;"parts"in c&&Array.isArray(c.parts)&&(o.meta.dotParts=c.parts.map(p=>p.name))}r.normalizeIdentifier(o)}return i}n(ty,"normalizeIdentifiers");var jl=new Map,ry=new Set;function iV(a){ry.add(a);let e=a.sqlNames();for(let t of e)jl.set(t.toUpperCase(),a)}n(iV,"registerFunc");function Q0(a,e){return ae.getOrRaise(e?.read??e?.dialect).parse(a,e)}n(Q0,"parse");function mD(a,e){let t=ae.getOrRaise(e?.read??e?.dialect),s=e?.into?t.parseIntoTypes(e.into,a,e):t.parse(a,e);if(!s.length||s[0]===void 0)throw new Ke(`No expression was parsed from '${a}'`);return 1<s.length?new GA({expressions:s}):s[0]}n(mD,"parseOne");var zW=/:.*?[a-zA-Z+\-]/;function QW(a){if(a.length===1&&a[0].isStar)return new Ab({this:a[0]});let e=[],t=[];for(let s=0;s<a.length;s+=2)e.push(a[s]),t.push(a[s+1]);return new Rs({keys:vA(e,{copy:!1}),values:vA(t,{copy:!1})})}n(QW,"buildVarMap");function ZW(a){if(a.length<2)throw new Error("buildLike only accept expression lists with at least 2 expressions");let e=new Zt({this:a[1],expression:a[0]});return 2<a.length?new Ba({this:e,expression:a[2]}):e}n(ZW,"buildLike");function zt(a,e={}){let{reverseArgs:t=!1}=e;return n(function(r){let i=this.parseBitwise(),o=r;return t&&([o,i]=[i,o]),this.parseEscape(this.expression(a,{this:o,expression:i}))},"parseBinaryRange")}n(zt,"binaryRangeParser");function KW(a,{dialect:e}){if(a.length<1)throw new Error("buildAlgorithm only accepts an expression list with at least one expression");let t=k(a,0),s=k(a,1);return t&&s?(e._constructor.LOG_BASE_FIRST||([t,s]=[s,t]),new ur({this:t,expression:s})):e._constructor.parserClass?.LOG_DEFAULTS_TO_LN??!1?new yh({this:t}):new ur({this:t})}n(KW,"buildLogarithm");function nV(a,{dialect:e}){if(a.length<1)throw new Error("buildHex only accepts an expression list with at least one expression");let t=a[0];return e._constructor.HEX_LOWERCASE?new Ph({this:t}):new $a({this:t})}n(nV,"buildHex");function ej(a){if(a.length<1)throw new Error("buildLower only accepts an expression list with at least one expression");let e=a[0];return e instanceof $a?new Ph({this:e.args.this}):new Ar({this:e})}n(ej,"buildLower");function tj(a){if(a.length<1)throw new Error("buildUpper only accepts an expression list with at least one expression");let e=a[0];return e instanceof Ph?new $a({this:e.args.this}):new dr({this:e})}n(tj,"buildUpper");function RD(a){return n(function(t,{dialect:s}){if(t.length<2)throw new Error("buildExtractJsonWithPath only accepts an expression list with at least two expressions");let r=new a({this:t[0],expression:s.toJsonPath(k(t,1))});return 2<t.length&&r instanceof Ns&&r.setArgKey("expressions",t.slice(2)),r instanceof bn&&r.setArgKey("scalarOnly",s._constructor.JSON_EXTRACT_SCALAR_SCALAR_ONLY),r},"builder")}n(RD,"buildExtractJsonWithPath");function sj(a){if(a.length<2)throw new Error("buildMod only accepts an expression list with at least two expressions");let e=a[0],t=a[1];return e=e instanceof v?new Re({this:e}):e,t=t instanceof v?new Re({this:t}):t,new jr({this:e,expression:t})}n(sj,"buildMod");function LM(a,e={}){if(a.length<2)throw new Error("buildPad only accepts an expression list with at least two expressions");let{isLeft:t=!0}=e;return new eb({this:k(a,0),expression:k(a,1),fillPattern:k(a,2),isLeft:t})}n(LM,"buildPad");function aV(a,e,t,s){let r=new a({expressions:e});return r instanceof ue&&s._constructor.HAS_DISTINCT_ARRAY_CONSTRUCTORS&&r.setArgKey("bracketNotation",t==="lBracket"),r}n(aV,"buildArrayConstructor");function rj(a,e={}){if(a.length<2)throw new Error("buildConvertTimezone only accepts an expression list with at least two expressions");let{defaultSourceTz:t}=e;if(a.length===2){let s=t?I.string(t):void 0,r=k(a,0),i=typeof r=="string"?I.string(r):r,o=k(a,1),c=typeof o=="string"?I.string(o):o;return new vn({sourceTz:s,targetTz:i,timestamp:c})}return vn.fromArgList(a)}n(rj,"buildConvertTimezone");function oV(a,e={}){if(a.length<1)throw new Error("buildTrim only accepts an expression list with at least one expression");let{isLeft:t=!0,reverseArgs:s=!1}=e,r=k(a,0),i=k(a,1);return i&&s&&([r,i]=[i,r]),new Ya({this:r,expression:i,position:t?"leading":"trailing"})}n(oV,"buildTrim");function ij(a,e={}){if(a.length<1)throw new Error("buildCoalesce only accepts an expression list with at least one expression");let{isNvl:t,isNull:s}=e;return new tt({this:k(a,0),expressions:a.slice(1),isNvl:t,isNull:s})}n(ij,"buildCoalesce");function cV(a){if(a.length<2)throw new Error("buildLocateStrposition only accepts an expression list with at least two expressions");return new Bs({this:k(a,1),substr:k(a,0),position:k(a,2)})}n(cV,"buildLocateStrPosition");function nj(a,{dialect:e}){if(a.length<2)throw new Error("buildArrayAppend only accepts an expression list with at least two expressions");return new sb({this:k(a,0),expression:k(a,1),nullPropagation:e._constructor.ARRAY_FUNCS_PROPAGATES_NULLS})}n(nj,"buildArrayAppend");function aj(a,{dialect:e}){if(a.length<2)throw new Error("buildArrayPrepend only accepts an expression list with at least two expressions");return new rb({this:a[0],expression:a[1],nullPropagation:e._constructor.ARRAY_FUNCS_PROPAGATES_NULLS})}n(aj,"buildArrayPrepend");function pV(a,{dialect:e}){if(a.length<1)throw new Error("buildArrayConcat only accepts an expression list with at least one expression");return new hh({this:a[0],expressions:a.slice(1),nullPropagation:e._constructor.ARRAY_FUNCS_PROPAGATES_NULLS})}n(pV,"buildArrayConcat");function oj(a,{dialect:e}){if(a.length<2)throw new Error("buildArrayRemove only accepts an expression list with at least two expressions");return new uh({this:a[0],expression:a[1],nullPropagation:e._constructor.ARRAY_FUNCS_PROPAGATES_NULLS})}n(oj,"buildArrayRemove");var lV,uV,hV,gV,EV,AV,dV,xV,fV,TV,SV,RV,OV,mV,NV,IV,yV,CV,bV,PV,LV,wV,MV,kV,DV,qV,UV,vV,FV,BV,$V,GV,YV,VV,HV,_V,WV,jV,XV,JV,zV,QV,ZV,KV,eH,tH,sH,rH,iH,nH,aH,oH,cH,pH,lH,uH,hH,gH,EH,AH,dH,xH,fH,TH,SH,RH,OH,mH,NH,IH,yH,CH,bH,PH,LH,wH,MH,B;MH=[O],wH=[O],LH=[O],PH=[O],bH=[O],CH=[O],yH=[O],IH=[O],NH=[O],mH=[O],OH=[O],RH=[O],SH=[O],TH=[O],fH=[O],xH=[O],dH=[O],AH=[O],EH=[O],gH=[O],hH=[O],uH=[O],lH=[O],pH=[O],cH=[O],oH=[O],aH=[O],nH=[O],iH=[O],rH=[O],sH=[O],tH=[O],eH=[O],KV=[O],ZV=[O],QV=[O],zV=[O],JV=[O],XV=[O],jV=[O],WV=[O],_V=[O],HV=[O],VV=[O],YV=[O],GV=[O],$V=[O],BV=[O],FV=[O],vV=[O],UV=[O],qV=[O],DV=[O],kV=[O],MV=[O],wV=[O],LV=[O],PV=[O],bV=[O],CV=[O],yV=[O],IV=[O],NV=[O],mV=[O],OV=[O],RV=[O],SV=[O],TV=[O],fV=[O],xV=[O],dV=[O],AV=[O],EV=[O],gV=[O],hV=[O],uV=[O],lV=[O];var S=class S{constructor(e={}){this.sql=void 0;this.dialect=void 0;this.errorLevel=void 0;this.errorMessageContext=void 0;this.maxErrors=void 0;this.errors=void 0;this.tokens=void 0;this.index=void 0;this.curr=void 0;this.next=void 0;this.prev=void 0;this.prevComments=void 0;this.pipeCteCounter=void 0;this._chunks=void 0;this._chunkIndex=void 0;let{errorLevel:t=3,errorMessageContext:s=100,maxErrors:r=3}=e;this.sql="",this.dialect=ae.getOrRaise(e.dialect),this.errorLevel=t,this.errorMessageContext=s,this.maxErrors=r,this.errors=[],this.tokens=[],this.index=0,this.curr=void 0,this.next=void 0,this.prev=void 0,this.prevComments=void 0,this.pipeCteCounter=0,this._chunks=[],this._chunkIndex=0,this.reset()}static get SHOW_TRIE(){return this._showTrie||(this._showTrie=Yt(Object.keys(this.SHOW_PARSERS).map(e=>e.split(" ")))),this._showTrie}static get SET_TRIE(){return this._setTrie||(this._setTrie=Yt(Object.keys(this.SET_PARSERS).map(e=>e.split(" ")))),this._setTrie}static get FUNCTIONS(){return{...Object.fromEntries(Array.from(jl.entries()).map(([e,t])=>[e,(s,r)=>t.fromArgList(s)])),...Object.fromEntries(["COALESCE","IFNULL","NVL"].map(e=>[e,(t,s)=>ij(t)])),ARRAY:n((e,t)=>new ue({expressions:e}),"ARRAY"),ARRAYAGG:n((e,{dialect:t})=>new Bn({this:e[0],nullsExcluded:t._constructor.ARRAY_AGG_INCLUDES_NULLS===void 0?!0:void 0}),"ARRAYAGG"),ARRAY_AGG:n((e,{dialect:t})=>new Bn({this:e[0],nullsExcluded:t._constructor.ARRAY_AGG_INCLUDES_NULLS===void 0?!0:void 0}),"ARRAY_AGG"),ARRAY_APPEND:nj,ARRAY_CAT:pV,ARRAY_CONCAT:pV,ARRAY_INTERSECT:n(e=>new MA({expressions:e}),"ARRAY_INTERSECT"),ARRAY_INTERSECTION:n(e=>new MA({expressions:e}),"ARRAY_INTERSECTION"),ARRAY_PREPEND:aj,ARRAY_REMOVE:oj,COUNT:n((e,t)=>new bh({this:e[0],expressions:e.slice(1),bigInt:!0}),"COUNT"),CONCAT:n((e,{dialect:t})=>new $t({expressions:e,safe:!t._constructor.STRICT_STRING_CONCAT,coalesce:t._constructor.CONCAT_COALESCE}),"CONCAT"),CONCAT_WS:n((e,{dialect:t})=>new Wt({expressions:e,safe:!t._constructor.STRICT_STRING_CONCAT,coalesce:t._constructor.CONCAT_COALESCE}),"CONCAT_WS"),CONVERT_TIMEZONE:n((e,t)=>rj(e),"CONVERT_TIMEZONE"),DATE_ADD:n(e=>e.length===3?OD(ft)([e[2],e[1],e[0]]):new ft({this:k(e,0),expression:k(e,1)}),"DATE_ADD"),DATE_SUB:n(e=>e.length===3?OD(Xt)([e[2],e[1],e[0]]):new Xt({this:k(e,0),expression:k(e,1)}),"DATE_SUB"),DATE_TO_DATE_STR:n((e,t)=>new z({this:e[0],to:new N({this:"text"})}),"DATE_TO_DATE_STR"),TIME_TO_TIME_STR:n((e,t)=>new z({this:e[0],to:new N({this:"text"})}),"TIME_TO_TIME_STR"),GENERATE_DATE_ARRAY:n((e,t)=>new ii({start:e[0],end:e[1],step:k(e,2)||new qe({this:I.string("1"),unit:Q("DAY")})}),"GENERATE_DATE_ARRAY"),GENERATE_UUID:n((e,{dialect:t})=>new DA({isString:t._constructor.UUID_IS_STRING_TYPE||void 0}),"GENERATE_UUID"),GLOB:n((e,t)=>new wA({this:e[1],expression:e[0]}),"GLOB"),LIKE:n((e,t)=>ZW(e),"LIKE"),GREATEST:n((e,{dialect:t})=>new ni({this:e[0],expressions:e.slice(1),ignoreNulls:t._constructor.LEAST_GREATEST_IGNORES_NULLS}),"GREATEST"),LEAST:n((e,{dialect:t})=>new Ih({this:e[0],expressions:e.slice(1),ignoreNulls:t._constructor.LEAST_GREATEST_IGNORES_NULLS}),"LEAST"),HEX:n((e,{dialect:t})=>nV(e,{dialect:t}),"HEX"),TO_HEX:n((e,{dialect:t})=>nV(e,{dialect:t}),"TO_HEX"),JSON_EXTRACT:RD(Ns),JSON_EXTRACT_SCALAR:RD(bn),JSON_EXTRACT_PATH_TEXT:RD(bn),JSON_KEYS:n((e,{dialect:t})=>new lb({this:e[0],expression:t.toJsonPath(k(e,1))}),"JSON_KEYS"),LOG:n((e,{dialect:t})=>KW(e,{dialect:t}),"LOG"),LOG2:n((e,t)=>new ur({this:I.number(2),expression:k(e,0)}),"LOG2"),LOG10:n((e,t)=>new ur({this:I.number(10),expression:k(e,0)}),"LOG10"),MOD:n((e,t)=>sj(e),"MOD"),LOWER:n((e,t)=>ej(e),"LOWER"),UPPER:n((e,t)=>tj(e),"UPPER"),LPAD:n((e,t)=>LM(e),"LPAD"),LEFTPAD:n((e,t)=>LM(e),"LEFTPAD"),RPAD:n((e,t)=>LM(e,{isLeft:!1}),"RPAD"),RIGHTPAD:n((e,t)=>LM(e,{isLeft:!1}),"RIGHTPAD"),LTRIM:n((e,t)=>oV(e),"LTRIM"),RTRIM:n((e,t)=>oV(e,{isLeft:!1}),"RTRIM"),STRPOS:n((e,t)=>Bs.fromArgList(e),"STRPOS"),INSTR:n((e,t)=>Bs.fromArgList(e),"INSTR"),CHARINDEX:n((e,t)=>cV(e),"CHARINDEX"),LOCATE:n((e,t)=>cV(e),"LOCATE"),SCOPE_RESOLUTION:n((e,t)=>e.length!==2?new bA({expression:e[0]}):new bA({this:k(e,0),expression:e[1]}),"SCOPE_RESOLUTION"),TS_OR_DS_TO_DATE_STR:n((e,t)=>new Is({this:new z({this:e[0],to:new N({this:"text"})}),start:I.number(1),length:I.number(10)}),"TS_OR_DS_TO_DATE_STR"),UNNEST:n((e,t)=>new Ee({expressions:[e[0]]}),"UNNEST"),UUID:n((e,{dialect:t})=>new DA({isString:t._constructor.UUID_IS_STRING_TYPE||void 0}),"UUID"),VAR_MAP:n((e,t)=>QW(e),"VAR_MAP")}}static get NO_PAREN_FUNCTIONS(){return{currentDate:pr,currentDatetime:pr,currentTime:si,currentTimestamp:ri,currentUser:xh,localtime:dh,localtimestamp:nb,currentRole:ab}}static get STRUCT_TYPE_TOKENS(){return new Set(["nested","object","struct","union"])}static get NESTED_TYPE_TOKENS(){return new Set(["array","list","lowcardinality","map","nullable","range",...S.STRUCT_TYPE_TOKENS])}static get ENUM_TYPE_TOKENS(){return new Set(["dynamic","enum","enum8","enum16"])}static get AGGREGATE_TYPE_TOKENS(){return new Set(["aggregatefunction","simpleaggregatefunction"])}static get TYPE_TOKENS(){return new Set(["bit","boolean","tinyint","utinyint","smallint","usmallint","int","uint","bigint","ubigint","bignum","int128","uint128","int256","uint256","mediumint","umediumint","fixedstring","float","double","udouble","char","nchar","varchar","nvarchar","bpchar","text","mediumtext","longtext","blob","mediumblob","longblob","binary","varbinary","json","jsonb","interval","tinyblob","tinytext","time","timetz","timeNs","timestamp","timestampS","timestampMs","timestampNs","timestamptz","timestampltz","timestampntz","datetime","datetime2","datetime64","smalldatetime","date","date32","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange","decimal","decimal32","decimal64","decimal128","decimal256","decfloat","udecimal","bigdecimal","uuid","geography","geographypoint","geometry","point","ring","linestring","multilinestring","polygon","multipolygon","hllsketch","hstore","pseudoType","super","serial","smallserial","bigserial","xml","year","userdefined","money","smallmoney","rowversion","image","variant","vector","void","object","objectIdentifier","inet","ipaddress","ipprefix","ipv4","ipv6","unknown","nothing","null","name","tdigest","dynamic",...S.ENUM_TYPE_TOKENS,...S.NESTED_TYPE_TOKENS,...S.AGGREGATE_TYPE_TOKENS])}static get SIGNED_TO_UNSIGNED_TYPE_TOKEN(){return{bigint:"ubigint",int:"uint",mediumint:"umediumint",smallint:"usmallint",tinyint:"utinyint",decimal:"udecimal",double:"udouble"}}static get SUBQUERY_PREDICATES(){return{any:Tt,all:cs,exists:Ys,some:Tt}}static get SUBQUERY_TOKENS(){return new Set(["select","with","from"])}static get RESERVED_TOKENS(){return new Set([...Object.values(Fr.SINGLE_TOKENS),"select"].filter(e=>e!=="identifier"))}static get DB_CREATABLES(){return new Set(["database","dictionary","fileFormat","model","namespace","schema","semanticView","sequence","sink","source","stage","storageIntegration","streamlit","table","tag","view","warehouse"])}static get CREATABLES(){return new Set(["column","constraint","foreignKey","function","index","procedure","trigger","type",...S.DB_CREATABLES])}static get TRIGGER_EVENTS(){return new Set(["insert","update","delete","truncate"])}static get ALTERABLES(){return new Set(["index","table","view","session"])}static get ID_VAR_TOKENS(){return(()=>{let e=new Set(["all","analyze","attach","var","anti","apply","asc","asof","autoIncrement","begin","bpchar","cache","case","collate","command","comment","commit","constraint","copy","cube","currentSchema","default","delete","desc","describe","detach","dictionary","div","end","execute","export","escape","false","first","file","filter","final","format","full","get","identifier","inout","is","isnull","interval","keep","kill","left","limit","load","lock","match","merge","natural","next","offset","operator","ordinality","over","overlaps","overwrite","partition","percent","pivot","pragma","put","range","recursive","references","refresh","rename","replace","right","rollup","row","rows","semi","set","settings","show","stream","streamlit","temporary","top","true","truncate","unique","unnest","unpivot","update","use","volatile","window",...S.ALTERABLES,...S.CREATABLES,...Object.keys(S.SUBQUERY_PREDICATES),...S.TYPE_TOKENS,...Object.keys(S.NO_PAREN_FUNCTIONS)]);return e.delete("union"),e})()}static get TABLE_ALIAS_TOKENS(){return new Set([...S.ID_VAR_TOKENS].filter(e=>!["anti","asof","full","left","lock","natural","right","semi","window"].includes(e)))}static get ALIAS_TOKENS(){return S.ID_VAR_TOKENS}static get COLON_PLACEHOLDER_TOKENS(){return S.ID_VAR_TOKENS}static get ARRAY_CONSTRUCTORS(){return{ARRAY:ue,LIST:KC}}static get COMMENT_TABLE_ALIAS_TOKENS(){return new Set([...S.TABLE_ALIAS_TOKENS].filter(e=>e!=="is"))}static get UPDATE_ALIAS_TOKENS(){return new Set([...S.TABLE_ALIAS_TOKENS].filter(e=>e!=="set"))}static get TRIM_TYPES(){return new Set(["leading".toUpperCase(),"trailing".toUpperCase(),"both".toUpperCase()])}static get TABLE_FAST_TERMINATORS(){return new Set(["comma","groupBy","having","join","limit","on","orderBy","rParen","semicolon","where",...S.SET_OPERATIONS,...S.JOIN_KINDS,...S.JOIN_METHODS,...S.JOIN_SIDES])}static get FUNC_TOKENS(){return new Set(["collate","command","currentDate","currentDatetime","currentSchema","currentTimestamp","currentTime","currentUser","currentCatalog","filter","first","format","get","glob","identifier","index","isnull","ilike","insert","like","localtime","localtimestamp","merge","next","offset","primaryKey","range","replace","rlike","row","sessionUser","unnest","var","left","right","sequence","date","datetime","table","timestamp","timestamptz","truncate","utcDate","utcTime","utcTimestamp","window","xor",...S.TYPE_TOKENS,...Object.keys(S.SUBQUERY_PREDICATES)])}static get CONJUNCTION(){return{and:Te}}static get ASSIGNMENT(){return{colonEq:ot}}static get DISJUNCTION(){return{or:pt}}static get EQUALITY(){return{eq:Me,neq:xt,nullsafeEq:Ks}}static get COMPARISON(){return{gt:je,gte:Je,lt:Fe,lte:nt}}static get BITWISE(){return{amp:rh,caret:JC,pipe:XC}}static get TERM(){return{dash:Ce,plus:we,mod:jr,collate:kA}}static get FACTOR(){return{div:Un,lrArrow:QC,slash:Mt,star:Ts}}static get EXPONENT(){return{}}static get TIMES(){return new Set(["time","timetz"])}static get TIMESTAMPS(){return new Set(["timestamp","timestampntz","timestamptz","timestampltz",...S.TIMES])}static get SET_OPERATIONS(){return new Set(["union","intersect","except"])}static get JOIN_METHODS(){return new Set(["asof","natural","positional"])}static get JOIN_SIDES(){return new Set(["left","right","full"])}static get JOIN_KINDS(){return new Set(["anti","cross","inner","outer","semi","straightJoin"])}static get LAMBDAS(){return{arrow:function(e){return this.expression(ps,{this:this.replaceLambda(this.parseDisjunction(),e),expressions:e})},farrow:function(e){return this.expression(oh,{this:Q(e[0].name),expression:this.parseDisjunction()})}}}static get COLUMN_OPERATORS(){return{dot:void 0,dotcolon:function(e,t){return this.expression(mb,{this:e,to:t})},dcolon:function(e,t){return this.buildCast({strict:this._constructor.STRICT_CAST,this:e,to:t})},arrow:function(e,t){return this.expression(Ns,{this:e,expression:this.dialect.toJsonPath(t),onlyJsonTypes:this._constructor.JSON_ARROWS_REQUIRE_JSON_TYPE})},darrow:function(e,t){return this.expression(bn,{this:e,expression:this.dialect.toJsonPath(t),onlyJsonTypes:this._constructor.JSON_ARROWS_REQUIRE_JSON_TYPE,scalarOnly:this._dialectConstructor.JSON_EXTRACT_SCALAR_SCALAR_ONLY})},hashArrow:function(e,t){return this.expression(Nh,{this:e,expression:t})},dhashArrow:function(e,t){return this.expression(Eb,{this:e,expression:t})},placeholder:function(e,t){return this.expression(gb,{this:e,expression:t})}}}static get CAST_COLUMN_OPERATORS(){return new Set(["dotcolon","dcolon"])}static get EXPRESSION_PARSERS(){return{cluster:function(){return this.parseSort(rr,"clusterBy")},column:function(){return this.parseColumn()},columnDef:function(){return this.parseColumnDef(this.parseColumn())},condition:function(){return this.parseDisjunction()},dataType:function(){return this.parseTypes({allowIdentifiers:!1,schema:!0})},expression:function(){return this.parseExpression()},from:function(){return this.parseFrom({joins:!0})},grantPrincipal:function(){return this.parseGrantPrincipal()},grantPrivilege:function(){return this.parseGrantPrivilege()},group:function(){return this.parseGroup()},having:function(){return this.parseHaving()},hint:function(){return this.parseHintBody()},identifier:function(){return this.parseIdVar()},join:function(){return this.parseJoin()},lambda:function(){return this.parseLambda()},lateral:function(){return this.parseLateral()},limit:function(){return this.parseLimit()},offset:function(){return this.parseOffset()},order:function(){return this.parseOrder()},ordered:function(){return this.parseOrdered()},properties:function(){return this.parseProperties()},partitionedByProperty:function(){return this.parsePartitionedBy()},qualify:function(){return this.parseQualify()},returning:function(){return this.parseReturning()},select:function(){return this.parseSelect()},sort:function(){return this.parseSort(zl,"sortBy")},table:function(){return this.parseTableParts()},tableAlias:function(){return this.parseTableAlias()},tuple:function(){return this.parseValue({values:!1})},whens:function(){return this.parseWhenMatched()},where:function(){return this.parseWhere()},window:function(){return this.parseNamedWindow()},with:function(){return this.parseWith()},JOIN_TYPE:n(function(){let{method:e,side:t,kind:s}=this.parseJoinParts();return new fe({method:e?.text,side:st(Vt,t?.text),kind:st(Vt,s?.text)})},"JOIN_TYPE")}}static get STATEMENT_PARSERS(){return{alter:function(){return this.parseAlter()},analyze:function(){return this.parseAnalyze()},begin:function(){return this.parseTransaction()},cache:function(){return this.parseCache()},comment:function(){return this.parseComment()},commit:function(){return this.parseCommitOrRollback()},copy:function(){return this.parseCopy()},create:function(){return this.parseCreate()},delete:function(){return this.parseDelete()},desc:function(){return this.parseDescribe()},describe:function(){return this.parseDescribe()},drop:function(){return this.parseDrop()},grant:function(){return this.parseGrant()},revoke:function(){return this.parseRevoke()},insert:function(){return this.parseInsert()},kill:function(){return this.parseKill()},load:function(){return this.parseLoad()},merge:function(){return this.parseMerge()},pivot:function(){return this.parseSimplifiedPivot()},pragma:function(){return this.expression(Ay,{this:this.parseExpression()})},refresh:function(){return this.parseRefresh()},rollback:function(){return this.parseCommitOrRollback()},set:function(){return this.parseSet()},truncate:function(){return this.parseTruncateTable()},uncache:function(){return this.parseUncache()},unpivot:function(){return this.parseSimplifiedPivot({isUnpivot:!0})},update:function(){return this.parseUpdate()},use:function(){return this.parseUse()},semicolon:()=>new bC({})}}static get UNARY_PARSERS(){return{plus:function(){return this.parseUnary()},not:function(){return this.expression(Le,{this:this.parseEquality()})},tilde:function(){return this.expression(lh,{this:this.parseUnary()})},dash:function(){return this.expression(Pt,{this:this.parseUnary()})},pipeSlash:function(){return this.expression(Ch,{this:this.parseUnary()})},dpipeSlash:function(){return this.expression(Ah,{this:this.parseUnary()})}}}static get STRING_PARSERS(){return{heredocString:function(e){return this.expression(Mn,{token:e})},nationalString:function(e){return this.expression(Fy,{token:e})},rawString:function(e){return this.expression(Mn,{token:e})},string:function(e){return this.expression(I,{token:e,isString:!0})},unicodeString:function(e){return this.expression(MC,{token:e,escape:this.matchTextSeq("UESCAPE")&&this.parseString()})}}}static get NUMERIC_PARSERS(){return{bitString:function(e){return this.expression(LC,{token:e})},byteString:function(e){return this.expression(wC,{token:e,isBytes:this._dialectConstructor.BYTE_STRING_IS_BYTES_TYPE||void 0})},hexString:function(e){return this.expression(xu,{token:e,isInteger:this._dialectConstructor.HEX_STRING_IS_INTEGER_TYPE||void 0})},number:function(e){return this.expression(I,{token:e,isString:!1})}}}static get PRIMARY_PARSERS(){return{...S.STRING_PARSERS,...S.NUMERIC_PARSERS,introducer:function(e){return this.parseIntroducer(e)},null:function(e){return this.expression(Lt,{})},true:function(e){return this.expression(at,{this:!0})},false:function(e){return this.expression(at,{this:!1})},sessionParameter:function(e){return this.parseSessionParameter()},star:function(e){return this.parseStarOps()}}}static get PLACEHOLDER_PARSERS(){return{placeholder:function(){return this.expression(ar)},parameter:function(){return this.parseParameter()},colon:function(){return this.matchSet(this._constructor.COLON_PLACEHOLDER_TOKENS)?this.expression(ar,{this:this.prev?.text}):void 0}}}static get RANGE_PARSERS(){return{atGt:zt(Fn),between:function(e){return this.parseBetween(e)},glob:zt(wA),ilike:zt(Gs),in:function(e){return this.parseIn(e)},irlike:zt(Tb),is:function(e){return this.parseIs(e)},like:zt(Zt),ltAt:zt(Fn,{reverseArgs:!0}),overlaps:zt(zC),rlike:zt(Ga),similarTo:zt(ZC),for:function(e){return this.parseComprehension(e)},qmarkAmp:zt(Oh),qmarkPipe:zt(Rh),hashDash:zt(mh),adjacent:zt(ph),operator:function(e){return this.parseOperator(e)},ampLt:zt(nh),ampGt:zt(ah)}}static get PIPE_SYNTAX_TRANSFORM_PARSERS(){return{AGGREGATE:n(function(e){return this.parsePipeSyntaxAggregate(e)},"AGGREGATE"),AS:n(function(e){return this.buildPipeCte({query:e,expressions:[new Ne({})],aliasCte:this.parseTableAlias()})},"AS"),EXTEND:n(function(e){return this.parsePipeSyntaxExtend(e)},"EXTEND"),LIMIT:n(function(e){return this.parsePipeSyntaxLimit(e)},"LIMIT"),"ORDER BY":n(function(e){return e.orderBy(this.parseOrder(),{append:!1,copy:!1})},"ORDER BY"),PIVOT:n(function(e){return this.parsePipeSyntaxPivot(e)},"PIVOT"),SELECT:n(function(e){return this.parsePipeSyntaxSelect(e)},"SELECT"),TABLESAMPLE:n(function(e){return this.parsePipeSyntaxTablesample(e)},"TABLESAMPLE"),UNPIVOT:n(function(e){return this.parsePipeSyntaxPivot(e)},"UNPIVOT"),WHERE:n(function(e){return e.where(this.parseWhere(),{copy:!1})},"WHERE")}}static get PROPERTY_PARSERS(){return{ALLOWED_VALUES:n(function(){return this.expression(Vn,{expressions:this.parseCsv(this.parsePrimary.bind(this))})},"ALLOWED_VALUES"),ALGORITHM:n(function(){return this.parsePropertyAssignment(Wn)},"ALGORITHM"),AUTO:n(function(){return this.parseAutoProperty()},"AUTO"),AUTO_INCREMENT:n(function(){return this.parsePropertyAssignment(jn)},"AUTO_INCREMENT"),BACKUP:n(function(){return this.expression(Jn,{this:this.parseVar({anyToken:!0})})},"BACKUP"),BLOCKCOMPRESSION:n(function(){return this.parseBlockCompression()},"BLOCKCOMPRESSION"),CHARSET:n(function(e){return this.parseCharacterSet(e)},"CHARSET"),"CHARACTER SET":n(function(e){return this.parseCharacterSet(e)},"CHARACTER SET"),CHECKSUM:n(function(){return this.parseChecksum()},"CHECKSUM"),"CLUSTER BY":n(function(){return this.parseCluster()},"CLUSTER BY"),CLUSTERED:n(function(){return this.parseClusteredBy()},"CLUSTERED"),COLLATE:n(function(...e){return this.parsePropertyAssignment(zn,e[0])},"COLLATE"),COMMENT:n(function(){return this.parsePropertyAssignment(Ia)},"COMMENT"),CONTAINS:n(function(){return this.parseContainsProperty()},"CONTAINS"),COPY:n(function(){return this.parseCopyProperty()},"COPY"),DATABLOCKSIZE:n(function(e){return this.parseDataBlocksize(e)},"DATABLOCKSIZE"),DATA_DELETION:n(function(){return this.parseDataDeletionProperty()},"DATA_DELETION"),DEFINER:n(function(){return this.parseDefiner()},"DEFINER"),DETERMINISTIC:n(function(){return this.expression(Fs,{this:I.string("IMMUTABLE")})},"DETERMINISTIC"),DISTRIBUTED:n(function(){return this.parseDistributedProperty()},"DISTRIBUTED"),DUPLICATE:n(function(){return this.parseCompositeKeyProperty(Bu)},"DUPLICATE"),DYNAMIC:n(function(){return this.expression(Aa,{})},"DYNAMIC"),DISTKEY:n(function(){return this.parseDistkey()},"DISTKEY"),DISTSTYLE:n(function(){return this.parsePropertyAssignment(ta)},"DISTSTYLE"),EMPTY:n(function(){return this.expression(da,{})},"EMPTY"),ENGINE:n(function(){return this.parsePropertyAssignment(sa)},"ENGINE"),ENVIRONMENT:n(function(){return this.expression(ga,{expressions:this.parseWrappedCsv(this.parseAssignment.bind(this))})},"ENVIRONMENT"),HANDLER:n(function(){return this.parsePropertyAssignment(ra)},"HANDLER"),EXECUTE:n(function(){return this.parsePropertyAssignment(nr)},"EXECUTE"),EXTERNAL:n(function(){return this.expression(oa,{})},"EXTERNAL"),FALLBACK:n(function(e){return this.parseFallback(e)},"FALLBACK"),FORMAT:n(function(){return this.parsePropertyAssignment(ir)},"FORMAT"),FREESPACE:n(function(){return this.parseFreespace()},"FREESPACE"),GLOBAL:n(function(){return this.expression(ca,{})},"GLOBAL"),HEAP:n(function(){return this.expression(na,{})},"HEAP"),ICEBERG:n(function(){return this.expression(pa,{})},"ICEBERG"),IMMUTABLE:n(function(){return this.expression(Fs,{this:I.string("IMMUTABLE")})},"IMMUTABLE"),INHERITS:n(function(){return this.expression(la,{expressions:this.parseWrappedCsv(this.parseTable.bind(this))})},"INHERITS"),INPUT:n(function(){return this.expression(ua,{this:this.parseSchema()})},"INPUT"),JOURNAL:n(function(e){return this.parseJournal(e)},"JOURNAL"),LANGUAGE:n(function(){return this.parsePropertyAssignment(Qr)},"LANGUAGE"),LAYOUT:n(function(){return this.parseDictProperty({this:"LAYOUT"})},"LAYOUT"),LIFETIME:n(function(){return this.parseDictRange({this:"LIFETIME"})},"LIFETIME"),LIKE:n(function(){return this.parseCreateLike()},"LIKE"),LOCATION:n(function(){return this.parsePropertyAssignment(Zr)},"LOCATION"),LOCK:n(function(){return this.parseLocking()},"LOCK"),LOCKING:n(function(){return this.parseLocking()},"LOCKING"),LOG:n(function(e){return this.parseLog(e)},"LOG"),MATERIALIZED:n(function(){return this.expression(fa,{})},"MATERIALIZED"),MERGEBLOCKRATIO:n(function(e){return this.parseMergeBlockRatio(e)},"MERGEBLOCKRATIO"),MODIFIES:n(function(){return this.parseModifiesProperty()},"MODIFIES"),MULTISET:n(function(){return this.expression(_r,{multi:!0})},"MULTISET"),NO:n(function(){return this.parseNoProperty()},"NO"),ON:n(function(){return this.parseOnProperty()},"ON"),"ORDER BY":n(function(){return this.parseOrder({skipOrderToken:!0})},"ORDER BY"),OUTPUT:n(function(){return this.expression(ha,{this:this.parseSchema()})},"OUTPUT"),PARTITION:n(function(){return this.parsePartitionedOf()},"PARTITION"),"PARTITION BY":n(function(){return this.parsePartitionedBy()},"PARTITION BY"),"PARTITIONED BY":n(function(){return this.parsePartitionedBy()},"PARTITIONED BY"),PARTITIONED_BY:n(function(){return this.parsePartitionedBy()},"PARTITIONED_BY"),"PRIMARY KEY":n(function(){return this.parsePrimaryKey({inProps:!0})},"PRIMARY KEY"),RANGE:n(function(){return this.parseDictRange({this:"RANGE"})},"RANGE"),READS:n(function(){return this.parseReadsProperty()},"READS"),REMOTE:n(function(){return this.parseRemoteWithConnection()},"REMOTE"),RETURNS:n(function(){return this.parseReturns()},"RETURNS"),STRICT:n(function(){return this.expression(Oa,{})},"STRICT"),STREAMING:n(function(){return this.expression(Sa,{})},"STREAMING"),ROW:n(function(){return this.parseRow()},"ROW"),ROW_FORMAT:n(function(){return this.parsePropertyAssignment(ma)},"ROW_FORMAT"),SAMPLE:n(function(){return this.expression(Na,{this:this.matchTextSeq("BY")&&this.parseBitwise()})},"SAMPLE"),SECURE:n(function(){return this.expression(La,{})},"SECURE"),SECURITY:n(function(){return this.parseSqlSecurity()},"SECURITY"),"SQL SECURITY":n(function(){return this.parseSqlSecurity()},"SQL SECURITY"),SET:n(function(){return this.expression(_r,{multi:!1})},"SET"),SETTINGS:n(function(){return this.parseSettingsProperty()},"SETTINGS"),SHARING:n(function(){return this.parsePropertyAssignment(ya)},"SHARING"),SORTKEY:n(function(){return this.parseSortkey()},"SORTKEY"),SOURCE:n(function(){return this.parseDictProperty({this:"SOURCE"})},"SOURCE"),STABLE:n(function(){return this.expression(Fs,{this:I.string("STABLE")})},"STABLE"),STORED:n(function(){return this.parseStored()},"STORED"),SYSTEM_VERSIONING:n(function(){return this.parseSystemVersioningProperty()},"SYSTEM_VERSIONING"),TBLPROPERTIES:n(function(){return this.parseWrappedProperties()},"TBLPROPERTIES"),TEMP:n(function(){return this.expression($s,{})},"TEMP"),TEMPORARY:n(function(){return this.expression($s,{})},"TEMPORARY"),TO:n(function(){return this.parseToTable()},"TO"),TRANSIENT:n(function(){return this.expression(Ma,{})},"TRANSIENT"),TRANSFORM:n(function(){return this.expression(wa,{expressions:this.parseWrappedCsv(this.parseExpression.bind(this))})},"TRANSFORM"),TTL:n(function(){return this.parseTtl()},"TTL"),USING:n(function(){return this.parsePropertyAssignment(ir)},"USING"),UNLOGGED:n(function(){return this.expression(ka,{})},"UNLOGGED"),VOLATILE:n(function(){return this.parseVolatileProperty()},"VOLATILE"),WITH:n(function(){return this.parseWithProperty()},"WITH")}}static get CONSTRAINT_PARSERS(){return{AUTOINCREMENT:n(function(){return this.parseAutoIncrement()},"AUTOINCREMENT"),AUTO_INCREMENT:n(function(){return this.parseAutoIncrement()},"AUTO_INCREMENT"),CASESPECIFIC:n(function(){return this.expression(kn,{not:!1})},"CASESPECIFIC"),"CHARACTER SET":n(function(){return this.expression(fu,{this:this.parseVarOrString()})},"CHARACTER SET"),CHECK:n(function(){return this.parseCheckConstraint()},"CHECK"),COLLATE:n(function(){return this.expression(Su,{this:this.parseIdentifier()||this.parseColumn()})},"COLLATE"),COMMENT:n(function(){return this.expression(Ru,{this:this.parseString()})},"COMMENT"),COMPRESS:n(function(){return this.parseCompress()},"COMPRESS"),CLUSTERED:n(function(){return this.expression(Tu,{this:this.parseWrappedCsv(()=>this.parseOrdered())})},"CLUSTERED"),NONCLUSTERED:n(function(){return this.expression(bu,{this:this.parseWrappedCsv(()=>this.parseOrdered())})},"NONCLUSTERED"),DEFAULT:n(function(){return this.expression(mu,{this:this.parseBitwise()})},"DEFAULT"),ENCODE:n(function(){return this.expression(Nu,{this:this.parseVar()})},"ENCODE"),EPHEMERAL:n(function(){return this.expression(yu,{this:this.parseBitwise()})},"EPHEMERAL"),EXCLUDE:n(function(){return this.expression(Iu,{this:this.parseIndexParams()})},"EXCLUDE"),"FOREIGN KEY":n(function(){return this.parseForeignKey()},"FOREIGN KEY"),FORMAT:n(function(){return this.expression(Ou,{this:this.parseVarOrString()})},"FORMAT"),GENERATED:n(function(){return this.parseGeneratedAsIdentity()},"GENERATED"),IDENTITY:n(function(){return this.parseAutoIncrement()},"IDENTITY"),INLINE:n(function(){return this.parseInline()},"INLINE"),LIKE:n(function(){return this.parseCreateLike()},"LIKE"),NOT:n(function(){return this.parseNotConstraint()},"NOT"),NULL:n(function(){return this.expression(LA,{allowNull:!0})},"NULL"),ON:n(function(){return this.match("update")&&this.expression(Lu,{this:this.parseFunction()})||this.expression(Vr,{this:this.parseIdVar()})},"ON"),PATH:n(function(){return this.expression(Du,{this:this.parseString()})},"PATH"),PERIOD:n(function(){return this.parsePeriodForSystemTime()},"PERIOD"),"PRIMARY KEY":n(function(){return this.parsePrimaryKey()},"PRIMARY KEY"),REFERENCES:n(function(){return this.parseReferences({match:!1})},"REFERENCES"),TITLE:n(function(){return this.expression(wu,{this:this.parseVarOrString()})},"TITLE"),TTL:n(function(){return this.expression(Pn,{expressions:[this.parseBitwise()]})},"TTL"),UNIQUE:n(function(){return this.parseUnique()},"UNIQUE"),UPPERCASE:n(function(){return this.expression(ku)},"UPPERCASE"),WITH:n(function(){return this.expression(He,{expressions:this.parseWrappedProperties()})},"WITH"),BUCKET:n(function(){return this.parsePartitionedByBucketOrTruncate()},"BUCKET"),TRUNCATE:n(function(){return this.parsePartitionedByBucketOrTruncate()},"TRUNCATE")}}static get ALTER_PARSERS(){return{ADD:n(function(){return this.parseAlterTableAdd()},"ADD"),AS:n(function(){return this.parseSelect()},"AS"),ALTER:n(function(){return this.parseAlterTableAlter()},"ALTER"),"CLUSTER BY":n(function(){return this.parseCluster({wrapped:!0})},"CLUSTER BY"),DELETE:n(function(){return this.expression(Gr,{where:this.parseWhere()})},"DELETE"),DROP:n(function(){return this.parseAlterTableDrop()},"DROP"),RENAME:n(function(){return this.parseAlterTableRename()},"RENAME"),SET:n(function(){return this.parseAlterTableSet()},"SET"),SWAP:n(function(){return this.expression(Kl,{this:this.match("with")&&this.parseTable({schema:!0})})},"SWAP")}}static get NO_PAREN_FUNCTION_PARSERS(){return{ANY:n(function(){return this.expression(Tt,{this:this.parseBitwise()})},"ANY"),CASE:n(function(){return this.parseCase()},"CASE"),CONNECT_BY_ROOT:n(function(){return this.expression(Eh,{this:this.parseColumn()})},"CONNECT_BY_ROOT"),IF:n(function(){return this.parseIf()},"IF")}}static get INVALID_FUNC_NAME_TOKENS(){return new Set(["identifier","string"])}static get KEY_VALUE_DEFINITIONS(){return new Set([Oe,Me,ot,On])}static get FUNCTION_PARSERS(){return{...Object.fromEntries(qA.sqlNames().map(e=>[e,function(){return this.parseMaxMinBy(qA)}])),...Object.fromEntries(UA.sqlNames().map(e=>[e,function(){return this.parseMaxMinBy(UA)}])),CAST:n(function(){return this.parseCast({strict:this._constructor.STRICT_CAST})},"CAST"),CEIL:n(function(){return this.parseCeilFloor(ti)},"CEIL"),CONVERT:n(function(){return this.parseConvert({strict:this._constructor.STRICT_CAST})},"CONVERT"),CHAR:n(function(){return this.parseChar()},"CHAR"),CHR:n(function(){return this.parseChar()},"CHR"),DECODE:n(function(){return this.parseDecode()},"DECODE"),EXTRACT:n(function(){return this.parseExtract()},"EXTRACT"),FLOOR:n(function(){return this.parseCeilFloor(fh)},"FLOOR"),GAP_FILL:n(function(){return this.parseGapFill()},"GAP_FILL"),INITCAP:n(function(){return this.parseInitcap()},"INITCAP"),JSON_OBJECT:n(function(){return this.parseJsonObject()},"JSON_OBJECT"),JSON_OBJECTAGG:n(function(){return this.parseJsonObject({agg:!0})},"JSON_OBJECTAGG"),JSON_TABLE:n(function(){return this.parseJsonTable()},"JSON_TABLE"),MATCH:n(function(){return this.parseMatchAgainst()},"MATCH"),NORMALIZE:n(function(){return this.parseNormalize()},"NORMALIZE"),OPENJSON:n(function(){return this.parseOpenJson()},"OPENJSON"),OVERLAY:n(function(){return this.parseOverlay()},"OVERLAY"),POSITION:n(function(){return this.parsePosition()},"POSITION"),SAFE_CAST:n(function(){return this.parseCast({strict:!1,safe:!0})},"SAFE_CAST"),STRING_AGG:n(function(){return this.parseStringAgg()},"STRING_AGG"),SUBSTRING:n(function(){return this.parseSubstring()},"SUBSTRING"),TRIM:n(function(){return this.parseTrim()},"TRIM"),TRY_CAST:n(function(){return this.parseCast({strict:!1,safe:!0})},"TRY_CAST"),TRY_CONVERT:n(function(){return this.parseConvert({strict:!1,safe:!0})},"TRY_CONVERT"),XMLELEMENT:n(function(){return this.parseXmlElement()},"XMLELEMENT"),XMLTABLE:n(function(){return this.parseXmlTable()},"XMLTABLE")}}static get QUERY_MODIFIER_PARSERS(){return{matchRecognize:function(){return["match",this.parseMatchRecognize()]},prewhere:function(){return["prewhere",this.parsePrewhere()]},where:function(){return["where",this.parseWhere()]},groupBy:function(){return["group",this.parseGroup()]},having:function(){return["having",this.parseHaving()]},qualify:function(){return["qualify",this.parseQualify()]},window:function(){return["windows",this.parseWindowClause()]},orderBy:function(){return["order",this.parseOrder()]},limit:function(){return["limit",this.parseLimit()]},fetch:function(){return["limit",this.parseLimit()]},offset:function(){return["offset",this.parseOffset()]},for:function(){return["locks",this.parseLocks()]},lock:function(){return["locks",this.parseLocks()]},tableSample:function(){return["sample",this.parseTableSample({asModifier:!0})]},using:function(){return["sample",this.parseTableSample({asModifier:!0})]},clusterBy:function(){return["cluster",this.parseSort(rr,"clusterBy")]},distributeBy:function(){return["distribute",this.parseSort($C,"distributeBy")]},sortBy:function(){return["sort",this.parseSort(zl,"sortBy")]},connectBy:function(){return["connect",this.parseConnect({skipStartToken:!0})]},startWith:function(){return["connect",this.parseConnect()]}}}static get QUERY_MODIFIER_TOKENS(){return new Set(Object.keys(S.QUERY_MODIFIER_PARSERS))}static get TYPE_LITERAL_PARSERS(){return{json:function(e,t){return this.expression(ai,{this:e})}}}static get TYPE_CONVERTERS(){return{}}static get DDL_SELECT_TOKENS(){return new Set(["select","with","lParen"])}static get PRE_VOLATILE_TOKENS(){return new Set(["create","replace","unique"])}static get OPTYPE_FOLLOW_TOKENS(){return new Set(["comma","rParen"])}static get TABLE_INDEX_HINT_TOKENS(){return new Set(["force","ignore","use"])}static get WINDOW_ALIAS_TOKENS(){return(()=>{let e=new Set(S.ID_VAR_TOKENS);return e.delete("range"),e.delete("rows"),e})()}static get WINDOW_BEFORE_PAREN_TOKENS(){return new Set(["over"])}static get JSON_KEY_VALUE_SEPARATOR_TOKENS(){return new Set(["colon","comma","is"])}static get FETCH_TOKENS(){return(()=>{let e=new Set(S.ID_VAR_TOKENS);return e.delete("row"),e.delete("rows"),e.delete("percent"),e})()}static get ADD_CONSTRAINT_TOKENS(){return new Set(["constraint","foreignKey","index","key","primaryKey","unique"])}static get DISTINCT_TOKENS(){return new Set(["distinct"])}static get UNNEST_OFFSET_ALIAS_TOKENS(){return(()=>{let e=new Set(S.TABLE_ALIAS_TOKENS);for(let t of S.SET_OPERATIONS)e.delete(t);return e})()}static get SELECT_START_TOKENS(){return new Set(["lParen","with","select"])}static get PRIVILEGE_FOLLOW_TOKENS(){return new Set(["on","comma","lParen"])}static get AMBIGUOUS_ALIAS_TOKENS(){return["limit","offset"]}static get MODIFIABLES(){return[ee,W,_l,tr]}reset(){this.sql="",this.errors=[],this.tokens=[],this.index=0,this.curr=void 0,this.next=void 0,this.prev=void 0,this.prevComments=void 0,this.pipeCteCounter=0,this._chunks=[],this._chunkIndex=0}parse(e,t){return this._parse({parseMethod:n(function(){return this.parseStatement()},"parseMethod"),rawTokens:e,sql:t})}_parse(e){let{parseMethod:t,rawTokens:s,sql:r}=e;this.reset(),this.sql=r||"";let i=s.length,o=[[]];for(let p=0;p<s.length;p++){let u=s[p];u.tokenType==="semicolon"?(u.comments.length&&o.push([u]),p<i-1&&o.push([])):o[o.length-1].push(u)}return this._chunks=o,this._chunkIndex=0,this.parseBatchStatements(p=>t.call(p),{sepFirstStatement:!1})}parseIntoTypes(e,t,s){let r=[],i=J(e);for(let p of i){let u=typeof p=="string"?this._constructor.EXPRESSION_PARSERS[p]??this._constructor.EXPRESSION_PARSERS[p.charAt(0).toLowerCase()+p.slice(1)]:this._constructor.EXPRESSION_PARSERS[p.key];if(!u)throw new TypeError(`No parser registered for ${p}`);try{return this._parse({parseMethod:u,rawTokens:t,sql:s})}catch(h){if(h instanceof Ke)h.errors[0].intoExpression=typeof p=="string"?p:p.name,r.push(h);else throw h}}let c=`[${J(e).map(p=>typeof p=="string"?p:p.name).join(", ")}]`;throw new Ke(`Failed to parse '${s||t}' into ${c}`,Wk(r))}findSql(e,t){return this.sql.slice(e?.start??0,(t?.end??0)+1)}isConnected(){return!!(this.prev&&this.curr&&(this.prev.end??0)+1===(this.curr.start??0))}advance(e=1){this.index+=e,this.curr=k(this.tokens,this.index),this.next=k(this.tokens,this.index+1),0<this.index?(this.prev=this.tokens[this.index-1],this.prevComments=this.prev.comments):(this.prev=void 0,this.prevComments=void 0)}retreat(e){e!==this.index&&this.advance(e-this.index)}warnUnsupported(){if(this.tokens.length<=1)return;let e=this.findSql(this.tokens[0],this.tokens[this.tokens.length-1]).slice(0,this.errorMessageContext);console.warn(`'${e}' contains unsupported syntax. Falling back to parsing as a 'Command'.`)}match(e,t={}){let{advance:s=!0,expression:r}=t;return this.curr?.tokenType===e?(s&&this.advance(),this.addComments(r),!0):!1}tryParse(e,t={}){let{retreat:s=!1}=t,r=this.index,i=this.errorLevel;this.errorLevel=3;let o;try{o=e()}catch(c){if(c instanceof Ke)o=void 0;else throw c}finally{(!o||s)&&this.retreat(r),this.errorLevel=i}return o}parseParen(){if(!this.match("lParen"))return;let e=this.prevComments,t=this.parseSelect(),s;t?s=[t]:s=this.parseExpressions();let r=k(s,0);return!r&&this.match("rParen",{advance:!1})?r=this.expression(Ze,{}):r&&Ls.some(i=>r instanceof i)?r=this.parseSubquery(r,{parseAlias:!1}):r instanceof he||r instanceof tr?r=this.parseSubquery(this.parseQueryModifiers(this.parseSetOperations(r)),{parseAlias:!1}):1<s.length||this.prev?.tokenType==="comma"?r=this.expression(Ze,{expressions:s}):r=this.expression(Re,{this:r}),r&&e&&r.addComments(e),this.matchRParen(r),r instanceof Re&&r.args.this instanceof D?this.parseWindow(r):r}parseDrop(e={}){let{exists:t}=e,s=this.prev,r=this.match("temporary")||void 0,i=this.matchTextSeq("MATERIALIZED")||void 0,o=this.matchTextSeq("ICEBERG")||void 0,c=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev?.text.toUpperCase();if(!c||o&&c&&c!=="TABLE")return this.parseAsCommand(s);let p=this.matchTextSeq("CONCURRENTLY")||void 0,u=t||this.parseExists(),h;c==="COLUMN"?h=this.parseColumn():h=this.parseTableParts({schema:!0,isDbReference:c==="SCHEMA"});let g=this.match("on")?this.parseOnProperty():void 0,x;this.match("lParen",{advance:!1})&&(x=this.parseWrappedCsv(()=>this.parseTypes()));let f=(this.matchTexts(["CASCADE","RESTRICT"])||void 0)&&this.prev?.text.toUpperCase();return this.expression(tu,{exists:u,this:h,expressions:x,kind:st(AM,this._dialectConstructor.CREATABLE_KIND_MAPPING[c]||c)??(this._dialectConstructor.CREATABLE_KIND_MAPPING[c]||c),temporary:r,materialized:i,cascade:f==="CASCADE",restrict:f==="RESTRICT",constraints:this.matchTextSeq("CONSTRAINTS"),purge:this.matchTextSeq("PURGE"),cluster:g,concurrently:p,sync:this.matchTextSeq("SYNC"),iceberg:o})}parseExists(e={}){let{not:t}=e;return this.matchTextSeq("IF")&&(!t||this.match("not"))&&this.match("exists")?!0:void 0}parseCreate(){let e=this.prev,t=e?.tokenType==="replace"||this.matchPair("or","replace")||this.matchPair("or","alter"),s=this.matchPair("or","refresh")||void 0,r=this.match("unique")||void 0,i;this.matchTexts(["FULLTEXT","BITMAP","SPATIAL"])&&(i=this.prev?.text.toUpperCase());let o;this.matchTextSeq(["CLUSTERED","COLUMNSTORE"])?o=!0:(this.matchTextSeq(["NONCLUSTERED","COLUMNSTORE"])||this.matchTextSeq("COLUMNSTORE"))&&(o=!1),this.matchPair("table","function",{advance:!1})&&this.advance();let c,p=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev;if(!p&&(c=this.parseProperties(),p=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev,!c||!p))return this.parseAsCommand(e);let u=this.matchTextSeq("CONCURRENTLY")||void 0,h=this.parseExists({not:!0}),g,x,f,T,y,b,m=n(U=>{c&&U?c.args.expressions?.push(...U.args.expressions??[]):U&&(c=U)},"extendProps");if(p.tokenType==="function"||p.tokenType==="procedure"){if(g=this.parseUserDefinedFunction({kind:p.tokenType}),m(this.parseProperties()),x=this.match("alias")&&this.parseHeredoc()||void 0,m(this.parseProperties()),!x)if(this.match("command"))x=this.parseAsCommand(this.prev);else{y=this.match("begin")||void 0;let U=this.matchTextSeq("RETURN")||void 0;this.match("string",{advance:!1})?(x=this.parseString(),m(this.parseProperties())):x=p.tokenType==="function"?this.parseUserDefinedFunctionExpression():this.parseBlock(),U&&(x=this.expression(ou,{this:x}))}}else if(p.tokenType==="constraint"&&this.match("trigger")||p.tokenType==="trigger"){let U=p.tokenType==="constraint";U&&(p=this.prev);let _=this.parseIdVar();if(!_)return this.parseAsCommand(e);let K=this.parseVarFromOptions(this._constructor.TRIGGER_TIMING,{raiseUnmatched:!1})?.args.this;if(!K)return this.parseAsCommand(e);let H=this.parseTriggerEvents();this.match("on")||this.raiseError("Expected ON in trigger definition");let Ie=this.parseTableParts(),Se=this.match("from")?this.parseTableParts():void 0,[Ot,gt]=this.parseTriggerDeferrable(),ds=this.parseTriggerReferencing(),mt=this.parseTriggerForEach(),Xe=this.matchTextSeq("WHEN")&&this.parseWrapped(()=>this.parseDisjunction(),{optional:!0}),Nt=this.parseTriggerExecute();if(Nt===void 0)return this.parseAsCommand(e);let oe=this.expression(Gn,{table:Ie,timing:K,events:H,execute:Nt,constraint:U,referencedTable:Se,deferrable:Ot,initially:gt,referencing:ds,forEach:mt,when:Xe||void 0});g=_;let V_=new He({expressions:oe?[oe]:[]});m(V_)}else if(p.tokenType==="index"){let U,_;this.match("on")?(U=void 0,_=!0):(U=this.parseIdVar(),_=!1),g=this.parseIndex({index:U,anonymous:_})}else if(p.tokenType==="type"){if(g=this.parseTableParts({schema:!0}),!g||!this.match("alias"))return this.parseAsCommand(e);if(this.match("enum"))x=new N({this:"enum",expressions:this.parseWrappedCsv(this.parseString.bind(this))});else if(this.match("lParen",{advance:!1}))x=this.parseSchema();else return this.parseAsCommand(e)}else if(this._constructor.DB_CREATABLES.has(p.tokenType)){let U=this.parseTableParts({schema:!0,isDbReference:p.tokenType==="schema"});this.match("comma"),m(this.parseProperties({before:!0})),g=this.parseSchema({this:U}),m(this.parseProperties());let _=this.match("alias")||void 0;if(this.matchSet(this._constructor.DDL_SELECT_TOKENS,{advance:!1})||m(this.parseProperties()),p.tokenType==="sequence"){x=this.parseTypes();let K=this.parseProperties();if(K){let H=new Br({}),Ie=[];for(let Se of K.args.expressions??[])if(Se instanceof Br){for(let[Ot,gt]of Object.entries(Se.args))Ot==="options"?Ie.push(...gt):H.setArgKey(Ot,gt);Se.pop()}0<Ie.length&&H.setArgKey("options",Ie),K.args.expressions?.push(H),m(K)}}else x=this.parseDdlSelect(),!x&&_&&(x=this.tryParse(()=>this.parseTableParts()));if(p.tokenType==="table")for(m(this.parseProperties()),f=[];;){let K=this.parseIndex();if(m(this.parseProperties()),K)this.match("comma"),f.push(K);else break}else p.tokenType==="view"?this.matchTextSeq(["WITH","NO","SCHEMA","BINDING"])&&(T=!0):(p.tokenType==="sink"||p.tokenType==="source")&&m(this.parseProperties());let ne=this.matchTextSeq("SHALLOW")||void 0;if(this.matchTexts(this._constructor.CLONE_KEYWORDS)){let K=this.prev?.text.toLowerCase()==="copy";b=this.expression(hy,{this:this.parseTable({schema:!0}),shallow:ne,copy:K})}}if(this.curr&&!this.matchSet(new Set(["rParen","comma"]),{advance:!1}))return this.parseAsCommand(e);let C=p.text.toUpperCase(),q=this._dialectConstructor.CREATABLE_KIND_MAPPING[C]||C;return this.expression(ss,{this:g,kind:st(eA,q)??q,replace:t,refresh:s,unique:r,indexPrefix:i,expression:x,exists:h,properties:c,indexes:f,noSchemaBinding:T,begin:y,clone:b,concurrently:u,clustered:o})}parseCommand(){return this.warnUnsupported(),this.expression($r,{comments:this.prevComments,this:this.prev?.text.toUpperCase(),expression:this.parseString()})}parseSequenceProperties(){let e=new Br({}),t=[],s=this.index;for(;this.curr;)if(this.match("comma"),this.matchTextSeq("INCREMENT"))this.matchTextSeq("BY"),this.matchTextSeq("="),e.setArgKey("increment",this.parseTerm());else if(this.matchTextSeq("MINVALUE"))e.setArgKey("minvalue",this.parseTerm());else if(this.matchTextSeq("MAXVALUE"))e.setArgKey("maxvalue",this.parseTerm());else if(this.match("startWith")||this.matchTextSeq("START"))this.matchTextSeq("="),e.setArgKey("start",this.parseTerm());else if(this.matchTextSeq("CACHE"))e.setArgKey("cache",this.parseNumber()||!0);else if(this.matchTextSeq(["OWNED","BY"]))e.setArgKey("owned",this.matchTextSeq("NONE")?void 0:this.parseColumn());else{let r=this.parseVarFromOptions(this._constructor.CREATE_SEQUENCE,{raiseUnmatched:!1});if(r)t.push(r);else break}return e.setArgKey("options",0<t.length?t:void 0),this.index===s?void 0:e}parseTriggerEvents(){let e=[];for(;;){let t=this.matchSet(this._constructor.TRIGGER_EVENTS)&&this.prev?.text.toUpperCase();t||this.raiseError("Expected trigger event (INSERT, UPDATE, DELETE, TRUNCATE)");let s=t==="UPDATE"&&this.matchTextSeq("OF")?this.parseCsv(()=>this.parseColumn()):void 0;if(e.push(this.expression(py,{this:t,columns:s})),!this.match("or"))break}return e}parseTriggerDeferrable(){let t=this.parseVarFromOptions(this._constructor.TRIGGER_DEFERRABLE,{raiseUnmatched:!1})?.args.this,s;return t&&this.matchTextSeq("INITIALLY")&&(s=this.parseVarFromOptions(this._constructor.TRIGGER_INITIALLY_VALUE,{raiseUnmatched:!1})?.args.this,s||this.raiseError("Expected IMMEDIATE or DEFERRED after INITIALLY")),[t,s]}parseTriggerReferencingClause(e){if(this.matchTextSeq(e))return this.matchTextSeq("TABLE")||this.raiseError(`Expected TABLE after ${e} in REFERENCING clause`),this.matchTextSeq("AS"),this.parseIdVar()}parseTriggerReferencing(){if(!this.matchTextSeq("REFERENCING"))return;let e,t;for(;;){let s=this.parseTriggerReferencingClause("OLD");if(s)e!==void 0&&this.raiseError("Duplicate OLD clause in REFERENCING"),e=s;else{let r=this.parseTriggerReferencingClause("NEW");if(r)t!==void 0&&this.raiseError("Duplicate NEW clause in REFERENCING"),t=r;else break}}return e===void 0&&t===void 0&&this.raiseError("REFERENCING clause requires at least OLD TABLE or NEW TABLE"),this.expression(ly,{old:e,new:t})}parseTriggerForEach(){if(!this.match("for"))return;this.matchTextSeq("EACH");let e=this.parseVarFromOptions(this._constructor.TRIGGER_FOR_EACH,{raiseUnmatched:!1});if(e)return e.args.this;this.raiseError("Expected ROW or STATEMENT after FOR")}parseTriggerExecute(){if(!this.match("execute"))return;this.matchSet(new Set(["function","procedure"]))||this.raiseError("Expected FUNCTION or PROCEDURE after EXECUTE");let e=this.parseFunction({anonymous:!0,optionalParens:!1});return this.expression(cy,{this:e})}parsePropertyBefore(){this.match("comma");let e={no:this.matchTextSeq("NO")||!1,dual:this.matchTextSeq("DUAL")||!1,before:this.matchTextSeq("BEFORE")||!1,default:this.matchTextSeq("DEFAULT")||!1,local:this.matchTextSeq("LOCAL")&&"LOCAL"||this.matchTextSeq(["NOT","LOCAL"])&&"NOT LOCAL"||!1,after:this.matchTextSeq("AFTER")||!1,minimum:this.matchTexts(["MIN","MINIMUM"])||!1,maximum:this.matchTexts(["MAX","MAXIMUM"])||!1};if(this.matchTexts(Object.keys(this._constructor.PROPERTY_PARSERS))){let t=this._constructor.PROPERTY_PARSERS[(this.prev?.text??"").toUpperCase()];try{let s=Object.fromEntries(Object.entries(e).filter(([,i])=>i));return t.call(this,s)??void 0}catch(s){if(s instanceof Ke)throw s;this.raiseError(`Cannot parse property '${this.prev?.text??""}'`)}}}parseWrappedProperties(){return this.parseWrappedCsv(()=>this.parseProperty())}parseProperty(){if(this.matchTexts(Object.keys(this._constructor.PROPERTY_PARSERS)))return this._constructor.PROPERTY_PARSERS[(this.prev?.text??"").toUpperCase()].call(this)??void 0;if(this.match("default")&&this.matchTexts(Object.keys(this._constructor.PROPERTY_PARSERS)))return this._constructor.PROPERTY_PARSERS[(this.prev?.text??"").toUpperCase()].call(this,{default:!0})??void 0;if(this.matchTextSeq(["COMPOUND","SORTKEY"]))return this.parseSortkey({compound:!0});if(this.matchTextSeq(["PARAMETER","STYLE","PANDAS"]))return this.expression(ia,{this:"PANDAS"});let e=this.index,t=this.parseSequenceProperties();if(t)return t;this.retreat(e);let s=this.parseColumn();if(!this.match("eq")){this.retreat(e);return}s instanceof $&&(s=s.parts&&1<s.parts.length?s.toDot()||Q(s.name):Q(s.name));let r=this.parseBitwise()||this.parseVar({anyToken:!0});return r instanceof $&&(r=Q(r.name)),this.expression(w,{this:s,value:r})}parseStored(){if(this.matchTextSeq("BY"))return this.expression(eh,{this:this.parseVarOrString()});this.match("alias");let e=(this.matchTextSeq("INPUTFORMAT")||void 0)&&this.parseString(),t=(this.matchTextSeq("OUTPUTFORMAT")||void 0)&&this.parseString();return this.expression(ir,{this:e||t?this.expression(Zy,{inputFormat:e,outputFormat:t}):this.parseVarOrString()||this.parseNumber()||this.parseIdVar(),hiveFormat:!0})}parseUnquotedField(){let e=this.parseField();return e instanceof F&&!e.args.quoted?Q(e):e}parsePropertyAssignment(e,t){return this.match("eq"),this.match("alias"),this.expression(e,{this:this.parseUnquotedField(),...t})}parseProperties(e){let t=[];for(;;){let s=e?.before?this.parsePropertyBefore():this.parseProperty();if(s===void 0||Array.isArray(s)&&s.length===0)break;let r=Array.isArray(s)?s:[s];for(let i of r)t.push(i)}if(0<t.length)return this.expression(He,{expressions:t})}parseFallback(e){return this.expression($u,{no:e?.no,protection:this.matchTextSeq("PROTECTION")})}parseSqlSecurity(){return this.expression(Pa,{this:this.matchTexts(this._constructor.SECURITY_PROPERTY_KEYWORDS)&&(this.prev?.text??"").toUpperCase()})}parseSettingsProperty(){return this.expression(Ca,{expressions:this.parseCsv(()=>this.parseAssignment())})}parseVolatileProperty(){let e;return 2<=this.index&&(e=this.tokens[this.index-2]),e&&this._constructor.PRE_VOLATILE_TOKENS.has(e.tokenType)?new qa({}):this.expression(Fs,{this:I.string("VOLATILE")})}parseRetentionPeriod(){let e=this.parseNumber(),t=e?`${e} `:"",s=this.parseVar({anyToken:!0});return Q(`${t}${s}`)}parseSystemVersioningProperty(e={}){let{with:t=!1}=e;this.match("eq");let s=this.expression(sh,{on:!0,with:t});if(this.matchTextSeq("OFF"))return s.setArgKey("on",!1),s;if(this.match("on"),this.match("lParen"))for(;this.curr&&!this.match("rParen");)this.matchTextSeq(["HISTORY_TABLE","="])?s.setArgKey("this",this.parseTableParts()):this.matchTextSeq(["DATA_CONSISTENCY_CHECK","="])?(this.advance(),s.setArgKey("dataConsistency",this.prev?.text.toUpperCase())):this.matchTextSeq(["HISTORY_RETENTION_PERIOD","="])&&s.setArgKey("retentionPeriod",this.parseRetentionPeriod()),this.match("comma");return s}parseDataDeletionProperty(){this.match("eq");let e=this.matchTextSeq("ON")||!this.matchTextSeq("OFF"),t=this.expression(Fu,{on:e});if(this.match("lParen"))for(;this.curr&&!this.match("rParen");)this.matchTextSeq(["FILTER_COLUMN","="])?t.setArgKey("filterColumn",this.parseColumn()):this.matchTextSeq(["RETENTION_PERIOD","="])&&t.setArgKey("retentionPeriod",this.parseRetentionPeriod()),this.match("comma");return t}parseDistributedProperty(){let e="HASH",t;this.matchTextSeq(["BY","HASH"])?t=this.parseWrappedCsv(()=>this.parseIdVar()):this.matchTextSeq(["BY","RANDOM"])&&(e="RANDOM");let s;return this.matchTextSeq("BUCKETS")&&!this.matchTextSeq("AUTO")&&(s=this.parseNumber()),this.expression(ea,{expressions:t,kind:e,buckets:s,order:this.parseOrder()})}parseCompositeKeyProperty(e){this.matchTextSeq("KEY");let t=this.parseWrappedIdVars();return this.expression(e,{expressions:t})}parseWithProperty(){if(this.matchTextSeq(["(","SYSTEM_VERSIONING"])){let e=this.parseSystemVersioningProperty({with:!0});return this.matchRParen(),e}if(this.match("lParen",{advance:!1}))return this.parseWrappedProperties();if(this.matchTextSeq("JOURNAL"))return this.parseWithjournaltable();if(this.matchTexts(Array.from(this._constructor.VIEW_ATTRIBUTES)))return this.expression(Da,{this:this.prev?.text.toUpperCase()});if(this.matchTextSeq("DATA"))return this.parseWithdata({no:!1});if(this.matchTextSeq(["NO","DATA"]))return this.parseWithdata({no:!0});if(this.match("serdeProperties",{advance:!1}))return this.parseSerdeProperties({with:!0});if(this.match("schema"))return this.expression(va,{this:this.parseVarFromOptions(this._constructor.SCHEMA_BINDING_OPTIONS)});if(this.matchTexts(Object.keys(this._constructor.PROCEDURE_OPTIONS),{advance:!1}))return this.expression(Fa,{expressions:this.parseCsv(()=>this.parseProcedureOption())});if(this.next)return this.parseWithIsolatedLoading()}parseProcedureOption(){return this.matchTextSeq(["EXECUTE","AS"])?this.expression(nr,{this:this.parseVarFromOptions(this._constructor.EXECUTE_AS_OPTIONS,{raiseUnmatched:!1})||this.parseString()}):this.parseVarFromOptions(this._constructor.PROCEDURE_OPTIONS)}parseDefiner(){this.match("eq");let e=this.parseIdVar();this.match("parameter");let t=this.parseIdVar()||this.match("mod")&&this.prev?.text;if(!(!e||!t))return new Zn({this:`${e}@${t}`})}parseWithjournaltable(){return this.match("table"),this.match("eq"),this.expression(Ua,{this:this.parseTableParts()})}parseLog(e={}){let{no:t=!1}=e;return this.expression(xa,{no:t})}parseJournal(e){return this.expression(Vu,e)}parseChecksum(){this.match("eq");let e;return this.match("on")?e=!0:this.matchTextSeq("OFF")&&(e=!1),this.expression(Uu,{on:e,default:this.match("default")})}parseCluster(e={}){let{wrapped:t=!1}=e;return this.expression(rr,{expressions:t?this.parseWrappedCsv(()=>this.parseOrdered()):this.parseCsv(()=>this.parseOrdered())})}parseClusteredBy(){this.matchTextSeq("BY"),this.matchLParen();let e=this.parseCsv(()=>this.parseColumn());this.matchRParen();let t;this.matchTextSeq(["SORTED","BY"])&&(this.matchLParen(),t=this.parseCsv(()=>this.parseOrdered()),this.matchRParen()),this.match("into");let s=this.parseNumber();return this.matchTextSeq("BUCKETS"),this.expression(Ea,{expressions:e,sortedBy:t,buckets:s})}parseCopyProperty(){if(!this.matchTextSeq("GRANTS")){this.retreat(this.index-1);return}return this.expression(Qn,{})}parseFreespace(){return this.match("eq"),this.expression(Gu,{this:this.parseNumber(),percent:this.match("percent")})}parseMergeBlockRatio(e={}){let{no:t=!1,default:s=!1}=e;return this.match("eq")?this.expression(qn,{this:this.parseNumber(),percent:this.match("percent")}):this.expression(qn,{no:t,default:s})}parseDataBlocksize(e={}){let{default:t,minimum:s,maximum:r}=e;this.match("eq");let i=this.parseNumber(),o;return this.matchTexts(["BYTES","KBYTES","KILOBYTES"])&&(o=this.prev?.text??""),this.expression(vu,{size:i,units:o,default:t,minimum:s,maximum:r})}parseBlockCompression(){this.match("eq");let e=this.matchTextSeq("ALWAYS")||void 0,t=this.matchTextSeq("MANUAL")||void 0,s=this.matchTextSeq("NEVER")||void 0,r=this.matchTextSeq("DEFAULT")||void 0,i;return this.matchTextSeq("AUTOTEMP")&&(i=this.parseSchema()),this.expression(qu,{always:e,manual:t,never:s,default:r,autotemp:i})}parseWithIsolatedLoading(){let e=this.index,t=this.matchTextSeq("NO")||void 0,s=this.matchTextSeq("CONCURRENT")||void 0;if(!this.matchTextSeq(["ISOLATED","LOADING"])){this.retreat(e);return}let r=this.parseVarFromOptions(this._constructor.ISOLATED_LOADING_OPTIONS,{raiseUnmatched:!1});return this.expression(Yu,{no:t,concurrent:s,target:r})}parseLocking(){let e;this.match("table")?e="TABLE":this.match("view")?e="VIEW":this.match("row")?e="ROW":this.matchTextSeq("DATABASE")&&(e="DATABASE");let t;(e==="DATABASE"||e==="TABLE"||e==="VIEW")&&(t=this.parseTableParts());let s;this.match("for")?s="FOR":this.match("in")&&(s="IN");let r;this.matchTextSeq("ACCESS")?r="ACCESS":this.matchTexts(["EXCL","EXCLUSIVE"])?r="EXCLUSIVE":this.matchTextSeq("SHARE")?r="SHARE":this.matchTextSeq("READ")?r="READ":this.matchTextSeq("WRITE")?r="WRITE":this.matchTextSeq("CHECKSUM")&&(r="CHECKSUM");let i=this.matchTextSeq("OVERRIDE")||void 0;return this.expression(ju,{this:t,kind:e,forOrIn:s,lockType:r,override:i})}parsePartitionBy(){return this.match("partitionBy")?this.parseCsv(()=>this.parseDisjunction()):[]}parsePartitionBoundSpec(){let e=n(()=>this.matchTextSeq("MINVALUE")?Q("MINVALUE"):this.matchTextSeq("MAXVALUE")?Q("MAXVALUE"):this.parseBitwise(),"parsePartitionBoundExpr"),t,s,r,i;return this.match("in")?t=this.parseWrappedCsv(()=>this.parseBitwise()):this.match("from")?(r=this.parseWrappedCsv(e),this.matchTextSeq("TO"),i=this.parseWrappedCsv(e)):this.matchTextSeq(["WITH","(","MODULUS"])?(t=this.parseNumber(),this.matchTextSeq([",","REMAINDER"]),s=this.parseNumber(),this.matchRParen()):this.raiseError("Failed to parse partition bound spec."),this.expression(au,{this:t,expression:s,fromExpressions:r,toExpressions:i})}parsePartitionedOf(){if(!this.matchTextSeq("OF")){this.retreat(this.index-1);return}let e=this.parseTable({schema:!0}),t;return this.match("default")?t=Q("DEFAULT"):this.matchTextSeq(["FOR","VALUES"])?t=this.parsePartitionBoundSpec():(this.raiseError("Expecting either DEFAULT or FOR VALUES clause."),t=Q("DEFAULT")),this.expression(zu,{this:e,expression:t})}parsePartitionedBy(){return this.match("eq"),this.expression(Cs,{this:this.parseSchema()||this.parseBracket(this.parseField())})}parseWithdata(e={}){let t;return this.matchTextSeq(["AND","STATISTICS"])?t=!0:this.matchTextSeq(["AND","NO","STATISTICS"])&&(t=!1),this.expression(th,{no:e?.no,statistics:t})}parseContainsProperty(){if(this.matchTextSeq("SQL"))return this.expression(vs,{this:"CONTAINS SQL"})}parseModifiesProperty(){if(this.matchTextSeq(["SQL","DATA"]))return this.expression(vs,{this:"MODIFIES SQL DATA"})}parseNoProperty(){if(this.matchTextSeq(["PRIMARY","INDEX"]))return new Ta({});if(this.matchTextSeq("SQL"))return this.expression(vs,{this:"NO SQL"})}parseOnProperty(){return this.matchTextSeq(["COMMIT","PRESERVE","ROWS"])?new Hr({}):this.matchTextSeq(["COMMIT","DELETE","ROWS"])?new Hr({delete:!0}):this.expression(Vr,{this:this.parseSchema({this:this.parseIdVar()})})}parseReadsProperty(){if(this.matchTextSeq(["SQL","DATA"]))return this.expression(vs,{this:"READS SQL DATA"})}parseDistkey(){return this.expression(Kn,{this:this.parseWrapped(()=>this.parseIdVar())})}parseCreateLike(){let e=this.parseTable({schema:!0}),t=[];for(;this.matchTexts(["INCLUDING","EXCLUDING"]);){let s=(this.prev?.text??"").toUpperCase(),r=this.parseIdVar();if(!r)return;let i=r.args.this;t.push(this.expression(w,{this:s,value:Q(typeof i=="string"?i.toUpperCase():"")}))}return this.expression(Wu,{this:e,expressions:t})}parseSortkey(e={}){let t=this.parseWrappedIdVars(),s=t.length===1?t[0]:this.expression(Ze,{expressions:t});return this.expression(ba,{this:s,compound:e?.compound})}parseCharacterSet(e={}){return this.match("eq"),this.expression(zr,{this:this.parseVarOrString(),default:e?.default??!1})}parseRemoteWithConnection(){return this.matchTextSeq(["WITH","CONNECTION"]),this.expression(Ra,{this:this.parseTableParts()})}parseReturns(){let e,t,s=this.match("table")||void 0;return s?this.match("lt")?(e=this.expression(Rt,{this:"TABLE",expressions:this.parseCsv(()=>this.parseStructTypes())}),this.match("gt")||this.raiseError("Expecting >")):e=this.parseSchema({this:Q("TABLE")}):this.matchTextSeq(["NULL","ON","NULL","INPUT"])?(t=!0,e=void 0):e=this.parseTypes(),this.expression(Kr,{this:e,isTable:s,null:t})}parseDescribe(){let e=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev?.text,t=(this.matchTexts(Array.from(this._constructor.DESCRIBE_STYLES))||void 0)&&this.prev?.text.toUpperCase();this.match("dot")&&(t=void 0,this.retreat(this.index-2));let s=this.match("format",{advance:!1})?this.parseProperty():void 0,r;this.matchSet(new Set(Object.keys(this._constructor.STATEMENT_PARSERS)),{advance:!1})?r=this.parseStatement():r=this.parseTable({schema:!0});let o=this.parseProperties()?.args.expressions,c=this.parsePartition();return this.expression(Ql,{this:r,style:t,kind:e,expressions:o,partition:c,format:s,asJson:this.matchTextSeq(["AS","JSON"])})}parseMultitableInserts(e){let t=(this.prev?.text??"").toUpperCase(),s=[],r=n(()=>{let o;this.match("when")&&(o=this.parseDisjunction(),this.match("then"));let c=this.match("else")||void 0;if(this.match("into"))return this.expression(Dy,{this:this.expression(es,{this:this.parseTable({schema:!0}),expression:this.parseDerivedTableValues()}),expression:o,else:c})},"parseConditionalInsert"),i=r();for(;i!==void 0;)s.push(i),i=r();return this.expression(nu,{kind:t,comments:e,expressions:s,source:this.parseTable()})}parseInsert(){let e=[],t=this.parseHint(),s=this.match("overwrite")||void 0,r=this.match("ignore")||void 0,i=this.matchTextSeq("LOCAL")||void 0,o,c,p;if(this.matchTextSeq("DIRECTORY"))p=this.expression(su,{this:this.parseVarOrString(),local:i,rowFormat:this.parseRowFormat({matchRow:!0})});else{if(this.matchSet(new Set(["first","all"])))return e.push(...J(this.prevComments)),this.parseMultitableInserts(e);this.match("or")&&(o=this.matchTexts(Array.from(this._constructor.INSERT_ALTERNATIVES))&&this.prev?.text||void 0),this.match("into"),e.push(...J(this.prevComments)),this.match("table"),c=this.match("function")||void 0,p=c?this.parseFunction():this.parseInsertTable()}let u=this.parseReturning();return this.expression(es,{comments:e,hint:t,isFunction:c,this:p,stored:this.matchTextSeq("STORED")&&this.parseStored(),byName:this.matchTextSeq(["BY","NAME"]),exists:this.parseExists(),where:this.matchPair("replace","where")&&this.parseDisjunction(),partition:this.match("partitionBy")&&this.parsePartitionedBy(),settings:this.matchTextSeq("SETTINGS")&&this.parseSettingsProperty(),default:this.matchTextSeq(["DEFAULT","VALUES"]),expression:this.parseDerivedTableValues()||this.parseDdlSelect(),conflict:this.parseOnConflict(),returning:u||this.parseReturning(),overwrite:s,alternative:o,ignore:r,source:this.match("table")&&this.parseTable()})}parseInsertTable(){let e=this.parseTable({schema:!0,parsePartition:!0});return e instanceof W&&this.match("alias",{advance:!1})&&e.setArgKey("alias",this.parseTableAlias()),e}parseKill(){let e=this.matchTexts(["CONNECTION","QUERY"])?Q(this.prev?.text??""):void 0;return this.expression(Ey,{this:this.parsePrimary(),kind:e})}parseOnConflict(){let e=this.matchTextSeq(["ON","CONFLICT"])||void 0,t=this.matchTextSeq(["ON","DUPLICATE","KEY"])||void 0;if(!e&&!t)return;let s,r;e&&(this.matchTextSeq(["ON","CONSTRAINT"])?r=this.parseIdVar():this.match("lParen")&&(s=this.parseCsv(()=>this.parseIdVar()),this.matchRParen()));let i=this.parseWhere(),o=this.parseVarFromOptions(this._constructor.CONFLICT_ACTIONS),c;return this.prev?.tokenType==="update"&&(this.match("set"),c=this.parseCsv(()=>this.parseEquality())),this.expression(qy,{duplicate:t,expressions:c,action:o,conflictKeys:s,indexPredicate:i,constraint:r,where:this.parseWhere()})}parseReturning(){if(this.match("returning"))return this.expression(BA,{expressions:this.parseCsv(()=>this.parseExpression()),into:this.match("into")&&this.parseTablePart()})}parseRow(){if(this.match("format"))return this.parseRowFormat()}parseSerdeProperties(e={}){let t=this.index,s=e?.with||this.matchTextSeq("WITH");if(!this.match("serdeProperties")){this.retreat(t);return}return this.expression(Ku,{expressions:this.parseWrappedProperties(),with:s})}parseRowFormat(e={}){if(e?.matchRow&&!this.matchPair("row","format"))return;if(this.matchTextSeq("SERDE")){let s=this.parseString(),r=this.parseSerdeProperties();return this.expression(Zu,{this:s,serdeProperties:r})}this.matchTextSeq("DELIMITED");let t={};return this.matchTextSeq(["FIELDS","TERMINATED","BY"])&&(t.fields=this.parseString(),this.matchTextSeq(["ESCAPED","BY"])&&(t.escaped=this.parseString())),this.matchTextSeq(["COLLECTION","ITEMS","TERMINATED","BY"])&&(t.collectionItems=this.parseString()),this.matchTextSeq(["MAP","KEYS","TERMINATED","BY"])&&(t.mapKeys=this.parseString()),this.matchTextSeq(["LINES","TERMINATED","BY"])&&(t.lines=this.parseString()),this.matchTextSeq(["NULL","DEFINED","AS"])&&(t.null=this.parseString()),this.expression(Qu,t)}parseSelect(e={}){let{nested:t=!1,table:s=!1,parseSubqueryAlias:r=!0,parseSetOperation:i=!0,consumePipe:o=!0,from:c}=e,p=this.parseSelectQuery({nested:t,table:s,parseSubqueryAlias:r,parseSetOperation:i});return o&&this.match("pipeGt",{advance:!1})&&(!p&&c&&(p=Ye("*").from(c)),p instanceof ee&&(p=this.parsePipeSyntaxQuery(p),p=p&&s?p.subquery(void 0,{copy:!1}):p)),p}parseSelectQuery(e={}){let{nested:t=!1,table:s=!1,parseSubqueryAlias:r=!0,parseSetOperation:i=!0}=e,o=this.parseWith(),c;if(o){if(c=this.parseStatement(),!c)return this.raiseError("Failed to parse any statement following CTE"),o;for(;c instanceof he&&c.isWrapper;)c=c.args.this;return c?._constructor.availableArgs.has("with")?c.setArgKey("with",o):(this.raiseError(`${c?._constructor.key||"Unknown expression"} does not support CTE`),c=o),c}let p;if(this.match("from",{advance:!1})&&(p=this.parseFrom({joins:!0,consumePipe:!0})),this.match("select")){let u=this.prevComments,h=this.parseHint(),g,x;this.next&&this.next.tokenType!=="dot"&&(g=this.match("all")||void 0,x=this.matchSet(this._constructor.DISTINCT_TOKENS)?new et:void 0);let f=this.match("alias")&&this.matchTexts(["STRUCT","VALUE"])&&this.prev?.text.toUpperCase()||void 0;x&&(x=this.expression(et,{on:this.match("on")?this.parseValue({values:!1}):void 0})),g&&x&&this.raiseError("Cannot specify both ALL and DISTINCT after SELECT");let T=[];for(;this.curr&&this.matchTexts(Array.from(this._constructor.OPERATION_MODIFIERS));)T.push(Q((this.prev?.text??"").toUpperCase()));let y=this.parseLimit(void 0,{top:!0}),[b,m]=this.parseProjections();c=this.expression(se,{kind:f,hint:h,distinct:x,expressions:b,limit:y,exclude:m,operationModifiers:0<T.length?T:void 0}),c.comments=u;let C=this.parseInto();C&&c.setArgKey("into",C),p||(p=this.parseFrom()),p&&c.setArgKey("from",p),c=this.parseQueryModifiers(c)}else if((s||t)&&this.match("lParen")){let u=this.prevComments;return c=this.parseWrappedSelect({table:s}),c&&c.addComments(u,{prepend:!0}),this.matchRParen(),this.parseSubquery(c,{parseAlias:r})}else if(this.match("values",{advance:!1}))c=this.parseDerivedTableValues();else if(p)c=Ye("*").from(p.args.this,{copy:!1}),c=this.parseQueryModifiers(c);else if(this.match("summarize")){let u=this.match("table")||void 0;return c=this.parseSelect()||this.parseString()||this.parseTable(),this.expression(gy,{this:c,table:u})}else{if(this.match("describe"))return this.parseDescribe();c=void 0}return i?this.parseSetOperations(c):c}parseRecursiveWithSearch(){this.matchTextSeq("SEARCH");let e=(this.matchTexts(Array.from(this._constructor.RECURSIVE_CTE_SEARCH_KIND))||void 0)&&this.prev?.text.toUpperCase();if(e)return this.matchTextSeq(["FIRST","BY"]),this.expression(Ty,{kind:e,this:this.parseIdVar(),expression:this.matchTextSeq("SET")&&this.parseIdVar(),using:this.matchTextSeq("USING")&&this.parseIdVar()})}parseWith(e={}){let{skipWithToken:t=!1}=e;if(!t&&!this.match("with"))return;let s=this.prevComments,r=this.match("recursive")||void 0,i,o=[];for(;;){let c=this.parseCte();if(c instanceof Bt&&(o.push(c),i&&c.addComments(i)),!this.match("comma")&&!this.match("with"))break;this.match("with"),i=this.prevComments}return this.expression(dt,{comments:s,expressions:o,recursive:r,search:this.parseRecursiveWithSearch()})}parseCte(){let e=this.index,t=this.parseTableAlias({aliasTokens:this._constructor.ID_VAR_TOKENS});(!t||!t.args.this)&&this.raiseError("Expected CTE to have alias");let s=this.matchTextSeq(["USING","KEY"])?this.parseWrappedIdVars():void 0;if(!this.match("alias")&&!this._constructor.OPTIONAL_ALIAS_TOKEN_CTE){this.retreat(e);return}let r=this.prevComments,i;this.matchTextSeq(["NOT","MATERIALIZED"])?i=!1:this.matchTextSeq("MATERIALIZED")&&(i=!0);let o=this.expression(Bt,{this:this.parseWrapped(()=>this.parseStatement()),alias:t,materialized:i,keyExpressions:s,comments:r}),c=o.args.this;return c instanceof tr&&(c.alias?o.setArgKey("this",Ye("*").from(c)):o.setArgKey("this",Ye("*").from(Be(c,"_values",{table:!0})))),o}parseTableAlias(e={}){let{aliasTokens:t}=e;if(this.canParseLimitOrOffset())return;let s=this.match("alias"),r=this.parseIdVar({anyToken:s,tokens:t||this._constructor.TABLE_ALIAS_TOKENS})||this.parseStringAsIdentifier(),i=this.index,o;if(this.match("lParen")?(o=this.parseCsv(()=>this.parseFunctionParameter()),!o||o.length===0?this.retreat(i):this.matchRParen()):o=void 0,!r&&(!o||o.length===0))return;let c=this.expression(pe,{this:r,columns:o});return r instanceof F&&c.addComments(r.popComments()),c}parseSubquery(e,t={}){let{parseAlias:s=!0}=t;if(e)return this.expression(he,{this:e,pivots:this.parsePivots(),alias:s?this.parseTableAlias():void 0,sample:this.parseTableSample()})}implicitUnnestsToExplicit(e){let t=new Set,s=e.args;if("from"in s){let i=s.from?.args.this;if(i){let o=ty(i.copy(),{dialect:this.dialect});t.add(o.aliasOrName||"")}}if("joins"in s){let r=s.joins?Et(s.joins,fe):void 0;if(r)for(let i of r){let o=i.args.this;if(o instanceof W&&!i.args.on){let c=o.copy();c.meta.maybeColumn=!0;let p=ty(c,{dialect:this.dialect}),u=p.parts;if(u&&0<u.length&&t.has(u[0].name||"")){let h=o.toColumn();if(h){let g=new Ee({expressions:[h]});if(o.args.alias instanceof pe&&h.args.this instanceof d){h.replace(h.args.this);let x=o.args.alias?.args.this,f={table:x?typeof x=="string"?[x]:(re(x,F),[x]):void 0,copy:!1};Be(g,void 0,f)}o.replace(g)}}t.add(p.aliasOrName||"")}}}return e}parseQueryModifiers(e){if(e&&this._constructor.MODIFIABLES.some(t=>e instanceof t)){for(let s of this.parseJoins())e.append("joins",s);let t=this.parseLateral();for(;t;)e.append("laterals",t),t=this.parseLateral();for(;;){if(this.matchSet(new Set(Object.keys(this._constructor.QUERY_MODIFIER_PARSERS)),{advance:!1})){let s=this.curr,r=this._constructor.QUERY_MODIFIER_PARSERS[s.tokenType],[i,o]=r?.call(this)||[];if(i!==void 0&&o!==void 0){if(e.getArgKey(i)&&this.raiseError(`Found multiple '${s.text.toUpperCase()}' clauses`,s),e.setArgKey(i,o),i==="limit"){let c=o,p=c.args.offset;if(c.setArgKey("offset",void 0),p){let u=new Cn({expression:p});e.setArgKey("offset",u);let h=o.args.expressions;c.setArgKey("expressions",void 0),u.setArgKey("expressions",h)}}continue}}break}}return this._constructor.SUPPORTS_IMPLICIT_UNNEST&&e&&e.args.from&&(e=this.implicitUnnestsToExplicit(e)),e}parseHintFallbackToString(){let e=this.curr;for(;this.curr;)this.advance();let t=this.tokens[this.index-1];return new Ps({expressions:[this.findSql(e,t)]})}parseHintFunctionCall(){return this.parseFunctionCall()}parseHintBody(){let e=this.index,t=!1,s=[];try{let r=this.parseCsv(()=>this.parseHintFunctionCall()||this.parseVar({upper:!0}));for(;0<r.length;)s.push(...r),r=this.parseCsv(()=>this.parseHintFunctionCall()||this.parseVar({upper:!0}))}catch{t=!0}return t||this.curr?(this.retreat(e),this.parseHintFallbackToString()):this.expression(Ps,{expressions:s})}parseHint(){if(this.match("hint")&&this.prevComments&&0<this.prevComments.length)return j(this.prevComments[0],{into:"hint",dialect:this.dialect})}parseInto(){if(!this.match("into"))return;let e=this.match("temporary")||void 0,t=this.matchTextSeq("UNLOGGED")||void 0;return this.match("table"),this.expression(iu,{this:this.parseTable({schema:!0}),temporary:e,unlogged:t})}parseFrom(e={}){let{joins:t=!1,skipFromToken:s=!1,consumePipe:r=!1}=e;if(!(!s&&!this.match("from")))return this.expression(rt,{comments:this.prevComments,this:this.parseTable({joins:t,consumePipe:r})})}parseMatchRecognizeMeasure(){return this.expression(Wy,{windowFrame:this.matchTexts(["FINAL","RUNNING"])&&(this.prev?.text??"").toUpperCase(),this:this.parseExpression()})}parseMatchRecognize(){if(!this.match("matchRecognize"))return;this.matchLParen();let e=this.parsePartitionBy(),t=this.parseOrder(),s=this.matchTextSeq("MEASURES")?this.parseCsv(()=>this.parseMatchRecognizeMeasure()):void 0,r;if(this.matchTextSeq(["ONE","ROW","PER","MATCH"]))r=Q("ONE ROW PER MATCH");else if(this.matchTextSeq(["ALL","ROWS","PER","MATCH"])){let p="ALL ROWS PER MATCH";this.matchTextSeq(["SHOW","EMPTY","MATCHES"])?p+=" SHOW EMPTY MATCHES":this.matchTextSeq(["OMIT","EMPTY","MATCHES"])?p+=" OMIT EMPTY MATCHES":this.matchTextSeq(["WITH","UNMATCHED","ROWS"])&&(p+=" WITH UNMATCHED ROWS"),r=Q(p)}let i;if(this.matchTextSeq(["AFTER","MATCH","SKIP"])){let p="AFTER MATCH SKIP";this.matchTextSeq(["PAST","LAST","ROW"])?p+=" PAST LAST ROW":this.matchTextSeq(["TO","NEXT","ROW"])?p+=" TO NEXT ROW":this.matchTextSeq(["TO","FIRST"])?(this.advance(),p+=` TO FIRST ${this.prev?.text}`):this.matchTextSeq(["TO","LAST"])&&(this.advance(),p+=` TO LAST ${this.prev?.text}`),i=Q(p)}let o;if(this.matchTextSeq("PATTERN")){this.matchLParen(),this.curr||this.raiseError("Expecting )",this.curr);let p=1,u=this.curr,h=this.prev;for(;this.curr&&0<p;)this.curr.tokenType==="lParen"&&p++,this.curr.tokenType==="rParen"&&p--,h=this.prev,this.advance();0<p&&this.raiseError("Expecting )",this.curr),o=Q(this.findSql(u,h))}let c=this.matchTextSeq("DEFINE")?this.parseCsv(()=>this.parseNameAsExpression()):void 0;return this.matchRParen(),this.expression(jy,{partitionBy:e,order:t,measures:s,rows:r,after:i,pattern:o,define:c,alias:this.parseTableAlias()})}parseLateral(){let e=this.matchPair("cross","apply")||void 0;!e&&this.matchPair("outer","apply")&&(e=!1);let t,s,r;if(e!==void 0)t=this.parseSelect({table:!0}),s=void 0,r=void 0;else if(this.match("lateral"))t=this.parseSelect({table:!0}),s=this.match("view")||void 0,r=this.match("outer")||void 0;else return;if(!t)for(t=this.parseUnnest()||this.parseFunction()||this.parseIdVar({anyToken:!1});this.match("dot");){let c=this.parseFunction()||this.parseIdVar({anyToken:!1});t=new ge({this:t,expression:c})}let i,o;if(s){let c=this.parseIdVar({anyToken:!1}),p=this.match("alias")?this.parseCsv(()=>this.parseIdVar()):[];o=this.expression(pe,{this:c,columns:p})}else(t instanceof he||t instanceof Ee)&&t.alias?o=t.args.alias?.pop():(i=this.matchPair("with","ordinality")||void 0,o=this.parseTableAlias());return this.expression(bt,{this:t,view:s,outer:r,alias:o,crossApply:e,ordinality:i})}parseStream(){let e=this.index;if(this.match("stream")){let t=this.tryParse(this.parseTable.bind(this));if(t)return this.expression(Eu,{this:t});this.retreat(e)}}parseJoinParts(){return{method:this.matchSet(this._constructor.JOIN_METHODS)?this.prev:void 0,side:this.matchSet(this._constructor.JOIN_SIDES)?this.prev:void 0,kind:this.matchSet(this._constructor.JOIN_KINDS)?this.prev:void 0}}parseUsingIdentifiers(){let e=n(()=>{let t=this.parseColumn();return t instanceof $?t.args.this instanceof d?t.args.this:Z(t.args.this):t},"parseColumnAsIdentifier");return this.parseWrappedCsv(e,{optional:!0})}parseJoin(e={}){let{skipJoinToken:t=!1,parseBracket:s=!1}=e;if(this.match("comma")){let b=this.tryParse(this.parseTable.bind(this)),m=b?this.expression(fe,{this:b}):void 0;return m&&this._constructor.JOINS_HAVE_EQUAL_PRECEDENCE&&m.setArgKey("kind","cross"),m}let r=this.index,{method:i,side:o,kind:c}=this.parseJoinParts(),p=this.matchTextSeq("DIRECTED")||void 0,u=(this.matchTexts(this._constructor.JOIN_HINTS)||void 0)&&this.prev?.text,h=this.match("join")||c?.tokenType==="straightJoin",g=this.prevComments;!t&&!h&&(this.retreat(r),c=void 0,i=void 0,o=void 0);let x=this.matchPair("outer","apply",{advance:!1})||void 0,f=this.matchPair("cross","apply",{advance:!1})||void 0;if(!t&&!h&&!x&&!f)return;let T={this:x||f?this.parseLateral():this.parseTable({parseBracket:s})};if(c?.tokenType==="array"&&this.match("comma")&&(T.expressions=this.parseCsv(()=>this.parseTable({parseBracket:s}))),i&&(T.method=i.text.toUpperCase()),o&&(T.side=st(Vt,o.text)),c&&(T.kind=c.tokenType==="straightJoin"?"straightJoin":st(Vt,c.text)),u&&(T.hint=u),this.match("matchCondition")&&(T.matchCondition=this.parseWrapped(()=>this.parseComparison())),this.match("on"))T.on=this.parseDisjunction();else if(this.match("using"))T.using=this.parseUsingIdentifiers();else if(!i&&!(x||f)&&!(T.this instanceof Ee)&&!(c?.tokenType==="cross"||c?.tokenType==="array")){let b=this.index,m=[...this.parseJoins()];0<m.length&&this.match("on")?T.on=this.parseDisjunction():0<m.length&&this.match("using")?T.using=this.parseUsingIdentifiers():this.retreat(b),0<m.length&&(T.on||T.using)&&T.this?.setArgKey("joins",m)}T.pivots=this.parsePivots();let y=[...g||[],...[i,o,c].flatMap(b=>b?.comments||[])];return this._constructor.ADD_JOIN_ON_TRUE&&!T.on&&!T.using&&!T.method&&(!T.kind||T.kind==="inner"||T.kind==="outer")&&(T.on=new at({this:!0})),p&&(T.directed=p),this.expression(fe,{comments:y,...T})}parseOpClass(){let e=this.parseDisjunction();return this.matchTexts(Array.from(this._constructor.OPCLASS_FOLLOW_KEYWORDS),{advance:!1})||this.matchSet(this._constructor.OPTYPE_FOLLOW_TOKENS,{advance:!1})?e:this.expression(wy,{this:e,expression:this.parseTableParts()})}parseIndexParams(){let e=this.match("using")?this.parseVar({anyToken:!0}):void 0,t=this.match("lParen",{advance:!1})?this.parseWrappedCsv(()=>this.parseWithOperator()):void 0;!e&&this.match("using")&&(e=this.parseVar({anyToken:!0}));let s=this.matchTextSeq("REVERSE")||void 0,r=this.matchTextSeq("INCLUDE")?this.parseWrappedIdVars():void 0,i=this.parsePartitionBy(),o=(this.match("with")||void 0)&&this.parseWrappedProperties(),c=this.matchTextSeq(["USING","INDEX","TABLESPACE"])?this.parseVar({anyToken:!0}):void 0,p=this.parseWhere(),u=this.match("on")?this.parseField():void 0;return this.expression(ky,{using:e,columns:t,include:r,partitionBy:i,where:p,withStorage:o,tablespace:c,on:u,reverse:s})}parseIndex(e={}){let{anonymous:t=!1,index:s}=e,r=s,i,o,c,p;if(r||t)i=void 0,o=void 0,c=void 0,this.match("on"),this.match("table"),p=this.parseTableParts({schema:!0});else{if(i=this.match("unique")||void 0,o=this.matchTextSeq("PRIMARY")||void 0,c=this.matchTextSeq("AMP")||void 0,!this.match("index"))return;r=this.parseIdVar(),p=void 0}let u=this.parseIndexParams();return this.expression(My,{this:r,table:p,unique:i,primary:o,amp:c,params:u})}parseTableHints(){let e=[];if(this.matchPair("with","lParen"))e.push(this.expression(cu,{expressions:this.parseCsv(()=>this.parseFunction()||this.parseVar({anyToken:!0}))})),this.matchRParen();else for(;this.matchSet(this._constructor.TABLE_INDEX_HINT_TOKENS);){let t=new eC({this:(this.prev?.text??"").toUpperCase()});this.matchSet(new Set(["index","key"])),this.match("for")&&(this.advanceAny(),t.setArgKey("target",(this.prev?.text??"").toUpperCase())),t.setArgKey("expressions",this.parseWrappedIdVars()),e.push(t)}return 0<e.length?e:void 0}parseTablePart(e={}){let{schema:t=!1}=e;return!t&&this.parseFunction({optionalParens:!1})||this.parseIdVar({anyToken:!1})||this.parseStringAsIdentifier()||this.parsePlaceholder()}parseTablePartsFast(){let e=this.index,t,s;for(;this.matchSet(this._constructor.FAST_COLUMN_TOKENS);){let o=this.prev,c=this.prevComments,p=this.match("dot"),u=this.curr?.tokenType;if(p){if(u===void 0||!this._constructor.FAST_COLUMN_TOKENS.has(u)){this.retreat(e);return}}else if(u!==void 0&&this._constructor.TABLE_POSTFIX_TOKENS.has(u)){this.retreat(e);return}if(t||(t=[]),c?.length&&(s||(s=[]),s.push(...c),this.prevComments=void 0),t.push(this.expression(F,{this:o.text,quoted:o.tokenType==="identifier",token:o})),!p)break}if(!t)return;let r=t.length,i;if(r===1)i=new W({this:t[0]});else if(r===2)i=new W({this:t[1],db:t[0]});else{let o=t[2];for(let c=3;c<r;c++)o=new ge({this:o,expression:t[c]});i=new W({this:o,db:t[1],catalog:t[0]})}return s&&i.addComments(s),i}parseTableParts(e={}){let{schema:t=!1,isDbReference:s=!1,wildcard:r=!1,fast:i=!1}=e;if(i)return this.parseTablePartsFast();let o,c,p=this.parseTablePart({schema:t});for(;this.match("dot");)o?p=this.expression(ge,{this:p,expression:this.parseTablePart({schema:t})}):(o=c,c=p,p=this.parseTablePart({schema:t})||"");r&&this.isConnected()&&(p instanceof F||!p)&&this.match("star")&&(p instanceof F?p.args.this+="*":p=new F({this:"*"}));let u=p instanceof d?p.popComments():void 0;s&&(o=c,c=p,p=void 0),!p&&!s&&this.raiseError(`Expected table name but got ${this.curr}`,this.curr),!c&&s&&this.raiseError(`Expected database name but got ${this.curr}`,this.curr);let h=this.expression(W,{comments:u,this:p,db:c,catalog:o}),g=this.parseChanges();g&&h.setArgKey("changes",g);let x=this.parseHistoricalData();x&&h.setArgKey("when",x);let f=this.parsePivots();return f&&h.setArgKey("pivots",f),h}parseTable(e={}){let{schema:t=!1,joins:s=!1,aliasTokens:r,parseBracket:i=!1,isDbReference:o=!1,parsePartition:c=!1,consumePipe:p=!1}=e;if(!t&&!o&&!p&&!s){let U=this.index,_=this.parseTableParts({fast:!0});if(_){let ne=this.curr?.tokenType,K=this.next?.tokenType,H=this._constructor.TABLE_FAST_TERMINATORS;if(ne!==void 0&&H.has(ne)&&K!=="matchCondition")return _;let Ie=this._constructor.TABLE_POSTFIX_TOKENS;if((ne===void 0||!Ie.has(ne))&&(K===void 0||!Ie.has(K))){let Se=this.parseTableAlias({aliasTokens:r||this._constructor.TABLE_ALIAS_TOKENS});if(Se&&_.setArgKey("alias",Se),this.curr?.tokenType!==void 0&&H.has(this.curr.tokenType))return _}this.retreat(U)}}let u=this.parseStream();if(u)return u;let h=this.parseLateral();if(h)return h;let g=this.parseUnnest();if(g)return g;let x=this.parseDerivedTableValues();if(x)return x;let f=this.parseSelect({table:!0,consumePipe:p});if(f)return f.args.pivots||f.setArgKey("pivots",this.parsePivots()),f;let T=i&&this.parseBracket(void 0);T=T?this.expression(W,{this:T}):void 0;let y=(this.matchTextSeq(["ROWS","FROM"])||void 0)&&this.parseWrappedCsv(()=>this.parseTable());y=y?this.expression(W,{rowsFrom:y}):void 0;let b=this.match("only")||void 0,m=T||y||this.parseBracket(this.parseTableParts({schema:t,isDbReference:o}));if(b&&m?.setArgKey("only",b),this.match("star"),(c||this._constructor.SUPPORTS_PARTITION_SELECTION)&&this.match("partition",{advance:!1})&&m?.setArgKey("partition",this.parsePartition()),t)return this.parseSchema({this:m});this._dialectConstructor.ALIAS_POST_VERSION&&m?.setArgKey("version",this.parseVersion()),this._dialectConstructor.ALIAS_POST_TABLESAMPLE&&m?.setArgKey("sample",this.parseTableSample());let q=this.parseTableAlias({aliasTokens:r||this._constructor.TABLE_ALIAS_TOKENS});if(q&&m?.setArgKey("alias",q),this.match("indexedBy")?m?.setArgKey("indexed",this.parseTableParts()):this.matchTextSeq(["NOT","INDEXED"])&&m?.setArgKey("indexed",!1),m instanceof W&&this.matchTextSeq("AT"))return this.expression(xC,{this:m.toColumn?.({copy:!1}),expression:this.parseIdVar()});if(m?.setArgKey("hints",this.parseTableHints()),m?.args.pivots||m?.setArgKey("pivots",this.parsePivots()),this._dialectConstructor.ALIAS_POST_TABLESAMPLE||m?.setArgKey("sample",this.parseTableSample()),this._dialectConstructor.ALIAS_POST_VERSION||m?.setArgKey("version",this.parseVersion()),s)for(let U of this.parseJoins())m?.append("joins",U);return this.matchPair("with","ordinality")&&(m?.setArgKey("ordinality",!0),m?.setArgKey("alias",this.parseTableAlias())),m}parseVersion(){let e;if(this.match("timestampSnapshot"))e="TIMESTAMP";else if(this.match("versionSnapshot"))e="VERSION";else return;let t,s;if(this.matchSet(new Set(["from","between"]))){t=(this.prev?.text??"").toUpperCase();let r=this.parseBitwise();this.matchTexts(["TO","AND"]);let i=this.parseBitwise();s=this.expression(Ze,{expressions:[r,i]})}else this.matchTextSeq(["CONTAINED","IN"])?(t="CONTAINED IN",s=this.expression(Ze,{expressions:this.parseWrappedCsv(()=>this.parseBitwise())})):this.match("all")?(t="ALL",s=void 0):(this.matchTextSeq(["AS","OF"]),t="AS OF",s=this.parseType());return this.expression(sC,{this:e,expression:s,kind:t})}parseHistoricalData(){let e=this.index,t;if(this.matchTexts(Array.from(this._constructor.HISTORICAL_DATA_PREFIX))){let s=(this.prev?.text??"").toUpperCase(),r=this.match("lParen")&&this.matchTexts(Array.from(this._constructor.HISTORICAL_DATA_KIND))&&(this.prev?.text??"").toUpperCase(),i=(this.match("farrow")||void 0)&&this.parseBitwise();i?(this.matchRParen(),t=this.expression(tC,{this:s,kind:r,expression:i})):this.retreat(e)}return t}parseChanges(){if(!this.matchTextSeq(["CHANGES","(","INFORMATION","=>"]))return;let e=this.parseVar({anyToken:!0});return this.matchRParen(),this.expression(Iy,{information:e,atBefore:this.parseHistoricalData(),end:this.parseHistoricalData()})}parseUnnest(e={}){let{withAlias:t=!0}=e;if(!this.matchPair("unnest","lParen",{advance:!1}))return;this.advance();let s=this.parseWrappedCsv(()=>this.parseEquality()),r=this.matchPair("with","ordinality")||void 0,i=t?this.parseTableAlias():void 0;if(i){this._dialectConstructor.UNNEST_COLUMN_ONLY&&(i.args.columns&&this.raiseError("Unexpected extra column alias in unnest."),i.setArgKey("columns",[i.args.this]),i.setArgKey("this",void 0));let o=i.args.columns;r&&o&&s.length<o.length&&(r=o.pop())}return!r&&this.matchPair("with","offset")&&(this.match("alias"),r=this.parseIdVar({anyToken:!1,tokens:this._constructor.UNNEST_OFFSET_ALIAS_TOKENS})||Z("offset")),this.expression(Ee,{expressions:s,alias:i,offset:r})}parseDerivedTableValues(){let e=this.matchPair("lParen","values")||void 0;if(!e&&!(this.matchTextSeq("VALUES")||this.matchTextSeq(["FORMAT","VALUES"])))return;let t=this.parseCsv(()=>this.parseValue()),s=this.parseTableAlias();return e&&this.matchRParen(),this.expression(tr,{expressions:t,alias:s||this.parseTableAlias()})}parseTableSample(e={}){let{asModifier:t=!1}=e;if(!this.match("tableSample")&&!(t&&this.matchTextSeq(["USING","SAMPLE"])))return;let s,r,i,o,c,p,u=this.parseVar({tokens:new Set(["row"]),upper:!0}),h=this.match("lParen")||void 0,g,x;return this._constructor.TABLESAMPLE_CSV?(x=void 0,g=this.parseCsv(()=>this.parsePrimary())):(g=void 0,x=this.match("number",{advance:!1})?this.parseFactor():this.parsePrimary()||this.parsePlaceholder()),this.matchTextSeq("BUCKET")?(s=this.parseNumber(),this.matchTextSeq(["OUT","OF"]),r=this.parseNumber(),this.match("on"),i=this.parseField()):this.matchSet(new Set(["percent","mod"]))?o=x:this.match("rows")||!this._dialectConstructor.TABLESAMPLE_SIZE_IS_PERCENT?c=x:o=x,h&&this.matchRParen(),this.match("lParen")?(u=this.parseVar({upper:!0}),p=(this.match("comma")||void 0)&&this.parseNumber(),this.matchRParen()):this.matchTexts(["SEED","REPEATABLE"])&&(p=this.parseWrapped(()=>this.parseNumber())),!u&&this._constructor.DEFAULT_SAMPLING_METHOD&&(u=Q(this._constructor.DEFAULT_SAMPLING_METHOD)),this.expression(rC,{expressions:g,method:u,bucketNumerator:s,bucketDenominator:r,bucketField:i,percent:o,size:c,seed:p})}parsePivots(){let e=[],t=this.parsePivot();for(;t;)e.push(t),t=this.parsePivot();return 0<e.length?e:void 0}parseJoins(){let e=[],t=this.parseJoin();for(;t;)e.push(t),t=this.parseJoin();return e}parseUnpivotColumns(){if(this.match("into"))return this.expression(iC,{this:this.matchTextSeq("NAME")&&this.parseColumn(),expressions:this.matchTextSeq("VALUE")&&this.parseCsv(()=>this.parseColumn())})}parseSimplifiedPivot(e={}){let{isUnpivot:t}=e,s=n(()=>{let u=this.parseBitwise();return this.match("in")?this.parseIn(u):this.match("alias",{advance:!1})?this.parseAlias(u):u},"parseOn"),r=this.parseTable(),i=(this.match("on")||void 0)&&this.parseCsv(s),o=this.parseUnpivotColumns(),c=(this.match("using")||void 0)&&this.parseCsv(()=>this.parseAlias(this.parseColumn())),p=this.parseGroup();return this.expression(Ln,{this:r,expressions:i,using:c,group:p,unpivot:t,into:o})}parsePivotIn(){let e=n(()=>{let i=this.parseSelectOrExpression();this.match("alias");let o=this.parseBitwise();if(o){let c=o;return o instanceof $&&!o.args.db&&(re(o.args.this,d),c=o.args.this),this.expression(WC,{this:i,alias:c})}return i},"parseAliasedExpression"),t=this.parseColumn();this.match("in")||this.raiseError("Expecting IN",this.curr);let s;if(this.match("lParen"))return this.match("any")?s=[...J(new wn({this:this.parseOrder()}))]:s=this.parseCsv(e),this.matchRParen(),this.expression(lt,{this:t,expressions:s});let r=this.parseIdVar();return this.expression(lt,{this:t,field:r})}parsePivotAggregation(){let e=this.parseFunction();if(!e){if(this.prev&&this.prev.tokenType==="comma")return;this.raiseError("Expecting an aggregation function in PIVOT",this.curr)}return this.parseAlias(e)}parsePivot(){let e=this.index,t,s;if(this.match("pivot"))s=!1;else if(this.match("unpivot"))s=!0,this.matchTextSeq(["INCLUDE","NULLS"])?t=!0:this.matchTextSeq(["EXCLUDE","NULLS"])&&(t=!1);else return;if(!this.match("lParen")){this.retreat(e);return}let r;s?r=this.parseCsv(()=>this.parseColumn()):r=this.parseCsv(()=>this.parsePivotAggregation()),r.length===0&&this.raiseError("Failed to parse PIVOT's aggregation list",this.curr),this.match("for")||this.raiseError("Expecting FOR",this.curr);let i=[];for(;;){let u=this.tryParse(()=>this.parsePivotIn());if(!u)break;i.push(u)}let o=(this.matchTextSeq(["DEFAULT","ON","NULL"])||void 0)&&this.parseWrapped(()=>this.parseBitwise()),c=this.parseGroup();this.matchRParen();let p=this.expression(Ln,{expressions:r,fields:i,unpivot:s,includeNulls:t,defaultOnNull:o,group:c});if(this.matchSet(new Set(["pivot","unpivot"]),{advance:!1})||p.setArgKey("alias",this.parseTableAlias()),!s){let u=this.pivotColumnNames(r),h=[],g=[];for(let x of p.args.fields){let f=x.args.expressions;f?.[0]instanceof wn||f&&g.push(f.map(T=>this._constructor.IDENTIFY_PIVOT_STRINGS?T.sql():T.aliasOrName||""))}if(0<g.length){0<u.length&&g.push(u);for(let x of this.product(g)){let f=[...x];0<u.length&&this._constructor.PREFIXED_PIVOT_COLUMNS&&f.unshift(f.pop()),h.push(Z(f.join("_")))}}p.setArgKey("columns",h)}return p}pivotColumnNames(e){return e.map(t=>t.alias).filter(t=>t)}product(e){if(e.length===0)return[[]];if(e.length===1)return e[0].map(o=>[o]);let t=[],[s,...r]=e,i=this.product(r);for(let o of s)for(let c of i)t.push([o,...c]);return t}parsePrewhere(e={}){let{skipWhereToken:t=!1}=e;if(!(!t&&!this.match("prewhere")))return this.expression(nC,{comments:this.prevComments,this:this.parseDisjunction()})}parseWhere(e={}){let{skipWhereToken:t=!1}=e;if(!(!t&&!this.match("where")))return this.expression(St,{comments:this.prevComments,this:this.parseDisjunction()})}parseGroup(e={}){let{skipGroupByToken:t=!1}=e;if(!t&&!this.match("groupBy"))return;let s=this.prevComments,r={expressions:[],rollup:[],cube:[],groupingSets:[]};if(this.match("all")?r.all=!0:this.match("distinct")&&(r.all=!1),this.matchSet(this._constructor.QUERY_MODIFIER_TOKENS,{advance:!1}))return this.expression(Yr,{comments:s,...r});for(;;){let i=this.index;r.expressions.push(...this.parseCsv(()=>this.matchSet(new Set(["cube","rollup"]),{advance:!1})?void 0:this.parseDisjunction()));let o=this.index,c=this.match("with")||void 0,p=this.parseCubeOrRollup({withPrefix:c});if(p){let u=p instanceof OA?"rollup":"cube";r[u].push(p)}else{let u=this.parseGroupingSets();u?r.groupingSets.push(u):this.matchTextSeq("TOTALS")&&(r.totals=!0)}if(o<=this.index&&this.index<=o+1){this.retreat(o);break}if(i===this.index)break}return this.expression(Yr,{comments:s,...r})}parseCubeOrRollup(e={}){let{withPrefix:t=!1}=e,s;if(this.match("cube"))s=Vy;else if(this.match("rollup"))s=OA;else return;return this.expression(s,{expressions:t?[]:this.parseWrappedCsv(()=>this.parseBitwise())})}parseGroupingSets(){if(this.match("groupingSets"))return this.expression(Hy,{expressions:this.parseWrappedCsv(()=>this.parseGroupingSet())})}parseGroupingSet(){return this.parseGroupingSets()||this.parseCubeOrRollup()||this.parseBitwise()}parseHaving(e={}){let{skipHavingToken:t=!1}=e;if(!(!t&&!this.match("having")))return this.expression(xs,{comments:this.prevComments,this:this.parseDisjunction()})}parseQualify(){if(this.match("qualify"))return this.expression(Xs,{this:this.parseDisjunction()})}parseConnectWithPrior(){this._constructor.NO_PAREN_FUNCTION_PARSERS.PRIOR=function(){return this.expression(Py,{this:this.parseBitwise()})};let e=this.parseDisjunction();return delete this._constructor.NO_PAREN_FUNCTION_PARSERS.PRIOR,e}parseConnect(e={}){let{skipStartToken:t=!1}=e,s;if(t)s=void 0;else if(this.match("startWith"))s=this.parseDisjunction();else return;this.match("connectBy");let r=this.matchTextSeq("NOCYCLE")||void 0,i=this.parseConnectWithPrior();return!s&&this.match("startWith")&&(s=this.parseDisjunction()),this.expression(yy,{start:s,connect:i,nocycle:r})}parseNameAsExpression(){let e=this.parseIdVar({anyToken:!0});return this.match("alias")&&(e=this.expression(Oe,{alias:e,this:this.parseDisjunction()})),e}parseInterpolate(){if(this.matchTextSeq("INTERPOLATE"))return this.parseWrappedCsv(()=>this.parseNameAsExpression())}parseOrder(e={}){let{thisExpr:t,skipOrderToken:s=!1}=e,r;if(!s&&!this.match("orderBy")){if(!this.match("orderSiblingsBy"))return t;r=!0}return this.expression(ye,{comments:this.prevComments,this:t,expressions:this.parseCsv(()=>this.parseOrdered()),siblings:r})}parseSort(e,t){if(this.match(t))return this.expression(e,{expressions:this.parseCsv(()=>this.parseOrdered())})}parseOrdered(e){let t=e?e():this.parseDisjunction();if(!t)return;let s=t;t.name?.toUpperCase()==="ALL"&&this._dialectConstructor.SUPPORTS_ORDER_BY_ALL&&(s=Q("ALL"));let r=this.match("asc")||void 0,i=this.match("desc")||void 0||r&&!1,o=this.matchTextSeq(["NULLS","FIRST"])||void 0,c=this.matchTextSeq(["NULLS","LAST"])||void 0,p=o||!1;!(o||c)&&(!i&&this._dialectConstructor.NULL_ORDERING==="nulls_are_small"||i&&this._dialectConstructor.NULL_ORDERING!=="nulls_are_small")&&this._dialectConstructor.NULL_ORDERING!=="nulls_are_last"&&(p=!0);let h;return this.matchTextSeq(["WITH","FILL"])&&(h=this.expression(Xy,{from:this.match("from")&&this.parseBitwise(),to:this.matchTextSeq("TO")&&this.parseBitwise(),step:this.matchTextSeq("STEP")&&this.parseBitwise(),interpolate:this.parseInterpolate()})),this.expression(hs,{this:s,desc:i,nullsFirst:p,withFill:h})}parseLimitOptions(){let e=this.matchSet(new Set(["percent","mod"]))||void 0,t=this.matchSet(new Set(["row","rows"]))||void 0;this.matchTextSeq("ONLY");let s=this.matchTextSeq(["WITH","TIES"])||void 0;if(e||t||s)return this.expression(_y,{percent:e,rows:t,withTies:s})}parseLimit(e,t={}){let{top:s=!1,skipLimitToken:r=!1}=t;if(r||this.match(s?"top":"limit")){let i=this.prevComments,o;if(s){let h=this.match("lParen")||void 0;o=h?this.parseTerm():this.parseNumber(),h&&this.matchRParen()}else{let h=this.index;o=this.tryParse(()=>this.parseTerm()),o instanceof jr?(this.retreat(h),o=this.parseFactor()):o||(o=this.parseFactor())}let c=this.parseLimitOptions(),p;return this.match("comma")&&(p=o,o=this.parseTerm()),this.expression(Dt,{this:e,expression:o,offset:p,comments:i,limitOptions:c,expressions:this.parseLimitBy()})}if(this.match("fetch")){let o=this.matchSet(new Set(["first","next"]))||void 0?(this.prev?.text??"").toUpperCase():"FIRST",c=this.parseField({tokens:this._constructor.FETCH_TOKENS});return this.expression(hr,{direction:o,count:c,limitOptions:this.parseLimitOptions()})}return e}parseOffset(e){if(!this.match("offset"))return e;let t=this.parseTerm();return this.matchSet(new Set(["row","rows"])),this.expression(Cn,{this:e,expression:t,expressions:this.parseLimitBy()})}canParseLimitOrOffset(){if(!this.matchSet(new Set(this._constructor.AMBIGUOUS_ALIAS_TOKENS),{advance:!1}))return!1;let e=this.index,t=!!(this.tryParse(()=>this.parseLimit(),{retreat:!0})||this.tryParse(()=>this.parseOffset(),{retreat:!0}));return this.retreat(e),this.next&&this.next.tokenType==="matchCondition"?!1:t}parseLimitBy(){return this.matchTextSeq("BY")?this.parseCsv(()=>this.parseBitwise()):void 0}parseLocks(){let e=[];for(;;){let t,s;if(this.matchTextSeq(["FOR","UPDATE"]))t=!0;else if(this.matchTextSeq(["FOR","SHARE"])||this.matchTextSeq(["LOCK","IN","SHARE","MODE"]))t=!1;else if(this.matchTextSeq(["FOR","KEY","SHARE"]))t=!1,s=!0;else if(this.matchTextSeq(["FOR","NO","KEY","UPDATE"]))t=!0,s=!0;else break;let r;this.matchTextSeq("OF")&&(r=this.parseCsv(()=>this.parseTable({schema:!0})));let i;this.matchTextSeq("NOWAIT")?i=!0:this.matchTextSeq("WAIT")?i=this.parsePrimary():this.matchTextSeq(["SKIP","LOCKED"])&&(i=!1),e.push(this.expression($A,{update:t,expressions:r,wait:i,key:s}))}return e}parseSetOperation(e,t={}){let{consumePipe:s=!1}=t,r=this.index,{side:i,kind:o}=this.parseJoinParts(),c=st(Vt,i?.text),p=st(dM,o?.text);if(!this.matchSet(this._constructor.SET_OPERATIONS)){this.retreat(r);return}let u=this.prev?.tokenType,h;u==="union"?h=or:u==="except"?h=cr:h=ei;let g=this.prev?.comments,x;this.match("distinct")?x=!0:this.match("all")?x=!1:(x=this._dialectConstructor.SET_OP_DISTINCT_BY_DEFAULT[h.key],x===void 0&&this.raiseError(`Expected DISTINCT or ALL for ${h.name}`,this.curr));let f=this.matchTextSeq(["BY","NAME"])||this.matchTextSeq(["STRICT","CORRESPONDING"])||void 0;this.matchTextSeq("CORRESPONDING")&&(f=!0,!c&&!p&&(p="inner"));let T;f&&this.matchTexts(["ON","BY"])&&(T=this.parseWrappedCsv(()=>this.parseColumn()));let y=this.parseSelect({nested:!0,parseSetOperation:!1,consumePipe:s});return this.expression(h,{comments:g,this:e,distinct:x,byName:f,expression:y,side:c,kind:p,on:T})}parseSetOperations(e){let t=e;for(;t;){let s=this.parseSetOperation(t);if(!s)break;t=s}if(t instanceof Ge&&this._constructor.MODIFIERS_ATTACHED_TO_SET_OP){let s=t.args.expression;if(s)for(let r of this._constructor.SET_OP_MODIFIERS){let i=s.args[r];i instanceof d&&t.setArgKey(r,i.pop())}}return t}parseExpression(){return this.parseAlias(this.parseAssignment())}parseAssignment(){let e=this.parseDisjunction();if(!e&&this.next&&this.next.tokenType in this._constructor.ASSIGNMENT){let s=this.advanceAny({ignoreReserved:!0});e=$n({col:s&&this.prev?.text})}let t=Object.keys(this._constructor.ASSIGNMENT);for(;this.matchSet(t);)e instanceof $&&e.parts.length===1&&(e=e.args.this),e=this.expression(this._constructor.ASSIGNMENT[this.prev.tokenType],{this:e,comments:this.prevComments,expression:this.parseAssignment()});return e}parseDisjunction(){let e=this.parseConjunction();for(;this.matchSet(Object.keys(this._constructor.DISJUNCTION));){let t=this.prevComments,s=this._constructor.DISJUNCTION[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseConjunction(),comments:t}))}return e}parseConjunction(){let e=this.parseEquality();for(;this.matchSet(Object.keys(this._constructor.CONJUNCTION));){let t=this.prevComments,s=this._constructor.CONJUNCTION[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseEquality(),comments:t}))}return e}parseEquality(){let e=this.parseComparison();for(;this.matchSet(Object.keys(this._constructor.EQUALITY));){let t=this.prevComments,s=this._constructor.EQUALITY[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseComparison(),comments:t}))}return e}parseComparison(){let e=this.parseRange();for(;this.matchSet(Object.keys(this._constructor.COMPARISON));){let t=this.prevComments,s=this._constructor.COMPARISON[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseRange(),comments:t}))}return e}parseRange(e){let t=e||this.parseBitwise(),s=this.match("not")||void 0;if(this.matchSet(Object.keys(this._constructor.RANGE_PARSERS))){let r=this._constructor.RANGE_PARSERS[this.prev?.tokenType??"unknown"];if(r&&t){let i=r.call(this,t);if(!i)return t;t=i}}else(this.match("isnull")||s&&this.match("null"))&&(t=this.expression(ze,{this:t,expression:le()}));return this.match("notnull")&&(t=this.expression(ze,{this:t,expression:le()}),t=this.expression(Le,{this:t})),s&&(t=this.negateRange(t)),this.match("is")&&(t=this.parseIs(t)),t}negateRange(e){return e&&this.expression(Le,{this:e})}parseIs(e){let t=this.index-1,s=this.match("not")||void 0;if(this.matchTextSeq(["DISTINCT","FROM"])){let o=s?Ks:Ur;return this.expression(o,{this:e,expression:this.parseBitwise()})}let r;if(this.match("json")){let o=(this.matchTexts(Array.from(this._constructor.IS_JSON_PREDICATE_KIND))||void 0)&&(this.prev?.text??"").toUpperCase(),c;this.matchTextSeq("WITH")?c=!0:this.matchTextSeq("WITHOUT")&&(c=!1);let p=this.match("unique")||void 0;this.matchTextSeq("KEYS"),r=this.expression(TC,{this:o,with:c,unique:p})}else if(r=this.parseNull()||this.parseBitwise(),!r){this.retreat(t);return}let i=this.expression(ze,{this:e,expression:r});return s?this.expression(Le,{this:i}):this.parseColumnOps(i)}parseIn(e,t={}){let{alias:s=!1}=t,r=this.parseUnnest({withAlias:!1}),i;if(r)i=this.expression(lt,{this:e,unnest:r});else if(this.matchSet(new Set(["lParen","lBracket"]))){let o=this.prev?.tokenType==="lParen",c=this.parseCsv(()=>this.parseSelectOrExpression({alias:s}));if(c.length===1&&c[0]instanceof ee){let p=c[0],h=this.parseQueryModifiers(p).subquery(void 0,{copy:!1});i=this.expression(lt,{this:e,query:h})}else i=this.expression(lt,{this:e,expressions:c});o?this.matchRParen(i):this.match("rBracket",{expression:i})||this.raiseError("Expecting ]",this.curr)}else i=this.expression(lt,{this:e,field:this.parseColumn()});return i}parseBetween(e){let t;this.matchTextSeq("SYMMETRIC")?t=!0:this.matchTextSeq("ASYMMETRIC")&&(t=!1);let s=this.parseBitwise();this.match("and");let r=this.parseBitwise();return this.expression(Ss,{this:e,low:s,high:r,symmetric:t})}parseEscape(e){return this.match("escape")?this.expression(Ba,{this:e,expression:this.parseString()||this.parseNull()}):e}parseIntervalSpan(e){let t;if(e&&e.isString&&this._constructor.SUPPORTS_OMITTED_INTERVAL_SPAN_UNIT&&e.name?.match?.(yD)){let i=this.index,o=this.parseVar({anyToken:!0,upper:!0}),c;o&&this.matchTextSeq("TO")&&(c=this.parseVar({anyToken:!0,upper:!0})),t=!(o&&c),this.retreat(i)}let s=t?void 0:this.parseFunction()||!this.matchSet(["alias","dcolon"],{advance:!1})&&this.parseVar({anyToken:!0,upper:!0})||void 0,r=e;if(e&&e.isNumber)r=I.string(e.toValue()||e.sql());else if(e&&e.isString){let i=Array.from(e.name?.matchAll(new RegExp(ID,"g"))||[]);0<i.length&&s&&(s=void 0,this.retreat(this.index-1)),i.length===1&&(r=I.string(i[0][1]),s=this.expression(Ve,{this:i[0][2].toUpperCase()}))}return this._constructor.INTERVAL_SPANS&&this.matchTextSeq("TO")&&(s=this.expression(Wr,{this:s,expression:this.parseFunction()||this.parseVar({anyToken:!0,upper:!0})})),this.expression(qe,{this:r,unit:s})}parseInterval(e={}){let{matchInterval:t=!0}=e,s=this.index;if(!this.match("interval")&&t)return;let r;if(this.match("string",{advance:!1})?r=this.parsePrimary():r=this.parseTerm(),!r||r instanceof $&&!r.args.table&&r.args.this instanceof F&&!r.args.this.args.quoted&&this.curr&&!this._dialectConstructor.VALID_INTERVAL_UNITS.has(this.curr.text.toUpperCase())){this.retreat(s);return}let i=this.parseIntervalSpan(r),o=this.index;return this.match("plus"),this.matchSet(new Set(["string","number"]),{advance:!1})?this.expression(we,{this:i,expression:this.parseInterval({matchInterval:!1})}):(this.retreat(o),i)}parseBitwise(){let e=this.parseTerm(),t=Object.keys(this._constructor.BITWISE);for(;;)if(this.matchSet(t)){let s=this._constructor.BITWISE[this.prev?.tokenType??"unknown"];s&&(e=this.expression(s,{this:e,expression:this.parseTerm()}))}else if(this._dialectConstructor.DPIPE_IS_STRING_CONCAT&&this.match("dpipe"))e=this.expression(jt,{this:e,expression:this.parseTerm(),safe:!this._dialectConstructor.STRICT_STRING_CONCAT});else if(this.match("dqmark"))e=this.expression(tt,{this:e,expressions:J(this.parseTerm())});else if(this.matchPair("lt","lt"))e=this.expression(jC,{this:e,expression:this.parseTerm()});else if(this.matchPair("gt","gt"))e=this.expression(ih,{this:e,expression:this.parseTerm()});else break;return e}parseTerm(){let e=this.parseFactor(),t=Object.keys(this._constructor.TERM);for(;this.matchSet(t);){let s=this._constructor.TERM[this.prev?.tokenType??"unknown"],r=this.prevComments,i=this.parseFactor();if(s&&(e=this.expression(s,{this:e,comments:r,expression:i}),e instanceof kA)){let o=e.args.expression;if(o instanceof $&&o.parts.length===1){let c=o.args.this;c instanceof F&&e.setArgKey("expression",c.args.quoted?c:Q(c.name))}}}return e}parseFactor(){let e=this._constructor.EXPONENT?()=>this.parseExponent():()=>this.parseUnary(),t=this.parseAtTimeZone(e()),s=Object.keys(this._constructor.FACTOR);for(;this.matchSet(s);){let r=this._constructor.FACTOR[this.prev?.tokenType??"unknown"],i=this.prevComments,o=e();if(!o&&r===Un&&/^[a-zA-Z]/.test(this.prev?.text??""))return this.retreat(this.index-1),t;r&&(t=this.expression(r,{this:t,comments:i,expression:o}),t instanceof Mt&&(t.setArgKey("typed",this._dialectConstructor.TYPED_DIVISION),t.setArgKey("safe",this._dialectConstructor.SAFE_DIVISION)))}return t}parseExponent(){let e=this.parseUnary();for(;this.matchSet(Object.keys(this._constructor.EXPONENT));){let t=this.prevComments,s=this._constructor.EXPONENT[this.prev.tokenType];s&&(e=this.expression(s,{this:e,expression:this.parseUnary(),comments:t}))}return e}parseUnary(){if(this.matchSet(Object.keys(this._constructor.UNARY_PARSERS))){let e=this._constructor.UNARY_PARSERS[this.prev?.tokenType??"unknown"];return e?e.call(this):void 0}return this.parseType()}parseType(e={}){let{parseInterval:t=!0,fallbackToIdentifier:s=!1}=e;if(!s){let c=this.parseAtom();if(c!==void 0)return c}let r=t&&this.parseInterval();if(r)return this.parseColumnOps(r);let i=this.index,o=this.parseTypes({checkFunc:!0,allowIdentifiers:!1});if(o instanceof z)return this.parseColumnOps(o);if(o){let c=this.index,p=this.parsePrimary();if(p instanceof I){let u=p.name,h=this.parseColumnOps(p),g=typeof o.args.this=="string"?this._constructor.TYPE_LITERAL_PARSERS[o.args.this]:void 0;return g?g.call(this,h,o):(this._constructor.ZONE_AWARE_TIMESTAMP_CONSTRUCTOR&&o.isType?.(["timestamp"])&&zW.test(u)&&o.setArgKey("this","timestamptz"),this.expression(z,{this:h,to:o}))}if(o.args.expressions&&1<c-i)return this.retreat(c),this.parseColumnOps(o);this.retreat(i)}return s?this.parseIdVar():this.parseColumn()}parseTypeSize(){let e=this.parseType();if(e)return e instanceof $&&!e.args.table&&(e=Q(e.name.toUpperCase())),this.expression(Jr,{this:e,expression:this.parseVar({anyToken:!0})})}parseUserDefinedType(e){let t=e.name;for(;this.match("dot");)this.advanceAny(),t=`${t}.${this.prev?.text??""}`;return N.build(t,{dialect:this.dialect,udt:!0})}parseTypes(e={}){let{checkFunc:t=!1,schema:s=!1,allowIdentifiers:r=!0}=e,i=this.index,o,c=this.matchTextSeq(["SYSUDTLIB","."])||void 0,p,u;if(this.matchSet(this._constructor.TYPE_TOKENS))p=this.prev?.tokenType,u=this.prev?.text;else{let C=r&&this.parseIdVar({anyToken:!1,tokens:new Set(["var"])});if(C instanceof F){let q;try{q=this.dialect.tokenize?.(C.name)}catch{q=void 0}if(q&&this._constructor.TYPE_TOKENS.has(q[0].tokenType)){if(1<q.length)return N.build(C.name,{dialect:this.dialect});p=q[0].tokenType,u=q[0].text}else if(this._dialectConstructor.SUPPORTS_USER_DEFINED_TYPES)o=this.parseUserDefinedType(C);else{this.retreat(this.index-1);return}}else return}if(p==="pseudoType")return this.expression(HC,{this:(this.prev?.text??"").toUpperCase()});if(p==="objectIdentifier")return this.expression(_C,{this:(this.prev?.text??"").toUpperCase()});if(p==="map"&&this.match("lBracket")){let C=this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r});if(!this.match("farrow")){this.retreat(i);return}let q=this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r});if(!this.match("rBracket")){this.retreat(i);return}return new N({this:"map",expressions:[C,q],nested:!0,prefix:c})}let h=p&&this._constructor.NESTED_TYPE_TOKENS.has(p),g=p&&this._constructor.STRUCT_TYPE_TOKENS.has(p),x=p&&this._constructor.AGGREGATE_TYPE_TOKENS.has(p),f,T=!1;if(this.match("lParen")){if(g)f=this.parseCsv(()=>this.parseStructTypes({typeRequired:!0}));else if(h){if(f=this.parseCsv(()=>this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r})),p==="nullable"&&f.length===1)return o=f[0],o.setArgKey("nullable",!0),this.matchRParen(),o}else if(p&&this._constructor.ENUM_TYPE_TOKENS.has(p))f=this.parseCsv(()=>this.parseEquality());else if(p==="json")f=this.parseCsv(()=>this.parseJsonTypeArg());else if(x){let C=this.parseFunction({anonymous:!0})||this.parseIdVar({anyToken:!1,tokens:new Set(["var","any"])});if(!C)return;f=[C],this.match("comma")&&f.push(...this.parseCsv(()=>this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r})))}else f=this.parseCsv(()=>this.parseTypeSize()),p==="vector"&&f.length===2&&(f=this.parseVectorExpressions(f));if(!this.match("rParen")){this.retreat(i);return}T=!0}let y;if(h&&this.match("lt")&&(g?f=this.parseCsv(()=>this.parseStructTypes({typeRequired:!0})):f=this.parseCsv(()=>this.parseTypes({checkFunc:t,schema:s,allowIdentifiers:r})),this.match("gt")||this.raiseError("Expecting >",this.curr),this.matchSet(new Set(["lBracket","lParen"]))&&(y=this.parseCsv(()=>this.parseDisjunction()),!y&&g?(y=void 0,this.retreat(this.index-1)):this.matchSet(new Set(["rBracket","rParen"])))),p&&this._constructor.TIMESTAMPS.has(p))if(this.matchTextSeq(["WITH","TIME","ZONE"])){T=!1;let C=this._constructor.TIMES.has(p)?"timetz":"timestamptz";o=new N({this:C,expressions:f})}else this.matchTextSeq(["WITH","LOCAL","TIME","ZONE"])?(T=!1,o=new N({this:"timestampltz",expressions:f})):this.matchTextSeq(["WITHOUT","TIME","ZONE"])&&(T=!1);else if(p==="interval")if(this.curr&&this._dialectConstructor.VALID_INTERVAL_UNITS.has(this.curr.text.toUpperCase())){let C=this.parseVar({upper:!0});this.matchTextSeq("TO")&&(C=new Wr({this:C,expression:this.parseVar({upper:!0})})),o=this.expression(N,{this:new qe({unit:C})})}else o=this.expression(N,{this:"interval"});else p==="void"&&(o=new N({this:"null"}));if(T&&t){let C=this.index;if(!this.parseString()){this.retreat(i);return}this.retreat(C)}if(o)f&&o.setArgKey("expressions",f);else{if(this.matchTextSeq("UNSIGNED")){let C=p&&this._constructor.SIGNED_TO_UNSIGNED_TYPE_TOKEN[p];C||this.raiseError(`Cannot convert ${p?.valueOf()} to unsigned.`,this.curr),p=C||p}if(p==="nullable"&&!f){this.retreat(i);return}if(p&&(o=new N({this:At[bM(p)],expressions:f,nested:h,prefix:c}),y!==void 0)){let C=g?Es:ue;o=X(new C({expressions:y}),o,{copy:!1})}}for(;this.match("list");)o=new N({this:"list",expressions:[o],nested:!0});let b=this.index,m=this.match("array")||!1;for(;this.curr;){let C=this.prev?.tokenType;if(!(this.match("lBracket")||void 0)&&!m||C==="array"&&this.match("rBracket"))break;m=!1;let U=this.parseCsv(()=>this.parseDisjunction());if(0<U.length&&!s&&(!this._dialectConstructor.SUPPORTS_FIXED_SIZE_ARRAYS||C==="array"||!this.match("rBracket",{advance:!1}))){this.retreat(b);break}o=new N({this:"array",expressions:[o],values:U,nested:!0}),this.match("rBracket")}if(o&&this._constructor.TYPE_CONVERTERS&&typeof o.args.this=="string"){let C=this._constructor.TYPE_CONVERTERS[o.args.this];C&&(o=C(o))}return o}parseJsonTypeArg(){if(this.matchTextSeq("SKIP")){let r=this.match("rlike"),i=this.parseColumn();return i instanceof $&&(i=i.toDot?.()??i),this.expression(Jy,{regexp:r,expression:i})}let e=this.parseColumn();if(!(e instanceof $))return;if(e.parts.length===1&&this.match("eq")){let r=e.name,i=this.parsePrimary();return this.expression(Me,{this:Q(r),expression:i})}let t=e.toDot?.()??e,s=this.parseTypes({checkFunc:!1,allowIdentifiers:!1});return this.expression(Pe,{this:t,kind:s})}parseVectorExpressions(e){let t=N.build(e[0].name,{dialect:this.dialect});return[...t?[t]:[],...e.slice(1)]}parseStructTypes(e={}){let{typeRequired:t=!1}=e,s=this.index,r;return this.curr&&this.next&&this._constructor.TYPE_TOKENS.has(this.curr.tokenType)&&this._constructor.TYPE_TOKENS.has(this.next.tokenType)?r=this.parseIdVar():r=this.parseType({parseInterval:!1,fallbackToIdentifier:!0})||this.parseIdVar(),this.match("colon"),t&&!(r instanceof N)&&!this.matchSet(this._constructor.TYPE_TOKENS,{advance:!1})?(this.retreat(s),this.parseTypes()):this.parseColumnDef(r)}parseAtTimeZone(e){return this.matchTextSeq(["AT","TIME","ZONE"])?this.parseAtTimeZone(this.expression(gs,{this:e,zone:this.parseUnary()})):e}parseAtom(){if(!this.curr)return;if(this.curr.tokenType in this._constructor.FAST_COLUMN_TOKENS){let i=this.parseColumn();if(i!==void 0)return i}let e=this.curr,t=e.tokenType,s=this._constructor.PRIMARY_PARSERS[t];if(!s)return;let r=this.next?.tokenType;if(!(r!==void 0&&(r in this._constructor.COLUMN_OPERATORS||this._constructor.COLUMN_POSTFIX_TOKENS.has(r)||t==="string"&&r==="string")))return this.advance(),s.call(this,e)}parseColumn(){let e=this.parseColumnFastPath();if(e===void 0){let t=this.parseColumnReference();t||(t=this.parseBracket(t)),e=t&&this.parseColumnOps(t)}return e&&(this._dialectConstructor.SUPPORTS_COLUMN_JOIN_MARKS&&e.setArgKey("joinMark",this.match("joinMarker")),this._constructor.COLON_IS_VARIANT_EXTRACT&&(e=this.parseColonAsVariantExtract(e))),e}parseColumnFastPath(){let e=this.index,t,s;for(;this.matchSet(this._constructor.FAST_COLUMN_TOKENS);){let o=this.prev,c=this.prevComments;if(t===void 0&&o.text.toUpperCase()in this._constructor.NO_PAREN_FUNCTION_PARSERS){this.retreat(e);return}let p=this.match("dot"),u=this.curr?.tokenType;if(p){if(u===void 0||!this._constructor.FAST_COLUMN_TOKENS.has(u)){this.retreat(e);return}}else if(u!==void 0&&(u in this._constructor.COLUMN_OPERATORS||this._constructor.COLUMN_POSTFIX_TOKENS.has(u))){this.retreat(e);return}t===void 0&&(t=[]),c&&0<c.length&&(s===void 0&&(s=[]),s.push(...c),this.prevComments=[]);let h=new F({this:o.text,quoted:o.tokenType==="identifier"});if(h.updatePositions(o),t.push(h),!p)break}if(t===void 0)return;let r=t.length,i;if(r===1)i=new $({this:t[0]});else if(r===2)i=new $({this:t[1],table:t[0]});else if(r===3)i=new $({this:t[2],table:t[1],db:t[0]});else{i=new $({this:t[3],table:t[2],db:t[1],catalog:t[0]});for(let o=4;o<r;o++)i=new ge({this:i,expression:t[o]})}return s&&i.addComments(s),i}parseColumnReference(){let e=this.parseField();return!e&&this.match("values",{advance:!1})&&this._constructor.VALUES_FOLLOWED_BY_PAREN&&(!this.next||this.next.tokenType!=="lParen")&&(e=this.parseIdVar()),e instanceof F&&(e=this.expression($,{comments:e.popComments(),this:e})),e}buildJsonExtract(e,t,s){return 1<t.length&&(e=this.expression(Ns,{this:e,expression:new Er({expressions:t,escape:s}),variantExtract:!0,requiresJson:this._constructor.JSON_EXTRACT_REQUIRES_JSON_EXPRESSION}),t=[new Qt]),[e,t]}parseColonAsVariantExtract(e){let t=[new Qt],s;for(;this.match("colon");){let r=this.parseIdVar({anyToken:!0,tokens:new Set(["select"])});for(r&&(r instanceof F&&r.args.quoted&&(s=!0),t.push(new kt({this:r.name})));;)if(this.match("dot")){let i=this.parseIdVar({anyToken:!0,tokens:new Set(["select"])});i&&(i instanceof F&&i.args.quoted&&(s=!0),t.push(new kt({this:i.name})))}else if(this.match("lBracket")){let i=this.parseBracketKeyValue();this.match("rBracket")||this.raiseError("Expected ]"),i&&(i.isString?(t.push(new kt({this:i.name})),s=!0):i.isStar?t.push(new ts({this:new qt})):i.isNumber?t.push(new ts({this:i.toValue()})):([e,t]=this.buildJsonExtract(e,t,s),s=void 0,e=this.expression(wt,{this:e,expressions:[i],jsonAccess:!0})))}else if(this.match("dcolon")){[e,t]=this.buildJsonExtract(e,t,s),s=void 0;let i=this.parseTypes();i?e=this.expression(z,{this:e,to:i}):this.raiseError("Expected type after '::'")}else break}return[e]=this.buildJsonExtract(e,t,s),e}parseDcolon(){return this.parseTypes()}parseColumnOps(e){let t=e;for(;this.curr&&this._constructor.BRACKETS.has(this.curr.tokenType);)t=this.parseBracket(t);for(;this.matchSet(Object.keys(this._constructor.COLUMN_OPERATORS));){let s=this.prev?.tokenType??"unknown",r=this._constructor.COLUMN_OPERATORS[s],i;if(this._constructor.CAST_COLUMN_OPERATORS.has(s)?(i=this.parseDcolon(),i||this.raiseError("Expected type",this.curr)):r&&this.curr?(i=this.parseColumnReference()||this.parseBitwise(),i instanceof $&&this.match("dot",{advance:!1})&&(i=this.parseColumnOps(i))):i=this.parseField({anyToken:!0,anonymousFunc:!0}),(i instanceof E||i instanceof Ue)&&t&&(t=t.transform(o=>o instanceof $&&o.toDot?.({includeDots:!1})||o)),r)t=r.call(this,t,i);else if(t instanceof $&&!t.args.catalog)t=this.expression($,{comments:t.comments,this:i,table:t.args.this,db:t.args.table,catalog:t.args.db});else if(i instanceof Ue){let o=this.expression(ge,{this:t,expression:i.args.this});i.setArgKey("this",o),t=i}else t=this.expression(ge,{this:t,expression:i});i?.comments&&t?.addComments?.(i.popComments()),t=this.parseBracket(t)}return t}parseComment(e={}){let{allowExists:t=!0}=e,s=this.prev,r=t?this.parseExists():void 0;this.match("on");let i=this.matchTextSeq("MATERIALIZED")||void 0,o=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev;if(!o)return this.parseAsCommand(s);let c;return o.tokenType==="function"||o.tokenType==="procedure"?c=this.parseUserDefinedFunction({kind:o.tokenType}):o.tokenType==="table"?c=this.parseTable({aliasTokens:this._constructor.COMMENT_TABLE_ALIAS_TOKENS}):o.tokenType==="column"?c=this.parseColumn():c=this.parseIdVar(),this.match("is"),this.expression(Oy,{this:c,kind:o.text,expression:this.parseString(),exists:r,materialized:i})}parseToTable(){let e=this.parseTableParts({schema:!0});return this.expression(aa,{this:e})}parseTtl(){let e=n(()=>{let o=this.parseBitwise();return this.matchTextSeq("DELETE")?this.expression(In,{this:o,delete:!0}):this.matchTextSeq("RECOMPRESS")?this.expression(In,{this:o,recompress:this.parseBitwise()}):this.matchTextSeq(["TO","DISK"])?this.expression(In,{this:o,toDisk:this.parseString()}):this.matchTextSeq(["TO","VOLUME"])?this.expression(In,{this:o,toVolume:this.parseString()}):o},"parseTtlAction"),t=this.parseCsv(e),s=this.parseWhere(),r=this.parseGroup(),i;return r&&this.match("set")&&(i=this.parseCsv(this.parseSetItem.bind(this))),this.expression(Pn,{expressions:t,where:s,group:r,aggregates:i})}parseCondition(){return this.parseWrapped(()=>this.parseExpression(),{optional:!0})}parseBlock(){return this.expression(GA,{expressions:this.parseBatchStatements(e=>e.parseStatement())})}parseWhileBlock(){return this.expression(PC,{this:this.parseCondition(),body:this.parseBlock()})}parseBatchStatements(e,t={}){let{sepFirstStatement:s=!0}=t,r=[];s&&(this.match("begin"),r.push(e(this)));let i=this._chunks.length;for(;this._chunkIndex<i;){if(this.advanceChunk(),this.match("else",{advance:!1}))return r;if(r.length&&!this.next&&this.match("end")){r.push(new du);continue}r.push(e(this)),this.index<this.tokens.length&&this.raiseError("Invalid expression / Unexpected token"),this.checkErrors()}return r}advanceChunk(){this.index=-1,this.tokens=this._chunks[this._chunkIndex],this._chunkIndex+=1,this.advance()}parseStatement(){if(this.curr===void 0)return;let e=Object.keys(this._constructor.STATEMENT_PARSERS);if(this.matchSet(e)){let s=this.prevComments,r=this._constructor.STATEMENT_PARSERS[this.prev?.tokenType??"unknown"]?.call(this);return r?.addComments(s,{prepend:!0}),r}if(this.matchSet(this._dialectConstructor.tokenizerClass.COMMANDS))return this.parseCommand();if(this.matchTextSeq("WHILE"))return this.parseWhileBlock();let t=this.parseExpression();return t=t?this.parseSetOperations(t):this.parseSelect(),t instanceof he&&this.match("pipeGt",{advance:!1})&&(t=this.parsePipeSyntaxQuery(t)),this.parseQueryModifiers(t)}parsePartitionedByBucketOrTruncate(){if(this.curr?.tokenType!=="lParen"){this.retreat(this.index-1);return}let e=this.prev?.text.toUpperCase()==="BUCKET"?Xu:Ju,t=this.parseWrappedCsv(()=>this.parsePrimary()||this.parseColumn()),s=k(t,0),r=k(t,1);return s instanceof I&&([s,r]=[r,s]),this.expression(e,{this:s,expression:r})}raiseError(e,t){let s=t||this.curr||this.prev||ey.string(""),{formattedSql:r,startContext:i,highlight:o,endContext:c}=aG({sql:this.sql,positions:[[s.start??0,s.end??0]],contextLength:this.errorMessageContext}),p=`${e}. Line ${s.line}, Col: ${s.col}.
|
|
5
|
+
${r}`,u=new Ke(p,[{description:e,line:s.line,col:s.col,startContext:i,highlight:o,endContext:c}]);if(this.errorLevel===3)throw u;this.errors.push(u)}checkErrors(){if(this.errorLevel===1)for(let e of this.errors)console.error(e.toString());else if(this.errorLevel===2&&0<this.errors.length)throw new Ke(gM(this.errors,this.maxErrors),Wk(this.errors))}expression(e,t={}){let{token:s,comments:r,...i}=t,o;return s?(o=new e({this:s.text,...i}),o.updatePositions(s)):o=new e(i),r?.length?o.addComments(r):this.addComments(o),this.validateExpression(o)}addComments(e){e&&this.prevComments?.length&&(e.addComments(this.prevComments),this.prevComments=void 0)}parseIdVar(e={}){let{anyToken:t=!0,tokens:s}=e,r=this.parseIdentifier();if(!r&&(t&&this.advanceAny()||this.matchSet(s||this._constructor.ID_VAR_TOKENS))){let i=this.prev?.tokenType==="string";r=this.identifierExpression(void 0,{quoted:i})}return r}parseGrantPrincipal(){let e=(this.matchTexts(["ROLE","GROUP"])||void 0)&&this.prev?.text.toUpperCase(),t=this.parseIdVar();if(t)return this.expression(Qy,{this:t,kind:e})}parseGrantPrivilege(){let e=[];for(;this.curr&&!this.matchSet(this._constructor.PRIVILEGE_FOLLOW_TOKENS,{advance:!1});)e.push(this.curr.text.toUpperCase()),this.advance();let t=this.expression(Ve,{this:e.join(" ")}),s=this.match("lParen",{advance:!1})?this.parseWrappedCsv(()=>this.parseColumn()):void 0;return this.expression(zy,{this:t,expressions:s})}matchTexts(e,t={}){let{advance:s=!0}=t,r=Array.from(e instanceof Set?e:J(e));return this.curr&&this.curr.tokenType!=="string"&&r.includes(this.curr.text.toUpperCase())?(s&&this.advance(),!0):!1}matchSet(e,t={}){let{advance:s=!0}=t;return this.curr&&(Array.isArray(e)?e.includes(this.curr.tokenType):e.has(this.curr.tokenType))?(s&&this.advance(),!0):!1}matchPair(e,t,s={}){let{advance:r=!0}=s;return!this.curr||!this.next?!1:this.curr.tokenType===e&&this.next.tokenType===t?(r&&this.advance(2),!0):!1}matchLParen(e){this.match("lParen",{advance:!0,expression:e})||this.raiseError("Expecting (")}matchRParen(e){this.match("rParen",{advance:!0,expression:e})||this.raiseError("Expecting )")}matchTextSeq(e,t={}){let{advance:s=!0}=t,r=J(e),i=this.index;for(let o of r)if(this.curr&&this.curr.tokenType!=="string"&&this.curr.text.toUpperCase()===o)this.advance();else return this.retreat(i),!1;return s||this.retreat(i),!0}replaceLambda(e,t){if(!e)return e;let s={};for(let r of t)s[r.name]=r.args.to||!1;for(let r of e.findAll($)){let i=s[r.parts[0]?.name||""];if(i!==void 0){let o=r.args.this;re(o,F);let c=r.table?r.toDot():o;i&&(c=this.expression(z,{this:c,to:i}));let p=r.parent;for(;p instanceof ge;){if(!(p.parent instanceof ge)){p.replace(c);break}p=p.parent}(!p||!(p instanceof ge))&&(r===e?e=c:r.replace(c))}}return e}parseTruncateTable(){let e=this.prev;if(this.match("lParen"))return this.retreat(this.index-2),this.parseFunction();let t=this.match("database")||void 0;this.match("table");let s=this.parseExists({not:!1}),r=this.parseCsv(()=>this.parseTable({schema:!0,isDbReference:t})),i=this.match("on")?this.parseOnProperty():void 0,o;this.matchTextSeq(["RESTART","IDENTITY"])?o="RESTART":this.matchTextSeq(["CONTINUE","IDENTITY"])?o="CONTINUE":o=void 0;let c;this.matchTextSeq("CASCADE")||this.matchTextSeq("RESTRICT")?c=this.prev?.text:c=void 0;let p=this.parsePartition();return this.curr?this.parseAsCommand(e):this.expression(uy,{expressions:r,isDatabase:t,exists:s,cluster:i,identity:o,option:c,partition:p})}parseWithOperator(){let e=this.parseOrdered(()=>this.parseOpClass());if(!this.match("with"))return e;let t=this.parseVar({anyToken:!0,tokens:this._constructor.RESERVED_TOKENS});return this.expression(eu,{this:e,op:t})}parseWrappedOptions(){this.match("eq"),this.match("lParen");let e=[],t;for(;this.curr&&!this.match("rParen");){if(this.matchTextSeq(["FORMAT_NAME","="])?t=this.parseFormatName():t=this.parseProperty(),t===void 0){this.raiseError("Unable to parse option");break}e.push(...Array.isArray(t)?t:[t])}return e}parseCopyParameters(){let e=this._dialectConstructor.COPY_PARAMS_ARE_CSV?"comma":void 0,t=[];for(;this.curr&&!this.match("rParen",{advance:!1});){let s=this.parseVar({anyToken:!0}),r=this.prev?.text.toUpperCase();this.match("eq"),this.match("alias");let i=this.expression(Cy,{this:s});r&&this._constructor.COPY_INTO_VARLEN_OPTIONS.has(r)&&this.match("lParen",{advance:!1})?i.setArgKey("expressions",this.parseWrappedOptions()):r==="FILE_FORMAT"?i.setArgKey("expression",this.parseField()):r==="FORMAT"&&this.prev?.tokenType==="alias"&&this.matchTexts(["AVRO","JSON"])?(i.setArgKey("this",this.expression(Ve,{this:`FORMAT AS ${this.prev?.text.toUpperCase()}`})),i.setArgKey("expression",this.parseField())):i.setArgKey("expression",this.parseUnquotedField()||this.parseBracket()),t.push(i),e&&this.match(e)}return t}parseCredentials(){let e=this.expression(by,{});if(this.matchTextSeq(["STORAGE_INTEGRATION","="])&&e.setArgKey("storage",this.parseField()),this.matchTextSeq("CREDENTIALS")){let t=this.match("eq")?this.parseWrappedOptions():this.parseField();e.setArgKey("credentials",t)}return this.matchTextSeq("ENCRYPTION")&&e.setArgKey("encryption",this.parseWrappedOptions()),this.matchTextSeq("IAM_ROLE")&&e.setArgKey("iamRole",this.match("default")?this.expression(Ve,{this:this.prev?.text}):this.parseField()),this.matchTextSeq("REGION")&&e.setArgKey("region",this.parseField()),e}parseFileLocation(){return this.parseField()}parseCopy(){let e=this.prev;this.match("into");let t=this.match("lParen",{advance:!1})?this.parseSelect({nested:!0,parseSubqueryAlias:!1}):this.parseTable({schema:!0}),s=this.match("from")||!this.matchTextSeq("TO"),r=this.parseCsv(()=>this.parseFileLocation());this.match("eq",{advance:!1})&&(this.advance(-1),r=[]);let i=this.parseCredentials();this.matchTextSeq("WITH");let o=this.parseWrapped(()=>this.parseCopyParameters(),{optional:!0});return this.curr?this.parseAsCommand(e):this.expression(BC,{this:t,kind:s,credentials:i,files:r,params:o})}parseNormalize(){return this.expression(xb,{this:this.parseBitwise(),form:this.match("comma")&&this.parseVar()})}parseCeilFloor(e){let t=this.parseCsv(()=>this.parseLambda()),s=k(t,0),r=k(t,1);return new e({this:s,decimals:r,to:this.matchTextSeq("TO")&&this.parseVar()})}parseStarOps(){let e=this.prev;if(this.matchTextSeq(["COLUMNS","("],{advance:!1})){let t=this.parseFunction();return t instanceof tb&&t.setArgKey("unpack",!0),t}return this.expression(Ne,{except:this.parseStarOp("EXCEPT")||this.parseStarOp("EXCLUDE"),replace:this.parseStarOp("REPLACE"),rename:this.parseStarOp("RENAME")}).updatePositions(e)}parseGrantRevokeCommon(){let e=this.parseCsv(()=>this.parseGrantPrivilege());this.match("on");let t=(this.matchSet(this._constructor.CREATABLES)||void 0)&&this.prev?.text.toUpperCase(),s=this.tryParse(()=>this.parseTableParts());return{privileges:e,kind:t,securable:s}}parseGrant(){let e=this.prev,{privileges:t,kind:s,securable:r}=this.parseGrantRevokeCommon();if(!r||!this.matchTextSeq("TO"))return this.parseAsCommand(e);let i=this.parseCsv(()=>this.parseGrantPrincipal()),o=this.matchTextSeq(["WITH","GRANT","OPTION"])||void 0;return this.curr?this.parseAsCommand(e):this.expression(Gy,{privileges:t,kind:s,securable:r,principals:i,grantOption:o})}parseRevoke(){let e=this.prev,t=this.matchTextSeq(["GRANT","OPTION","FOR"])||void 0,{privileges:s,kind:r,securable:i}=this.parseGrantRevokeCommon();if(!i||!this.matchTextSeq("FROM"))return this.parseAsCommand(e);let o=this.parseCsv(()=>this.parseGrantPrincipal()),c;return this.matchTexts(["CASCADE","RESTRICT"])&&(c=this.prev?.text.toUpperCase()),this.curr?this.parseAsCommand(e):this.expression(Yy,{privileges:s,kind:r,securable:i,principals:o,grantOption:t,cascade:c})}parseOverlay(){let e=n(t=>(this.match("comma")||this.matchTextSeq(t)||void 0)&&this.parseBitwise(),"parseOverlayArg");return this.expression(fb,{this:this.parseBitwise(),expression:e("PLACING"),from:e("FROM"),for:e("FOR")})}parseFormatName(){return this.expression(w,{this:this.expression(Ve,{this:"FORMAT_NAME"}),value:this.parseString()||this.parseTableParts()})}parseMaxMinBy(e){let t=[];return this.match("distinct")&&(t.push(this.expression(et,{expressions:[this.parseLambda()]})),this.match("comma")),t.push(...this.parseFunctionArgs()),this.expression(e,{this:k(t,0),expression:k(t,1),count:k(t,2)})}identifierExpression(e,t){return this.expression(F,{token:e||this.prev,...t})}parseWrappedIdVars(e={}){let{optional:t=!1}=e;return this.parseWrappedCsv(()=>this.parseIdVar(),{optional:t})}parseWrappedCsv(e,t={}){let{sep:s="comma",optional:r=!1}=t;return this.parseWrapped(()=>this.parseCsv(e,{sep:s}),{optional:r})}parseWrapped(e,t={}){let{optional:s=!1}=t,r=this.match("lParen")||void 0;!r&&!s&&this.raiseError("Expecting (");let i=e();return r&&this.matchRParen(),i}parseExpressions(){return this.parseCsv(()=>this.parseExpression())}parseSelectOrExpression(e={}){let{alias:t=!1}=e;return this.parseSetOperations(t?this.parseAlias(this.parseAssignment(),{explicit:!0}):this.parseAssignment())||this.parseSelect()}parseDdlSelect(){return this.parseQueryModifiers(this.parseSetOperations(this.parseSelect({nested:!0,parseSubqueryAlias:!1})))}parseTransaction(){let e;this.matchTexts(this._constructor.TRANSACTION_KIND)&&(e=this.prev?.text),this.matchTexts(["TRANSACTION","WORK"]);let t=[];for(;;){let s=[];for(;this.match("var")||this.match("not");)s.push(this.prev?.text??"");if(0<s.length&&t.push(s.join(" ")),!this.match("comma"))break}return this.expression(aC,{this:e,modes:t})}parseStar(){return this.match("star")?this._constructor.PRIMARY_PARSERS.star?.call(this,this.prev):this.parsePlaceholder()}parseParameter(){let e=this.parseIdentifier()||this.parsePrimaryOrVar();return this.expression(YC,{this:e})}parsePlaceholder(){if(this.matchSet(new Set(Object.keys(this._constructor.PLACEHOLDER_PARSERS)))){let e=this._constructor.PLACEHOLDER_PARSERS[this.prev?.tokenType??"unknown"]?.call(this);if(e)return e;this.advance(-1)}}parseStarOp(...e){if(!this.matchTexts(e))return;if(this.match("lParen",{advance:!1}))return this.parseWrappedCsv(()=>this.parseExpression());let t=this.parseAlias(this.parseDisjunction(),{explicit:!0});return t?[t]:void 0}parseCsv(e,t={}){let{sep:s="comma"}=t,r=e(),i=r!==void 0?[r]:[];for(;this.match(s);)r instanceof d&&this.addComments(r),r=e(),r!==void 0&&i.push(r);return i}parseIdentifier(){return this.match("identifier")?this.identifierExpression(void 0,{quoted:!0}):this.parsePlaceholder()}parseVar(e={}){let{anyToken:t=!1,tokens:s,upper:r=!1}=e;if(t&&this.advanceAny()||this.match("var")||s&&this.matchSet(s)){let i=r?(this.prev?.text??"").toUpperCase():this.prev?.text??"";return this.expression(Ve,{this:i})}return this.parsePlaceholder()}advanceAny(e={}){let{ignoreReserved:t=!1}=e;if(this.curr&&(t||!this._constructor.RESERVED_TOKENS.has(this.curr.tokenType)))return this.advance(),this.prev}parseVarOrString(e={}){let{upper:t=!1}=e;return this.parseString()||this.parseVar({anyToken:!0,upper:t})}parsePrimaryOrVar(){return this.parsePrimary()||this.parseVar({anyToken:!0})}parseNull(){return this.matchSet(new Set(["null","unknown"]))?this._constructor.PRIMARY_PARSERS.null?.call(this,this.prev):this.parsePlaceholder()}parseBoolean(){return this.match("true")?this._constructor.PRIMARY_PARSERS.true?.call(this,this.prev):this.match("false")?this._constructor.PRIMARY_PARSERS.false?.call(this,this.prev):this.parsePlaceholder()}parseString(){return this.matchSet(new Set(Object.keys(this._constructor.STRING_PARSERS)))?this._constructor.STRING_PARSERS[this.prev?.tokenType??"unknown"]?.call(this,this.prev):this.parsePlaceholder()}parseStringAsIdentifier(){let e=(this.match("string")||void 0)&&this.prev?.text,t=e===void 0?void 0:Z(e,{quoted:!0});return t&&this.prev&&t.updatePositions(this.prev),t}parseNumber(){return this.matchSet(new Set(Object.keys(this._constructor.NUMERIC_PARSERS)))?this._constructor.NUMERIC_PARSERS[this.prev?.tokenType??"unknown"]?.call(this,this.prev):this.parsePlaceholder()}parseHavingMax(e){if(this.match("having")){this.matchTexts(["MAX","MIN"]);let t=this.prev?.text.toUpperCase()!=="MIN";return this.expression(gr,{this:e,expression:this.parseColumn(),max:t})}return e}parseWindow(e,t={}){let{alias:s=!1}=t,r=e,i=r instanceof d?r.comments:void 0;if(this.matchTextSeq(["WITHIN","GROUP"])){let T=this.parseWrapped(()=>this.parseOrder());e=this.expression(ns,{this:e,expression:T})}if(this.matchPair("filter","lParen")&&(this.match("where"),e=this.expression(Xr,{this:e,expression:this.parseWhere({skipWhereToken:!0})}),this.matchRParen()),e instanceof D){let T=e.find([yA,CA]);T&&T!==e&&(T.replace(T.args.this),e=this.expression(T._constructor,{this:e}))}e=this.parseRespectOrIgnoreNulls(e);let o;if(s)o=void 0,this.match("alias");else if(this.matchSet(this._constructor.WINDOW_BEFORE_PAREN_TOKENS))o=this.prev?.text.toUpperCase();else return e;if(i&&r instanceof d&&r.popComments(),!this.match("lParen"))return this.expression(Ue,{comments:i,this:e,alias:this.parseIdVar({anyToken:!1}),over:o});let c=this.parseIdVar({anyToken:!1,tokens:this._constructor.WINDOW_ALIAS_TOKENS}),p=this.match("first")||void 0;this.matchTextSeq("LAST")&&(p=!1);let[u,h]=this.parsePartitionAndOrder(),g=(this.matchSet(new Set(["rows","range"]))||this.matchTextSeq("GROUPS")||void 0)&&this.prev?.text,x;if(g){this.match("between");let T=this.parseWindowSpec(),y=this.match("and")?this.parseWindowSpec():{},b=this.matchTextSeq("EXCLUDE")?this.parseVarFromOptions(this._constructor.WINDOW_EXCLUDE_OPTIONS):void 0;x=this.expression(pu,{kind:g,start:T.value,startSide:T.side,end:y.value,endSide:y.side,exclude:b})}else x=void 0;this.matchRParen();let f=this.expression(Ue,{comments:i,this:e,partitionBy:u,order:h,spec:x,alias:c,over:o,first:p});return this.matchSet(this._constructor.WINDOW_BEFORE_PAREN_TOKENS,{advance:!1})?this.parseWindow(f,{alias:s}):f}parsePartitionAndOrder(){return[this.parsePartitionBy(),this.parseOrder()]}parseWindowSpec(){return this.match("between"),{value:this.matchTextSeq("UNBOUNDED")&&"UNBOUNDED"||this.matchTextSeq(["CURRENT","ROW"])&&"CURRENT ROW"||this.parseBitwise()||void 0,side:(this.matchTexts(this._constructor.WINDOW_SIDES)||void 0)&&this.prev?.text}}parseAlias(e,t={}){let{explicit:s=!1}=t;if(this.canParseLimitOrOffset())return e;let r=this.match("alias"),i=this.prevComments??[];if(s&&!r)return e;if(this.match("lParen")){let c=this.expression(Hn,{comments:i,this:e,expressions:this.parseCsv(()=>this.parseIdVar({anyToken:r}))});return this.matchRParen(c),c}let o=this.parseIdVar({anyToken:r,tokens:this._constructor.ALIAS_TOKENS})||this._constructor.STRING_ALIASES&&this.parseStringAsIdentifier();if(o){i.push(...o.popComments()),e=this.expression(Oe,{comments:i,this:e,alias:o});let c=e.args.this;(!e.comments||e.comments.length===0)&&c&&c.comments&&0<c.comments.length&&(e.comments=c.popComments())}return e}parseOpenJson(){let e=this.parseBitwise(),t=(this.match("comma")||void 0)&&this.parseString(),s=n(()=>{let i=this.parseField({anyToken:!0}),o=this.parseTypes(),c=this.parseString(),p=this.matchPair("alias","json")||void 0;return this.expression(IC,{this:i,kind:o,path:c,asJson:p})},"parseOpenJsonColumnDef"),r;return this.matchPair("rParen","with")&&(this.matchLParen(),r=this.parseCsv(s)),this.expression(hb,{this:e,path:t,expressions:r})}parsePosition(e={}){let{haystackFirst:t=!1}=e,s=this.parseCsv(()=>this.parseBitwise());if(this.match("in"))return this.expression(Bs,{this:this.parseBitwise(),substr:k(s,0)});let r=t?k(s,0):k(s,1),i=t?k(s,1):k(s,0);return this.expression(Bs,{this:r,substr:i,position:k(s,2)})}parseJoinHint(e){let t=this.parseCsv(()=>this.parseTable());return new gn({this:e.toUpperCase(),expressions:t})}parseSubstring(){let e=this.parseCsv(()=>this.parseBitwise()),t,s;for(;this.curr;)if(this.match("from"))t=this.parseBitwise();else if(this.match("for"))t||(t=I.number(1)),s=this.parseBitwise();else break;return t&&e.push(t),s&&e.push(s),this.validateExpression(Is.fromArgList(e),e)}parseTrim(){let e,t,s;this.matchTexts(this._constructor.TRIM_TYPES)&&(e=this.prev?.text.toUpperCase());let r=this.parseBitwise();if(this.matchSet(new Set(["from","comma"]))){let i=this.prev?.tokenType==="from"||this._constructor.TRIM_PATTERN_FIRST;s=this.parseBitwise(),i&&([r,s]=[s,r])}return this.match("collate")&&(t=this.parseBitwise()),this.expression(Ya,{this:r,position:e,expression:s,collation:t})}parseWindowClause(){return(this.match("window")||void 0)&&this.parseCsv(()=>this.parseNamedWindow())}parseNamedWindow(){return this.parseWindow(this.parseIdVar(),{alias:!0})}parseRespectOrIgnoreNulls(e){if(this.curr?.tokenType==="var"){if(this.matchTextSeq(["IGNORE","NULLS"]))return this.expression(yA,{this:e});if(this.matchTextSeq(["RESPECT","NULLS"]))return this.expression(CA,{this:e})}return e}parseJsonObject(e={}){let{agg:t=!1}=e,s=this.parseStar(),r=s?[s]:this.parseCsv(()=>this.parseFormatJson(this.parseJsonKeyValue())),i=this.parseOnHandling("NULL",["NULL","ABSENT"]),o;this.matchTextSeq(["WITH","UNIQUE"])?o=!0:this.matchTextSeq(["WITHOUT","UNIQUE"])&&(o=!1),this.matchTextSeq("KEYS");let c=(this.matchTextSeq("RETURNING")||void 0)&&this.parseFormatJson(this.parseType()),p=(this.matchTextSeq("ENCODING")||void 0)&&this.parseVar();return this.expression(t?Nb:Sh,{expressions:r,nullHandling:i,uniqueKeys:o,returnType:c,encoding:p})}parseJsonColumnDef(){let e,t,s,r;this.matchTextSeq("NESTED")?(e=void 0,t=void 0,s=void 0,r=!0):(e=this.parseIdVar(),t=this.matchPair("for","ordinality")||void 0,s=this.parseTypes({allowIdentifiers:!1}),r=void 0);let i=(this.matchTextSeq("PATH")||void 0)&&this.parseString(),o=r&&this.parseJsonSchema();return this.expression(OC,{this:e,kind:s,path:i,nestedSchema:o,ordinality:t})}parseJsonSchema(){return this.matchTextSeq("COLUMNS"),this.expression(mC,{expressions:this.parseWrappedCsv(()=>this.parseJsonColumnDef(),{optional:!0})})}parseJsonTable(){let e=this.parseFormatJson(this.parseBitwise());e||this.raiseError("Expected expression for JSON_TABLE");let t=(this.match("comma")||void 0)&&this.parseString(),s=this.parseOnHandling("ERROR",["ERROR","NULL"]),r=this.parseOnHandling("EMPTY",["ERROR","NULL"]),i=this.parseJsonSchema();return new ub({this:e,schema:i,path:t,errorHandling:s,emptyHandling:r})}parseMatchAgainst(){let e;if(this.matchTextSeq("TABLE")){e=[];let r=this.parseTable();r&&(e=[r])}else e=this.parseCsv(()=>this.parseColumn());this.matchTextSeq([")","AGAINST","("]);let t=this.parseString(),s;return this.matchTextSeq(["IN","NATURAL","LANGUAGE","MODE"])?(s="IN NATURAL LANGUAGE MODE",this.matchTextSeq(["WITH","QUERY","EXPANSION"])&&(s=`${s} WITH QUERY EXPANSION`)):this.matchTextSeq(["IN","BOOLEAN","MODE"])?s="IN BOOLEAN MODE":this.matchTextSeq(["WITH","QUERY","EXPANSION"])?s="WITH QUERY EXPANSION":s=void 0,this.expression(db,{this:t,expressions:e,modifier:s})}parseJsonKeyValue(){this.matchTextSeq("KEY");let e=this.parseColumn();this.matchSet(this._constructor.JSON_KEY_VALUE_SEPARATOR_TOKENS),this.matchTextSeq("VALUE");let t=this.parseBitwise();if(!(!e&&!t))return this.expression(RC,{this:e,expression:t})}parseFormatJson(e){return!e||!this.matchTextSeq(["FORMAT","JSON"])?e:this.expression(SC,{this:e})}parseOnCondition(){let e,t;this._dialectConstructor.ON_CONDITION_EMPTY_BEFORE_ERROR?(e=this.parseOnHandling("EMPTY",[...this._constructor.ON_CONDITION_TOKENS]),t=this.parseOnHandling("ERROR",[...this._constructor.ON_CONDITION_TOKENS])):(t=this.parseOnHandling("ERROR",[...this._constructor.ON_CONDITION_TOKENS]),e=this.parseOnHandling("EMPTY",[...this._constructor.ON_CONDITION_TOKENS]));let s=this.parseOnHandling("NULL",[...this._constructor.ON_CONDITION_TOKENS]);if(!(!e&&!t&&!s))return this.expression(Uy,{empty:e,error:t,null:s})}parseOnHandling(e,t){for(let r of t)if(this.matchTextSeq([r,"ON",e]))return`${r} ON ${e}`;let s=this.index;if(this.match("default")){let r=this.parseBitwise();if(this.matchTextSeq(["ON",e]))return r;this.retreat(s)}}parseConvert(e){let{safe:t,strict:s}=e,r=this.parseBitwise(),i;return this.match("using")?i=this.expression(TA,{this:this.parseVar({tokens:new Set(["binary"])})}):this.match("comma")?i=this.parseTypes():i=void 0,this.buildCast({strict:s,this:r,to:i,safe:t})}parseXmlElement(){let e,t;return this.matchTextSeq("EVALNAME")?(e=!0,t=this.parseBitwise()):(e=void 0,this.matchTextSeq("NAME"),t=this.parseIdVar()),this.expression(Sb,{this:t,expressions:(this.match("comma")||void 0)&&this.parseCsv(()=>this.parseBitwise()),evalname:e})}parseXmlTable(){let e,t,s;this.matchTextSeq(["XMLNAMESPACES","("])&&(e=this.parseXmlNamespace(),this.match("rParen"),this.match("comma"));let r=this.parseString();this.matchTextSeq("PASSING")&&(this.matchTextSeq(["BY","VALUE"]),t=this.parseCsv(()=>this.parseColumn()));let i=this.matchTextSeq(["RETURNING","SEQUENCE","BY","REF"])||void 0;return this.matchTextSeq("COLUMNS")&&(s=this.parseCsv(()=>this.parseFieldDef())),this.expression(Rb,{this:r,namespaces:e,passing:t,columns:s,byRef:i})}parseXmlNamespace(){let e=[];for(;;){let t;if(this.match("default")?t=this.parseString():t=this.parseAlias(this.parseString()),e.push(this.expression(yC,{this:t})),!this.match("comma"))break}return e}parseDecode(){let e=this.parseCsv(()=>this.parseDisjunction());return e.length<3?this.expression(ob,{this:k(e,0),charset:k(e,1)}):this.expression(cb,{expressions:e})}parseGapFill(){this.match("table");let e=this.parseTable();this.match("comma");let t=[e,...this.parseCsv(()=>this.parseLambda())].filter(r=>r instanceof d),s=pb.fromArgList(t);return this.validateExpression(s,t)}parseChar(){return this.expression(gh,{expressions:this.parseCsv(()=>this.parseAssignment()),charset:(this.match("using")||void 0)&&this.parseVar()})}parseCast(e){let{safe:t,strict:s}=e,r=this.parseAssignment();if(!this.match("alias")){if(this.match("comma"))return this.expression(ib,{this:r,to:this.parseString()});this.raiseError("Expected AS after CAST")}let i,o=this.parseTypes(),c;if(this.match("default")&&(c=this.parseBitwise(),this.matchTextSeq(["ON","CONVERSION","ERROR"])),this.matchSet(new Set(["format","comma"]))){let p=this.parseWrapped(()=>this.parseString(),{optional:!0});if(i=this.parseAtTimeZone(p),o||(o=N.build("unknown")),o&&N.TEMPORAL_TYPES.has(o.args.this))return r=this.expression(o.args.this==="date"?oi:ys,{this:r,format:I.string(Wl(p?.args.this??"",Object.keys(this._dialectConstructor.FORMAT_MAPPING).length?this._dialectConstructor.FORMAT_MAPPING:this._dialectConstructor.TIME_MAPPING,Object.keys(this._dialectConstructor.FORMAT_MAPPING).length?this._dialectConstructor.FORMAT_TRIE:this._dialectConstructor.TIME_TRIE)??""),safe:t}),i instanceof gs&&r instanceof ys&&r.setArgKey("zone",i.args.zone),r}else o?o instanceof F?o=N.build(o.name,{dialect:this.dialect,udt:!0}):o.args.this==="char"&&this.match("characterSet")&&(o=this.expression(TA,{this:this.parseVarOrString()})):this.raiseError("Expected TYPE after CAST");return this.buildCast({strict:s,this:r,to:o,format:i,safe:t,action:this.parseVarFromOptions(this._constructor.CAST_ACTIONS,{raiseUnmatched:!1}),default:c})}parseStringAgg(){let e;this.match("distinct")?(e=[this.expression(et,{expressions:[this.parseDisjunction()]})],this.match("comma")&&e.push(...this.parseCsv(()=>this.parseDisjunction()))):e=this.parseCsv(()=>this.parseDisjunction());let t;this.matchTextSeq(["ON","OVERFLOW"])?this.matchTextSeq("ERROR")?t=Q("ERROR"):(this.matchTextSeq("TRUNCATE"),t=this.expression(fC,{this:this.parseString(),withCount:this.matchTextSeq(["WITH","COUNT"])||!this.matchTextSeq(["WITHOUT","COUNT"])})):t=void 0;let s=this.index;return!this.match("rParen")&&0<e.length?(e[0]=this.parseLimit(this.parseOrder({thisExpr:e[0]})),this.expression(sr,{this:e[0],separator:k(e,1)})):this.matchTextSeq(["WITHIN","GROUP"])?(this.matchLParen(),this.expression(sr,{this:this.parseOrder({thisExpr:k(e,0)}),separator:k(e,1),onOverflow:t})):(this.retreat(s),this.validateExpression(sr.fromArgList(e.filter(r=>r instanceof d)),e))}parseBracket(e){if(!this.matchSet(this._constructor.BRACKETS))return e;let t;if(this._constructor.MAP_KEYS_ARE_ARBITRARY_EXPRESSIONS){let i=k(this.tokens,this.index-2);t=i!==void 0&&i.text.toUpperCase()==="MAP"}else t=!1;let s=this.prev?.tokenType;if(s==="lBrace"&&this.curr&&this.curr.tokenType==="var"&&this._constructor.ODBC_DATETIME_LITERALS[this.curr.text.toLowerCase()])return this.parseOdbcDatetimeLiteral();let r=this.parseCsv(()=>this.parseBracketKeyValue({isMap:s==="lBrace"}));if(s==="lBracket"&&!this.match("rBracket")?this.raiseError("Expected ]"):s==="lBrace"&&!this.match("rBrace")&&this.raiseError("Expected }"),s==="lBrace")e=this.expression(Es,{expressions:this.kvToPropEq(r,{parseMap:t})});else if(!e&&s)e=aV(ue,r,s,this.dialect);else if(e&&s){let i=this._constructor.ARRAY_CONSTRUCTORS[e?.name.toUpperCase()??""];if(i)return aV(i,r,s,this.dialect);let o=dA(e,r,-this._dialectConstructor.INDEX_OFFSET,{dialect:this.dialect});e=this.expression(wt,{this:e,expressions:o,comments:e.popComments()})}return this.addComments(e),this.parseBracket(e)}parseSlice(e){if(!this.match("colon"))return e;let t;this.matchPair("dash","colon",{advance:!1})?(this.advance(),t=I.number("1").neg()):t=this.parseAssignment();let s=this.match("colon")?this.parseUnary():void 0;return this.expression(On,{this:e,expression:t,step:s})}parseCase(){if(this.match("dot",{advance:!1})){this.retreat(this.index-1);return}let e=[],t,s=this.prevComments,r=this.parseDisjunction();for(;this.match("when");){let i=this.parseDisjunction();this.match("then");let o=this.parseDisjunction();e.push(this.expression(xe,{this:i,true:o}))}return this.match("else")&&(t=this.parseDisjunction()),this.match("end")||(t instanceof qe&&(typeof t.args.this=="string"?t.args.this:t.args.this?.sql())?.toUpperCase()==="END"?t=$n({col:"interval"}):this.raiseError("Expected END after CASE",this.prev)),this.expression(ut,{comments:s,this:r,ifs:e,default:t})}parseIf(){if(this.match("lParen")){let e=this.parseCsv(()=>this.parseAlias(this.parseAssignment(),{explicit:!0})),t=this.validateExpression(xe.fromArgList(e),e);return this.matchRParen(),t}else{let e=this.index-1;if(this._constructor.NO_PAREN_IF_COMMANDS&&e===0)return this.parseAsCommand(this.prev);let t=this.parseDisjunction();if(!t){this.retreat(e);return}this.match("then");let s=this.parseDisjunction(),r=this.match("else")?this.parseDisjunction():void 0;return this.match("end"),this.expression(xe,{this:t,true:s,false:r})}}parseNextValueFor(){if(!this.matchTextSeq(["VALUE","FOR"])){this.retreat(this.index-1);return}return this.expression(Ob,{this:this.parseColumn(),order:(this.match("over")||void 0)&&this.parseWrapped(()=>this.parseOrder())})}parseExtract(){let e=this.parseFunction()||this.parseVarOrString({upper:!0});return this.match("from")?this.expression(lr,{this:e,expression:this.parseBitwise()}):(this.match("comma")||this.raiseError("Expected FROM or comma after EXTRACT",this.prev),this.expression(lr,{this:e,expression:this.parseBitwise()}))}parsePrimaryKeyPart(){return this.parseField()}parsePeriodForSystemTime(){if(!this.match("timestampSnapshot")){this.retreat(this.index-1);return}let e=this.parseWrappedIdVars();return this.expression(DC,{this:k(e,0),expression:k(e,1)})}parsePrimaryKey(e={}){let{wrappedOptional:t=!1,inProps:s=!1,namedPrimaryKey:r=!1}=e,i=this.matchSet(new Set(["asc","desc"]))?this.prev?.tokenType==="desc":void 0,o;if(r&&!((this.curr?.text.toUpperCase()||"")in this._constructor.CONSTRAINT_PARSERS)&&this.next&&(this.next.tokenType==="lParen"||this.next.tokenType==="using")&&(o=this.parseIdVar()),!s&&this.match("using")&&this.advance(),!s&&!this.match("lParen",{advance:!1}))return this.expression(vC,{desc:i,options:this.parseKeyConstraintOptions()});let c=this.parseWrappedCsv(()=>this.parsePrimaryKeyPart(),{optional:t});return this.expression(ru,{this:o,expressions:c,include:this.parseIndexParams(),options:this.parseKeyConstraintOptions()})}parseBracketKeyValue(e={}){return this.parseSlice(this.parseAlias(this.parseDisjunction(),{explicit:!0}))}parseOdbcDatetimeLiteral(){this.match("var");let e=this._constructor.ODBC_DATETIME_LITERALS[this.prev?.text??"".toLowerCase()],t=this.expression(e,{this:this.parseString()});return this.match("rBrace")||this.raiseError("Expected }"),t}parseUniqueKey(){if(!(this.curr&&this.curr.text.toUpperCase()in this._constructor.CONSTRAINT_PARSERS))return this.parseIdVar({anyToken:!1})}parseUnique(){return this.matchTexts(["KEY","INDEX"]),this.expression(Mu,{nulls:this.matchTextSeq(["NULLS","NOT","DISTINCT"])||void 0,this:this.parseSchema({this:this.parseUniqueKey()}),indexType:(this.match("using")||void 0)&&this.advanceAny()&&this.prev?.text,onConflict:this.parseOnConflict(),options:this.parseKeyConstraintOptions()})}parseKeyConstraintOptions(){let e=[];for(;this.curr;)if(this.match("on")){let t,s=this.advanceAny()&&this.prev?.text;this.matchTextSeq(["NO","ACTION"])?t="NO ACTION":this.matchTextSeq("CASCADE")?t="CASCADE":this.matchTextSeq("RESTRICT")?t="RESTRICT":this.matchPair("set","null")?t="SET NULL":this.matchPair("set","default")?t="SET DEFAULT":this.raiseError("Invalid key constraint"),e.push(`ON ${s} ${t}`)}else{let t=this.parseVarFromOptions(this._constructor.KEY_CONSTRAINT_OPTIONS,{raiseUnmatched:!1});if(!t)break;e.push(t.name)}return e}parseReferences(e={}){let{match:t=!0}=e;if(t&&!this.match("references"))return;let s,r=this.parseTable({schema:!0}),i=this.parseKeyConstraintOptions();return this.expression(Ky,{this:r,expressions:s,options:i})}parseForeignKey(){this.curr&&this.curr.tokenType!=="lParen"&&this.curr.tokenType!=="references"&&this.advance();let e=this.match("references",{advance:!1})?void 0:this.parseWrappedIdVars(),t=this.parseReferences(),s={};for(;this.match("on");){this.matchSet(new Set(["delete","update"]))||this.raiseError("Expected DELETE or UPDATE");let r=(this.prev?.text??"").toLowerCase(),i;this.matchTextSeq(["NO","ACTION"])?i="NO ACTION":this.match("set")?(this.matchSet(new Set(["null","default"])),i="SET "+(this.prev?.text??"").toUpperCase()):(this.advance(),i=(this.prev?.text??"").toUpperCase()),s[r]=i}return this.expression(Ly,{expressions:e,reference:t,options:this.parseKeyConstraintOptions(),...s})}parsePrimary(){if(this.matchSet(Object.keys(this._constructor.PRIMARY_PARSERS))){let e=this.prev?.tokenType??"unknown",t=this._constructor.PRIMARY_PARSERS[e]?.call(this,this.prev);if(e==="string"){let s=[t];for(;this.match("string");)s.push(I.string(this.prev?.text??""));if(1<s.length)return this.expression($t,{expressions:s,coalesce:this._dialectConstructor.CONCAT_COALESCE})}return t}return this.matchPair("dot","number")?I.number(`0.${this.prev?.text??""}`):this.parseParen()}parseField(e={}){let{anyToken:t=!1,tokens:s,anonymousFunc:r=!1}=e||{},i;return r?i=this.parseFunction({anonymous:r,anyToken:t})||this.parsePrimary():i=this.parsePrimary()||this.parseFunction({anonymous:r,anyToken:t}),i||this.parseIdVar({anyToken:t,tokens:s})}parseGeneratedAsIdentity(){let e;if(this.matchTextSeq(["BY","DEFAULT"])){let s=this.matchPair("on","null")||void 0;e=this.expression(Jl,{this:!1,onNull:s})}else this.matchTextSeq("ALWAYS"),e=this.expression(Jl,{this:!0});if(this.match("alias"),this.matchTextSeq("ROW")){let s=this.matchTextSeq("START")||void 0;s||this.match("end");let r=this.matchTextSeq("HIDDEN")||void 0;return this.expression(UC,{start:s,hidden:r})}let t=this.matchTextSeq("IDENTITY")||void 0;if(this.match("lParen")){if(this.match("startWith")&&e.setArgKey("start",this.parseBitwise()),this.matchTextSeq(["INCREMENT","BY"])&&e.setArgKey("increment",this.parseBitwise()),this.matchTextSeq("MINVALUE")&&e.setArgKey("minvalue",this.parseBitwise()),this.matchTextSeq("MAXVALUE")&&e.setArgKey("maxvalue",this.parseBitwise()),this.matchTextSeq("CYCLE")?e.setArgKey("cycle",!0):this.matchTextSeq(["NO","CYCLE"])&&e.setArgKey("cycle",!1),!t)e.setArgKey("expression",this.parseRange());else if(!e.args.start&&this.match("number",{advance:!1})){let s=this.parseCsv(this.parseBitwise.bind(this));e.setArgKey("start",k(s,0)),e.setArgKey("increment",k(s,1))}this.matchRParen()}return e}parseInline(){return this.matchTextSeq("LENGTH"),this.expression(Cu,{this:this.parseBitwise()})}parseNotConstraint(){if(this.matchTextSeq("NULL"))return this.expression(LA);if(this.matchTextSeq("CASESPECIFIC"))return this.expression(kn,{not:!0});if(this.matchTextSeq(["FOR","REPLICATION"]))return this.expression(Pu);this.retreat(this.index-1)}parseColumnConstraint(){let e=(this.match("constraint")||void 0)&&this.parseIdVar();if(!((this.match("with",{advance:!1})||void 0)&&this.next&&this.next.text.toUpperCase()in this._constructor.PROCEDURE_OPTIONS)&&this.matchTexts(Object.keys(this._constructor.CONSTRAINT_PARSERS))){let s=this._constructor.CONSTRAINT_PARSERS[(this.prev?.text??"").toUpperCase()]?.call(this);if(!s){this.retreat(this.index-1);return}return this.expression(yn,{this:e,kind:s})}return e}parseConstraint(){return this.match("constraint")?this.expression(Ny,{this:this.parseIdVar(),expressions:this.parseUnnamedConstraints()}):this.parseUnnamedConstraint({constraints:this._constructor.SCHEMA_UNNAMED_CONSTRAINTS})}parseUnnamedConstraints(){let e=[];for(;;){let t=this.parseUnnamedConstraint()||this.parseFunction();if(!t)break;e.push(t)}return e}parseUnnamedConstraint(e={}){let t=this.index,{constraints:s}=e;if(this.match("identifier",{advance:!1})||!this.matchTexts(s||Object.keys(this._constructor.CONSTRAINT_PARSERS)))return;let r=(this.prev?.text??"").toUpperCase();r in this._constructor.CONSTRAINT_PARSERS||this.raiseError(`No parser found for schema constraint ${r}.`);let i=this._constructor.CONSTRAINT_PARSERS[r]?.call(this);if(!i||Array.isArray(i)){this.retreat(t);return}return i}parseFieldDef(){return this.parseColumnDef(this.parseField({anyToken:!0}))}parseColumnDef(e,t={}){let{computedColumn:s=!0}=t,r=e;r instanceof $&&(r=r.args.this),s||this.match("alias");let i=this.parseTypes({schema:!0});if(this.matchTextSeq(["FOR","ORDINALITY"]))return this.expression(Pe,{this:r,ordinality:!0});let o=[];if(!i&&this.match("alias")||this.matchTexts(["ALIAS","MATERIALIZED"])){let p=(this.prev?.text??"").toUpperCase()==="MATERIALIZED",u=new Dn({this:this.parseDisjunction(),persisted:p||this.matchTextSeq("PERSISTED")||void 0,dataType:this.matchTextSeq("AUTO")?new N({this:"AUTO"}):this.parseTypes(),notNull:this.matchPair("not","null")||void 0});o.push(this.expression(yn,{kind:u}))}else if(!i&&this.matchSet(["in","out"],{advance:!1})){let p=this.expression(FC,{input:this.match("in")||void 0,output:this.match("out")||void 0});o.push(p),i=this.parseTypes()}else i&&this.match("alias",{advance:!1})&&(!this._constructor.WRAPPED_TRANSFORM_COLUMN_CONSTRAINT||this.next&&this.next.tokenType==="lParen")&&(this.advance(),o.push(this.expression(yn,{kind:new Dn({this:this.parseDisjunction(),persisted:(this.matchTexts(["STORED","VIRTUAL"])||void 0)&&(this.prev?.text??"").toUpperCase()==="STORED"})})));for(;;){let p=this.parseColumnConstraint();if(!p)break;o.push(p)}if(!i&&o.length===0)return r;let c;if(this.matchTexts(["FIRST","AFTER"])){let p=this.prev?.text??"";c=this.expression(Sy,{this:this.parseColumn(),position:p})}return this.expression(Pe,{this:r,kind:i,constraints:o,position:c})}parseAutoIncrement(){let e,t,s;if(this.match("lParen",{advance:!1})){let r=this.parseWrappedCsv(this.parseBitwise.bind(this));e=k(r,0),t=k(r,1)}else this.matchTextSeq("START")&&(e=this.parseBitwise(),this.matchTextSeq("INCREMENT"),t=this.parseBitwise(),this.matchTextSeq("ORDER")?s=!0:this.matchTextSeq("NOORDER")&&(s=!1));return e&&t?new Jl({start:e,increment:t,this:!1,order:s}):new kC({})}parseCheckConstraint(){if(this.match("lParen",{advance:!1}))return this.expression(qC,{this:this.parseWrapped(this.parseAssignment.bind(this)),enforced:this.matchTextSeq("ENFORCED")||void 0})}parseAutoProperty(){if(!this.matchTextSeq("REFRESH")){this.retreat(this.index-1);return}return this.expression(Xn,{this:this.parseVar({upper:!0})})}parseCompress(){return this.match("lParen",{advance:!1})?this.expression(PA,{this:this.parseWrappedCsv(this.parseBitwise.bind(this))}):this.expression(PA,{this:this.parseBitwise()})}parseFunction(e={}){let{functions:t,anonymous:s=!1,optionalParens:r=!0,anyToken:i=!1}=e,o=!1;this.match("lBrace",{advance:!1})&&this.next&&this.next.text.toUpperCase()==="FN"&&(this.advance(2),o=!0);let c=this.parseFunctionCall({functions:t,anonymous:s,optionalParens:r,anyToken:i});return o&&this.match("rBrace"),c}parseFunctionArgs(e={}){let{alias:t=!1}=e;return this.parseCsv(()=>this.parseLambda({alias:t}))}parseFunctionCall(e={}){let{functions:t,anonymous:s=!1,optionalParens:r=!0,anyToken:i=!1}=e;if(!this.curr)return;let o=this.curr.comments,c=this.prev,p=this.curr,u=this.curr.tokenType,h=this.curr.text,g=h.toUpperCase(),x=this._constructor.NO_PAREN_FUNCTION_PARSERS[g];if(x&&r&&!this._constructor.INVALID_FUNC_NAME_TOKENS.has(u))return this.advance(),this.parseWindow(x.call(this));if(!this.next||this.next.tokenType!=="lParen"){let T=this._constructor.NO_PAREN_FUNCTIONS[u];return r&&T?(this.advance(),this.expression(T)):void 0}if(i){if(this._constructor.RESERVED_TOKENS.has(u))return}else if(!this._constructor.FUNC_TOKENS.has(u))return;this.advance(2);let f=this._constructor.FUNCTION_PARSERS[g];if(f&&!s){let T=f.call(this);return T instanceof d&&T.addComments(o),this.match("rParen",{expression:T instanceof d?T:void 0}),this.parseWindow(T)}else{let T=this._constructor.SUBQUERY_PREDICATES[u];if(T){let H;if(this._constructor.SUBQUERY_TOKENS.has(this.curr.tokenType)?(H=this.parseSelect(),this.matchRParen()):c&&(c.tokenType==="like"||c.tokenType==="ilike")&&(this.advance(-1),H=this.parseBitwise()),H)return this.expression(T,{comments:o,this:H})}let b=(t??this._constructor.FUNCTIONS)[g],m=b&&!s,C=!m||this._constructor.FUNCTIONS_WITH_ALIASED_ARGS.has(g),q=this.parseFunctionArgs({alias:C}),U=this.curr?.comments,_=m;_&&U&&U.some(H=>H.trimStart().startsWith(ND))&&(_=!1);let ne=C&&_?this.kvToPropEq(q):q,K;if(_){let H;1<b.length?H=b(ne,{dialect:this.dialect}):H=b(ne),H=this.validateExpression(H,ne),this._dialectConstructor.PRESERVE_ORIGINAL_NAMES&&(H.meta.name=h),K=H}else{let H=h;u==="identifier"&&(H=new F({this:h,quoted:!0}).updatePositions(p)),K=this.expression(Qe,{this:H,expressions:q})}return K=K.updatePositions(p),K instanceof d&&K.addComments(o),this.matchRParen(K),this.parseWindow(K)}}toPropEq(e,t){return e}kvToPropEq(e,t={}){let{parseMap:s=!1}=t,r=[];for(let i=0;i<e.length;i++){let o=e[i];if([...this._constructor.KEY_VALUE_DEFINITIONS.keys()].some(c=>o instanceof c)){if(o instanceof Oe&&(o=this.expression(ot,{this:o.args.alias,expression:o.args.this})),!(o instanceof ot)){let c=o.args.this;o=this.expression(ot,{this:s?o.args.this:Z(c instanceof d?c.name:c?.toString()),expression:o.args.expression})}o.args.this instanceof $&&o.args.this.replace(o.args.this.args.this)}else o=this.toPropEq(o,i);r.push(o)}return r}parseUserDefinedFunctionExpression(){return this.parseStatement()}parseFunctionParameter(){return this.parseColumnDef(this.parseIdVar(),{computedColumn:!1})}parseUserDefinedFunction(e={}){let t=this.parseTableParts({schema:!0});if(!this.match("lParen"))return t;let s=this.parseCsv(this.parseFunctionParameter.bind(this));return this.matchRParen(),this.expression(fy,{this:t,expressions:s,wrapped:!0})}parseIntroducer(e){let t=this.parsePrimary();return t?this.expression(vy,{token:e,expression:t}):this.identifierExpression(e)}parseSessionParameter(){let e,t=this.parseIdVar()||this.parsePrimary();return t&&this.match("dot")&&(e=t.name,t=this.parseVar()||this.parsePrimary()),this.expression(VC,{this:t,kind:e})}parseLambdaArg(){return this.parseIdVar()}parseLambda(e={}){let{alias:t=!1}=e,s=this.next?.tokenType;if(s!==void 0&&this._constructor.LAMBDA_ARG_TERMINATORS.has(s)){let c=this.parseAtom();if(c!==void 0)return c}let r=this.index,i;if(this.match("lParen"))if(i=this.parseCsv(this.parseLambdaArg.bind(this)),!this.match("rParen"))this.retreat(r);else if(this.matchSet(Object.keys(this._constructor.LAMBDAS))){let c=this.prev?.tokenType;return c&&this._constructor.LAMBDAS[c]?.call(this,i.filter(p=>!!p))}else this.retreat(r);else if(this._constructor.TYPED_LAMBDA_ARGS||s!==void 0&&s in this._constructor.LAMBDAS){if(i=[this.parseLambdaArg()],this.matchSet(Object.keys(this._constructor.LAMBDAS))){let c=this.prev?.tokenType;return c&&this._constructor.LAMBDAS[c]?.call(this,i.filter(p=>!!p))}this.retreat(r)}let o;return this.match("distinct")?o=this.expression(et,{expressions:this.parseCsv(this.parseDisjunction.bind(this))}):o=this.parseSelectOrExpression({alias:t}),this.parseLimit(this.parseRespectOrIgnoreNulls(this.parseOrder({thisExpr:this.parseHavingMax(this.parseRespectOrIgnoreNulls(o))})))}parseSchema(e={}){let{this:t}=e,s=this.index;if(!this.match("lParen"))return t;if(this.matchSet(this._constructor.SELECT_START_TOKENS))return this.retreat(s),t;let r=this.parseCsv(()=>this.parseConstraint()||this.parseFieldDef());return this.matchRParen(),this.expression(Rt,{this:t,expressions:r})}parseAlterTableSet(){let e=this.expression(Ry);if(this.match("lParen",{advance:!1})||this.matchTextSeq(["TABLE","PROPERTIES"]))e.setArgKey("expressions",this.parseWrappedCsv(this.parseAssignment.bind(this)));else if(this.matchTextSeq("FILESTREAM_ON",{advance:!1}))e.setArgKey("expressions",[this.parseAssignment()]);else if(this.matchTexts(["LOGGED","UNLOGGED"]))e.setArgKey("option",Q((this.prev?.text??"").toUpperCase()));else if(this.matchTextSeq("WITHOUT")&&this.matchTexts(["CLUSTER","OIDS"]))e.setArgKey("option",Q(`WITHOUT ${(this.prev?.text??"").toUpperCase()}`));else if(this.matchTextSeq("LOCATION"))e.setArgKey("location",this.parseField());else if(this.matchTextSeq(["ACCESS","METHOD"]))e.setArgKey("accessMethod",this.parseField());else if(this.matchTextSeq("TABLESPACE"))e.setArgKey("tablespace",this.parseField());else if(this.matchTextSeq(["FILE","FORMAT"])||this.matchTextSeq("FILEFORMAT"))e.setArgKey("fileFormat",[this.parseField()]);else if(this.matchTextSeq("STAGE_FILE_FORMAT"))e.setArgKey("fileFormat",this.parseWrappedOptions());else if(this.matchTextSeq("STAGE_COPY_OPTIONS"))e.setArgKey("copyOptions",this.parseWrappedOptions());else if(this.matchTextSeq("TAG")||this.matchTextSeq("TAGS"))e.setArgKey("tag",this.parseCsv(this.parseAssignment.bind(this)));else{this.matchTextSeq("SERDE")&&e.setArgKey("serde",this.parseField());let t=this.parseWrapped(this.parseProperties.bind(this),{optional:!0});e.setArgKey("expressions",t?[t]:[])}return e}parseAlterSession(){if(this.match("set")){let t=this.parseCsv(()=>this.parseSetItemAssignment());return this.expression(mA,{expressions:t,unset:!1})}this.matchTextSeq("UNSET");let e=this.parseCsv(()=>this.expression(Xl,{this:this.parseIdVar({anyToken:!0})}));return this.expression(mA,{expressions:e,unset:!0})}parseAlter(){let e=this.prev,t=this.matchTextSeq("ICEBERG")||void 0,s=(this.matchSet(this._constructor.ALTERABLES)||void 0)&&this.prev;if(!s)return this.parseAsCommand(e);if(t&&s.tokenType!=="table")return this.parseAsCommand(e);let r=this.parseExists(),i=this.matchTextSeq("ONLY")||void 0,o,c,p;s.tokenType==="session"?(o=void 0,c=void 0,p=void 0):(o=this.parseTable({schema:!0,parsePartition:this._constructor.ALTER_TABLE_PARTITIONS}),c=this.matchTextSeq(["WITH","CHECK"])||this.matchTextSeq(["WITH","NOCHECK"])||void 0,p=this.match("on")?this.parseOnProperty():void 0,this.next&&this.advance());let u=this.prev?this._constructor.ALTER_PARSERS[this.prev.text.toUpperCase()]:void 0;if(u){let h=J(u.call(this)),g=this.matchTextSeq(["NOT","VALID"])||void 0,x=this.parseCsv(this.parseProperty.bind(this)),f=this._dialectConstructor.ALTER_TABLE_SUPPORTS_CASCADE&&this.matchTextSeq("CASCADE");if(!this.curr&&h)return this.expression(lu,{this:o,kind:st(VI,s.text)??s.text.toUpperCase(),exists:r,actions:h,only:i,options:x,cluster:p,notValid:g,check:c,cascade:f,iceberg:t})}return this.parseAsCommand(e)}parseAnalyze(){let e=this.prev;if(!this.curr)return this.expression(NA);let t=[];for(;this.matchTexts(this._constructor.ANALYZE_STYLES);)(this.prev?.text??"").toUpperCase()==="BUFFER_USAGE_LIMIT"?t.push(`BUFFER_USAGE_LIMIT ${this.parseNumber()}`):t.push((this.prev?.text??"").toUpperCase());let s,r,i=this.curr?.text.toUpperCase();this.match("table")||this.match("index")?s=this.parseTableParts():this.matchTextSeq("TABLES")?this.matchSet(["from","in"])&&(i=`${i} ${(this.prev?.text??"").toUpperCase()}`,s=this.parseTable({schema:!0,isDbReference:!0})):this.matchTextSeq("DATABASE")?s=this.parseTable({schema:!0,isDbReference:!0}):this.matchTextSeq("CLUSTER")?s=this.parseTable():this.matchTexts(Object.keys(this._constructor.ANALYZE_EXPRESSION_PARSERS))?(i=void 0,r=this._constructor.ANALYZE_EXPRESSION_PARSERS[(this.prev?.text??"").toUpperCase()].call(this)):(i=void 0,s=this.parseTableParts());let o=this.tryParse(this.parsePartition.bind(this));if(!o&&this.matchTexts(this._constructor.PARTITION_KEYWORDS))return this.parseAsCommand(e);let c;this.matchTextSeq(["WITH","SYNC","MODE"])||this.matchTextSeq(["WITH","ASYNC","MODE"])?c=`WITH ${this.tokens[this.index-2].text.toUpperCase()} MODE`:c=void 0,this.matchTexts(Object.keys(this._constructor.ANALYZE_EXPRESSION_PARSERS))&&(r=this._constructor.ANALYZE_EXPRESSION_PARSERS[(this.prev?.text??"").toUpperCase()].call(this));let p=this.parseProperties();return this.expression(NA,{kind:i,this:s,mode:c,partition:o,properties:p,expression:r,options:t})}parseAnalyzeStatistics(){let e,t=(this.prev?.text??"").toUpperCase(),s=this.matchTextSeq("DELTA")?(this.prev?.text??"").toUpperCase():void 0,r=[];if(this.matchTextSeq("STATISTICS")||this.raiseError("Expecting token STATISTICS"),this.matchTextSeq("NOSCAN"))e="NOSCAN";else if(this.match("for"))this.matchTextSeq(["ALL","COLUMNS"])&&(e="FOR ALL COLUMNS"),this.matchTexts("COLUMNS")&&(e="FOR COLUMNS",r=this.parseCsv(this.parseColumnReference.bind(this)));else if(this.matchTextSeq("SAMPLE")){let i=this.parseNumber();r=[this.expression(uC,{sample:i,kind:this.match("percent")?(this.prev?.text??"").toUpperCase():void 0})]}return this.expression(pC,{kind:t,option:s,this:e,expressions:r})}parseAnalyzeValidate(){let e,t,s;return this.matchTextSeq(["REF","UPDATE"])?(e="REF",t="UPDATE",this.matchTextSeq(["SET","DANGLING","TO","NULL"])&&(t="UPDATE SET DANGLING TO NULL")):this.matchTextSeq("STRUCTURE")&&(e="STRUCTURE",this.matchTextSeq(["CASCADE","FAST"])?t="CASCADE FAST":this.matchTextSeq(["CASCADE","COMPLETE"])&&this.matchTexts(["ONLINE","OFFLINE"])&&(t=`CASCADE COMPLETE ${(this.prev?.text??"").toUpperCase()}`,s=this.parseInto())),this.expression(EC,{kind:e,this:t,expression:s})}parseAnalyzeColumns(){let e=(this.prev?.text??"").toUpperCase();if(this.matchTextSeq("COLUMNS"))return this.expression(hu,{this:`${e} ${(this.prev?.text??"").toUpperCase()}`})}parseAnalyzeDelete(){let e=this.matchTextSeq("SYSTEM")?(this.prev?.text??"").toUpperCase():void 0;if(this.matchTextSeq("STATISTICS"))return this.expression(gC,{kind:e})}parseAnalyzeList(){if(this.matchTextSeq(["CHAINED","ROWS"]))return this.expression(hC,{expression:this.parseInto()})}parseAnalyzeHistogram(){let e=(this.prev?.text??"").toUpperCase(),t,s=[],r;if(this.matchTextSeq(["HISTOGRAM","ON"])){s=this.parseCsv(this.parseColumnReference.bind(this));let i=[];for(;this.match("with");)if(this.matchTexts(["SYNC","ASYNC"]))this.matchTextSeq("MODE",{advance:!1})&&(i.push(`${(this.prev?.text??"").toUpperCase()} MODE`),this.advance());else{let o=this.parseNumber();this.matchTextSeq("BUCKETS")&&i.push(`${o} BUCKETS`)}0<i.length&&(t=this.expression(uu,{expressions:i})),this.matchTexts(["MANUAL","AUTO"])&&this.match("update",{advance:!1})?(r=(this.prev?.text??"").toUpperCase(),this.advance()):this.matchTextSeq(["USING","DATA"])&&(t=this.expression(gu,{this:this.parseString()}))}return this.expression(lC,{this:e,expressions:s,expression:t,updateOptions:r})}parseMerge(){this.match("into");let e=this.parseTable();e&&this.match("alias",{advance:!1})&&e.setArgKey("alias",this.parseTableAlias()),this.match("using");let t=this.parseTable();return this.expression(YA,{this:e,using:t,on:(this.match("on")||void 0)&&this.parseDisjunction(),usingCond:(this.match("using")||void 0)&&this.parseUsingIdentifiers(),whens:this.parseWhenMatched(),returning:this.parseReturning()})}parseWhenMatched(){let e=[];for(;this.match("when");){let t=!this.match("not");this.matchTextSeq("MATCHED");let s=this.matchTextSeq(["BY","TARGET"])?!1:this.matchTextSeq(["BY","SOURCE"]),r=this.match("and")?this.parseDisjunction():void 0;this.match("then");let i;if(this.match("insert")){let o=this.parseStar();o?i=this.expression(es,{this:o}):i=this.expression(es,{this:this.matchTextSeq("ROW")?Q("ROW"):this.parseValue({values:!1}),expression:this.matchTextSeq("VALUES")&&this.parseValue()})}else if(this.match("update")){let o=this.parseStar();o?i=this.expression(us,{expressions:o}):i=this.expression(us,{expressions:this.match("set")&&this.parseCsv(this.parseEquality.bind(this))})}else this.match("delete")?i=this.expression(Ve,{this:this.prev?.text??""}):i=this.parseVarFromOptions(this._constructor.CONFLICT_ACTIONS);e.push(this.expression(_n,{matched:t,source:s,condition:r,then:i}))}return this.expression(Au,{expressions:e})}parseShow(){let e=this.findParser(this._constructor.SHOW_PARSERS,this._constructor.SHOW_TRIE);return e?e.call(this):this.parseAsCommand(this.prev)}parseSetItemAssignment(e={}){let{kind:t}=e,s=this.index;if((t==="GLOBAL"||t==="SESSION")&&this.matchTextSeq("TRANSACTION"))return this.parseSetTransaction({global:t==="GLOBAL"});let r=this.parsePrimary()||this.parseColumn(),i=this.matchTexts(this._constructor.SET_ASSIGNMENT_DELIMITERS)||void 0;if(!r||this._constructor.SET_REQUIRES_ASSIGNMENT_DELIMITER&&!i){this.retreat(s);return}let o=this.parseStatement()||this.parseIdVar();(o instanceof $||o instanceof F)&&(o=Q(o.name));let c=this.expression(Me,{this:r,expression:o});return this.expression(Xl,{this:c,kind:t})}parseSetTransaction(e={}){let{global:t=!1}=e;this.matchTextSeq("TRANSACTION");let s=this.parseCsv(()=>this.parseVarFromOptions(this._constructor.TRANSACTION_CHARACTERISTICS));return this.expression(Xl,{expressions:s,kind:"TRANSACTION",global:t})}parseSetItem(){let e=this.findParser(this._constructor.SET_PARSERS,this._constructor.SET_TRIE);return e?e.call(this):this.parseSetItemAssignment({kind:void 0})}parseSet(e={}){let{unset:t=!1,tag:s=!1}=e,r=this.index,i=this.expression(Zl,{expressions:this.parseCsv(this.parseSetItem.bind(this)),unset:t,tag:s});return this.curr?(this.retreat(r),this.parseAsCommand(this.prev)):i}parseVarFromOptions(e,t={}){let{raiseUnmatched:s=!0}=t,r=this.curr;if(!r)return;let i=r.text.toUpperCase(),o=e[i],c=this.index;this.advance();let p=!1;for(let u of o||[]){let h=typeof u=="string"?[u]:u;if(this.matchTextSeq(h)){i=`${i} ${h.join(" ")}`,p=!0;break}}if(!p&&(o===void 0||0<o.length)){s&&this.raiseError(`Unknown option ${i}`),this.retreat(c);return}return Q(i)}parseCache(){let e=this.matchTextSeq("LAZY")||void 0;this.match("table");let t=this.parseTable({schema:!0}),s=[];if(this.matchTextSeq("OPTIONS")){this.matchLParen();let r=this.parseString();r||this.raiseError("Expected option key"),this.match("eq");let i=this.parseString();i||this.raiseError("Expected option value"),s=[r,i].filter(Boolean),this.matchRParen()}return this.match("alias"),this.expression(ny,{this:t,lazy:e,options:s,expression:this.parseSelect({nested:!0})})}parsePartition(){if(this.matchTexts(this._constructor.PARTITION_KEYWORDS))return this.expression($y,{subpartition:(this.prev?.text??"").toUpperCase()==="SUBPARTITION",expressions:this.parseWrappedCsv(this.parseDisjunction.bind(this))})}parseValue(e){let t=n(()=>this._dialectConstructor.SUPPORTS_VALUES_DEFAULT&&this.match("default")?Q((this.prev?.text??"").toUpperCase()):this.parseExpression(),"parseValueExpression");if(this.match("lParen")){let r=this.parseCsv(t);return this.matchRParen(),this.expression(Ze,{expressions:r})}let s=this.parseExpression();if(s)return this.expression(Ze,{expressions:[s]})}parseProjections(){return[this.parseExpressions(),void 0]}parseWrappedSelect(e={}){let{table:t=!1}=e,s;if(this.matchSet(["pivot","unpivot"]))s=this.parseSimplifiedPivot({isUnpivot:this.prev?.tokenType==="unpivot"});else if(this.match("from")){let r=this.parseFrom({skipFromToken:!0,consumePipe:!0}),i=this.parseSelect({from:r});i?(i.args.from||i.setArgKey("from",r),s=i):(s=Ye("*").from(r),s=this.parseQueryModifiers(this.parseSetOperations(s)))}else{if(s=t?this.parseTable({consumePipe:!0}):this.parseSelect({nested:!0,parseSetOperation:!1}),t&&s instanceof tr&&s.alias){let r=s.args.alias?.pop();s=new W({this:s,alias:r})}s=this.parseQueryModifiers(this.parseSetOperations(s))}return s}parseCommitOrRollback(){let e,t,s=this.prev?.tokenType==="rollback";return this.matchTexts(["TRANSACTION","WORK"]),this.matchTextSeq("TO")&&(this.matchTextSeq("SAVEPOINT"),t=this.parseIdVar()),this.match("and")&&(e=!this.matchTextSeq("NO"),this.matchTextSeq("CHAIN")),s?this.expression(cC,{savepoint:t}):this.expression(oC,{chain:e})}parseRefresh(){let e;this.match("table")?e="TABLE":this.matchTextSeq(["MATERIALIZED","VIEW"])?e="MATERIALIZED VIEW":e="";let t=this.parseString()||this.parseTable();return!e&&!(t instanceof I)?this.parseAsCommand(this.prev):this.expression(oy,{this:t,kind:e})}parseColumnDefWithExists(){let e=this.index;this.match("column");let t=this.parseExists({not:!0}),s=this.parseFieldDef();if(!(s instanceof Pe)){this.retreat(e);return}return s.setArgKey("exists",t),s}parseAddColumn(){if((this.prev?.text??"").toUpperCase()==="ADD")return this.parseColumnDefWithExists()??void 0}parseDropColumn(){let e=(this.match("drop")||void 0)&&this.parseDrop();return e&&!(e instanceof $r)&&e.setArgKey("kind",e.args.kind||"COLUMN"),e}parseDropPartition(e={}){let{exists:t}=e;return this.expression(dC,{expressions:this.parseCsv(this.parsePartition.bind(this)),exists:t})}parseAlterTableAdd(){let e=n(()=>{if(this.matchTextSeq("ADD"),this.matchSet(this._constructor.ADD_CONSTRAINT_TOKENS,{advance:!1}))return this.expression(IA,{expressions:this.parseCsv(this.parseConstraint.bind(this))});let t=this.parseAddColumn();if(t instanceof Pe)return t;let s=this.parseExists({not:!0});if(this.matchPair("partition","lParen",{advance:!1}))return this.expression(AC,{exists:s,this:this.parseField({anyToken:!0}),location:this.matchTextSeq("LOCATION",{advance:!1})&&this.parseProperty()})},"parseAddAlteration");if(this.matchTexts(["CHECK"],{advance:!1}))return[this.expression(IA,{expressions:this.parseCsv(this.parseConstraint.bind(this))})];if(!this.matchSet(this._constructor.ADD_CONSTRAINT_TOKENS,{advance:!1})&&(!this._dialectConstructor.ALTER_TABLE_ADD_REQUIRED_FOR_EACH_COLUMN||this.matchTextSeq("COLUMNS"))){let t=this.parseSchema();return t?Array.from(J(t)):this.parseCsv(this.parseColumnDefWithExists.bind(this))}return this.parseCsv(e)}parseAlterTableAlter(){if(this.matchTexts(Object.keys(this._constructor.ALTER_ALTER_PARSERS)))return this._constructor.ALTER_ALTER_PARSERS[(this.prev?.text??"").toUpperCase()]?.call(this);this.match("column");let e=this.parseField({anyToken:!0});return this.matchPair("drop","default")?this.expression(ms,{this:e,drop:!0}):this.matchPair("set","default")?this.expression(ms,{this:e,default:this.parseDisjunction()}):this.match("comment")?this.expression(ms,{this:e,comment:this.parseString()}):this.matchTextSeq(["DROP","NOT","NULL"])?this.expression(ms,{this:e,drop:!0,allowNull:!0}):this.matchTextSeq(["SET","NOT","NULL"])?this.expression(ms,{this:e,allowNull:!1}):this.matchTextSeq(["SET","VISIBLE"])?this.expression(ms,{this:e,visible:"VISIBLE"}):this.matchTextSeq(["SET","INVISIBLE"])?this.expression(ms,{this:e,visible:"INVISIBLE"}):(this.matchTextSeq(["SET","DATA"]),this.matchTextSeq("TYPE"),this.expression(ms,{this:e,dtype:this.parseTypes(),collate:this.match("collate")&&this.parseTerm(),using:this.match("using")&&this.parseDisjunction()}))}parseAlterDiststyle(){return this.matchTexts(["ALL","EVEN","AUTO"])?this.expression(SA,{this:Q((this.prev?.text??"").toUpperCase())}):(this.matchTextSeq(["KEY","DISTKEY"]),this.expression(SA,{this:this.parseColumn()}))}parseAlterSortkey(e={}){let{compound:t}=e;return t&&this.matchTextSeq("SORTKEY"),this.match("lParen",{advance:!1})?this.expression(RA,{expressions:this.parseWrappedIdVars(),compound:t}):(this.matchTexts(["AUTO","NONE"]),this.expression(RA,{this:Q((this.prev?.text??"").toUpperCase()),compound:t}))}parseAlterTableDrop(){let e=this.index-1,t=this.parseExists();return this.match("partition",{advance:!1})?this.parseCsv(()=>this.parseDropPartition({exists:t})):(this.retreat(e),this.parseCsv(this.parseDropColumn.bind(this)))}parseAlterTableRename(){if(this.match("column")||!this._constructor.ALTER_RENAME_REQUIRES_COLUMN){let e=this.parseExists(),t=this.parseColumn(),s=this.matchTextSeq("TO")||void 0,r=this.parseColumn();return!t||!s||!r?void 0:this.expression(FA,{this:t,to:r,exists:e})}return this.matchTextSeq("TO"),this.expression(Yn,{this:this.parseTable({schema:!0})})}parseLoad(){if(this.matchTextSeq("DATA")){let e=this.matchTextSeq("LOCAL")||void 0;this.matchTextSeq("INPATH");let t=this.parseString(),s=this.match("overwrite")||void 0;return this.matchPair("into","table"),this.expression(By,{this:this.parseTable({schema:!0}),local:e,overwrite:s,inpath:t,partition:this.parsePartition(),inputFormat:this.matchTextSeq("INPUTFORMAT")&&this.parseString(),serde:this.matchTextSeq("SERDE")&&this.parseString()})}return this.parseAsCommand(this.prev)}parseDelete(){let e;this.match("from",{advance:!1})||(e=this.parseCsv(this.parseTable.bind(this))||void 0);let t=this.parseReturning();return this.expression(Gr,{tables:e,this:this.match("from")&&this.parseTable({joins:!0}),using:this.match("using")&&this.parseCsv(()=>this.parseTable({joins:!0})),cluster:this.match("on")&&this.parseOnProperty(),where:this.parseWhere(),returning:t||this.parseReturning(),order:this.parseOrder(),limit:this.parseLimit()})}parseUpdate(){let e={this:this.parseTable({joins:!0,aliasTokens:this._constructor.UPDATE_ALIAS_TOKENS})};for(;this.curr;)if(this.match("set"))e.expressions=this.parseCsv(this.parseEquality.bind(this));else if(this.match("returning",{advance:!1}))e.returning=this.parseReturning();else if(this.match("from",{advance:!1})){let t=this.parseFrom({joins:!0}),s=t?.args.this;if(s instanceof he&&this.match("join",{advance:!1})){let r=this.parseJoins();s.setArgKey("joins",0<r.length?r:void 0)}e.from=t}else if(this.match("where",{advance:!1}))e.where=this.parseWhere();else if(this.match("orderBy",{advance:!1}))e.order=this.parseOrder();else if(this.match("limit",{advance:!1}))e.limit=this.parseLimit();else break;return this.expression(us,e)}parseUse(){return this.expression(CC,{kind:this.parseVarFromOptions(this._constructor.USABLES,{raiseUnmatched:!1}),this:this.parseTable({schema:!1})})}parseUncache(){return this.match("table")||this.raiseError("Expecting TABLE after UNCACHE"),this.expression(ay,{exists:this.parseExists(),this:this.parseTable({schema:!0})})}parseAsCommand(e){for(;this.curr;)this.advance();let t=this.findSql(e,this.prev),s=e?.text.length||0;return this.warnUnsupported(),new $r({this:t.substring(0,s),expression:t.substring(s)})}parseDictProperty(e){let t=[];this.matchLParen();let s=this.parseIdVar();if(this.match("lParen")){for(;;){let r=this.parseIdVar(),i=this.parsePrimary();if(!r&&!i)break;t.push(this.expression(GC,{this:r,value:i}))}this.match("rParen")}return this.matchRParen(),this.expression(Hu,{this:e.this,kind:s?.args.this,settings:t})}parseDictRange(e){this.matchLParen();let t=this.matchTextSeq("MIN")||void 0,s,r;return t?(s=this.parseVar()||this.parsePrimary(),s||this.raiseError("Expected MIN value"),this.matchTextSeq("MAX"),r=this.parseVar()||this.parsePrimary(),r||this.raiseError("Expected MAX value")):(r=this.parseVar()||this.parsePrimary(),r||this.raiseError("Expected MAX value"),s=I.number(0)),this.matchRParen(),this.expression(_u,{this:e.this,min:s,max:r})}parseComprehension(e){let t=this.index,s=this.parseColumn(),r=(this.match("comma")||void 0)&&this.parseColumn();if(!this.match("in")){this.retreat(t-1);return}let i=this.parseColumn(),o=this.matchTextSeq("IF")?this.parseDisjunction():void 0;return this.expression(my,{this:e,expression:s,position:r,iterator:i,condition:o})}parseHeredoc(){if(this.match("heredocString"))return this.expression(fA,{this:this.prev?.text??""});if(!this.matchTextSeq("$"))return;let e=["$"],t;this.isConnected()?(this.advance(),e.push((this.prev?.text??"").toUpperCase())):this.raiseError("No closing $ found"),e[e.length-1]!=="$"&&(this.isConnected()&&this.matchTextSeq("$")?(t=e[e.length-1],e.push("$")):this.raiseError("No closing $ found"));let s=this.curr;for(;this.curr;){if(this.matchTextSeq(e,{advance:!1})){let r=this.findSql(s,this.prev);return this.advance(e.length),this.expression(fA,{this:r,tag:t})}this.advance()}this.raiseError(`No closing ${e.join("")} found`)}findParser(e,t){if(!this.curr)return;let s=this.index,r=[];for(;;){let i=this.curr.text.toUpperCase(),o=i.split(" ");r.push(i),this.advance();let[c,p]=Nn(t,o);if(t=p,c===0)break;if(c===2)return e[r.join(" ")]}this.retreat(s)}parseGroupConcat(){let e=n((i,o)=>{if(i instanceof et&&1<(i.args.expressions?.length??0)){let c=[this.expression($t,{expressions:i.args.expressions,safe:!0,coalesce:this._dialectConstructor.CONCAT_COALESCE})];return i.setArgKey("expressions",c),i}return o.length===1?o[0]:this.expression($t,{expressions:o,safe:!0,coalesce:this._dialectConstructor.CONCAT_COALESCE})},"concatExprs"),t=this.parseCsv(this.parseLambda.bind(this)),s;if(t){let i=t[t.length-1],o=i instanceof ye?i:void 0;o?.args.this&&(t[t.length-1]=o.args.this,o.setArgKey("this",e(o.args.this,t))),s=o||e(t[0],t)}else s=void 0;let r=this.match("separator")?this.parseField():void 0;return this.expression(sr,{this:s,separator:r})}parseInitcap(){let e=Th.fromArgList(this.parseFunctionArgs());return e.args.expression||e.setArgKey("expression",I.string(this._dialectConstructor.INITCAP_DEFAULT_DELIMITER_CHARS)),e}parseOperator(e){let t=e;for(;this.match("lParen");){let s="";for(;this.curr&&!this.match("rParen");)s+=this.curr.text,this.advance();if(t=this.expression(ch,{comments:this.prevComments,this:t,operator:s,expression:this.parseBitwise()}),!this.match("operator"))break}return t}buildPipeCte(e){let{query:t,expressions:s,aliasCte:r}=e,i;r?i=r:(this.pipeCteCounter+=1,i=`__tmp${this.pipeCteCounter}`);let c=t.args.with?.pop(),p=Ye(...s,{copy:!1}).from(i,{copy:!1});return c&&p.setArgKey("with",c),p.with(i,t,{copy:!1})}parsePipeSyntaxSelect(e){let t=this.parseSelect({consumePipe:!1});return t?this.buildPipeCte({query:e.select(t.args.expressions,{append:!1}),expressions:[new Ne({})]}):e}parsePipeSyntaxLimit(e){let t=this.parseLimit(),s=this.parseOffset();if(t){let r=e.args.limit||t,i;if(typeof r=="number")i=r;else{re(r,Dt);let c=r.args.expression;re(c,d),i=c.toValue()}(t.args.expression?.toValue()??0)<=i&&e.limit(t,{copy:!1})}if(s){let r=e.args.offset,i;if(r===void 0)i=0;else if(typeof r=="number")i=r;else{re(r,Cn);let p=r.args.expression;i=typeof p=="number"?p:(re(p,d),p.toValue())}let o=s.args.expression,c=typeof o=="number"?o:(re(o,d),o.toValue());e.offset(I.number(i+c),{copy:!1})}return e}parsePipeSyntaxAggregateFields(){let e=this.parseDisjunction();return this.matchTextSeq(["GROUP","AND"],{advance:!1})?e:(e=this.parseAlias(e),this.matchSet(["asc","desc"],{advance:!1})?this.parseOrdered(()=>e):e)}parsePipeSyntaxAggregateGroupOrderBy(e,t={}){let{groupByExists:s=!0}=t,r=this.parseCsv(this.parsePipeSyntaxAggregateFields.bind(this)),i=[],o=[];for(let c of r){let p;c instanceof hs?(p=c.args.this,p instanceof Oe&&c.setArgKey("this",p.args.alias),o.push(c)):p=c,p&&i.push(p)}return s?e.select(i,{copy:!1}).groupBy(i.map(c=>c.args.alias||c),{copy:!1}):e.select(i,{append:!1,copy:!1}),0<o.length?e.orderBy(o,{append:!1,copy:!1}):e}parsePipeSyntaxAggregate(e){return this.matchTextSeq("AGGREGATE"),e=this.parsePipeSyntaxAggregateGroupOrderBy(e,{groupByExists:!1}),(this.match("groupBy")||this.matchTextSeq(["GROUP","AND"])&&this.match("orderBy"))&&(e=this.parsePipeSyntaxAggregateGroupOrderBy(e)),this.buildPipeCte({query:e,expressions:[new Ne({})]})}parsePipeSyntaxSetOperator(e){if(!e)return;let t=this.parseSetOperation(e);if(!t)return;let s=n(()=>{let c=this.parseParen();return c?c.assertIs(he).unnest():void 0},"parseAndUnwrapQuery");t.args.this?.pop();let r=[t.args.expression?.pop().assertIs(he).unnest(),...this.parseCsv(s)];e=this.buildPipeCte({query:e,expressions:[new Ne({})]});let o=e.args.with?.pop();if(t instanceof or?e=e.union(r,{copy:!1,...t.args}):t instanceof cr?e=e.except(r,{copy:!1,...t.args}):e=e.intersect(r,{copy:!1,...t.args}),!!e)return e.setArgKey("with",o),this.buildPipeCte({query:e,expressions:[new Ne({})]})}parsePipeSyntaxJoin(e){if(!e)return;let t=this.parseJoin();if(t)return e instanceof se?e.join(t,{copy:!1}):e}parsePipeSyntaxPivot(e){let t=this.parsePivots();if(!t)return e;let s=e.args.from;if(s){let r=s.args.this;Y(r,d)&&r.setArgKey("pivots",t)}return this.buildPipeCte({query:e,expressions:[new Ne({})]})}parsePipeSyntaxExtend(e){return this.matchTextSeq("EXTEND"),e.select([new Ne({}),...this.parseExpressions()],{append:!1,copy:!1}),this.buildPipeCte({query:e,expressions:[new Ne({})]})}parsePipeSyntaxTablesample(e){let t=this.parseTableSample(),s=e.args.with;if(s){let r=s.args.expressions?.[s.args.expressions.length-1];r instanceof d&&r.args.this instanceof d&&r.args.this.setArgKey("sample",t)}else e.setArgKey("sample",t);return e}parsePipeSyntaxQuery(e){let t=e;for(t instanceof he&&(t=Ye("*").from(t,{copy:!1})),t.args.from||(t=Ye("*").from(t.subquery(void 0,{copy:!1}),{copy:!1}));this.match("pipeGt");){let s=this.curr,r=s?this.tokens.indexOf(s):-1,i=this._constructor.PIPE_SYNTAX_TRANSFORM_PARSERS[this.curr?.text.toUpperCase()??""];if(i)t=i.call(this,t);else{let o=this.parsePipeSyntaxSetOperator(t);if(o=o||this.parsePipeSyntaxJoin(t),!o&&0<=r){this.retreat(r),this.raiseError(`Unsupported pipe syntax operator: '${s?.text.toUpperCase()}'.`);break}t=o}}return t}parseDeclareitem(){this.matchTexts(["VAR","VARIABLE"]);let e=this.parseCsv(this.parseIdVar.bind(this));if(!e)return;this.match("alias");let t=this.match("table")?this.parseSchema():this.parseTypes(),s=(this.match("default")||this.match("eq"))&&this.parseBitwise();return this.expression(xy,{this:e,kind:t,default:s})}parseDeclare(){let e=this.prev,t=this.matchTextSeq(["OR","REPLACE"]),s=this.tryParse(()=>this.parseCsv(this.parseDeclareitem.bind(this)));return!s||this.curr?this.parseAsCommand(e):this.expression(dy,{expressions:s,replace:t||void 0})}buildCast(e){let{strict:t}=e,s=t?z:Gt,r={...e};return delete r.strict,s===Gt&&(r.requiresString=this._dialectConstructor.TRY_CAST_REQUIRES_STRING),this.expression(s,r)}parseJsonValue(){let e=this.parseBitwise();this.match("comma");let t=this.parseBitwise(),s=(this.match("returning")||void 0)&&this.parseType();return this.expression(NC,{this:e,path:this.dialect.toJsonPath(t),returning:s,onCondition:this.parseOnCondition()})}validateExpression(e,t){if(this.errorLevel!==0)for(let s of e.errorMessages(t))this.raiseError(s);return e}get _constructor(){return this.constructor}get _dialectConstructor(){return this.dialect._constructor}};B=Ft(null),R(B,10,"FUNCTIONS",MH,S),R(B,10,"NO_PAREN_FUNCTIONS",wH,S),R(B,10,"STRUCT_TYPE_TOKENS",LH,S),R(B,10,"NESTED_TYPE_TOKENS",PH,S),R(B,10,"ENUM_TYPE_TOKENS",bH,S),R(B,10,"AGGREGATE_TYPE_TOKENS",CH,S),R(B,10,"TYPE_TOKENS",yH,S),R(B,10,"SIGNED_TO_UNSIGNED_TYPE_TOKEN",IH,S),R(B,10,"SUBQUERY_PREDICATES",NH,S),R(B,10,"SUBQUERY_TOKENS",mH,S),R(B,10,"RESERVED_TOKENS",OH,S),R(B,10,"DB_CREATABLES",RH,S),R(B,10,"CREATABLES",SH,S),R(B,10,"ALTERABLES",TH,S),R(B,10,"ID_VAR_TOKENS",fH,S),R(B,10,"TABLE_ALIAS_TOKENS",xH,S),R(B,10,"ALIAS_TOKENS",dH,S),R(B,10,"COLON_PLACEHOLDER_TOKENS",AH,S),R(B,10,"ARRAY_CONSTRUCTORS",EH,S),R(B,10,"COMMENT_TABLE_ALIAS_TOKENS",gH,S),R(B,10,"UPDATE_ALIAS_TOKENS",hH,S),R(B,10,"TRIM_TYPES",uH,S),R(B,10,"TABLE_FAST_TERMINATORS",lH,S),R(B,10,"FUNC_TOKENS",pH,S),R(B,10,"CONJUNCTION",cH,S),R(B,10,"ASSIGNMENT",oH,S),R(B,10,"DISJUNCTION",aH,S),R(B,10,"EQUALITY",nH,S),R(B,10,"COMPARISON",iH,S),R(B,10,"BITWISE",rH,S),R(B,10,"TERM",sH,S),R(B,10,"FACTOR",tH,S),R(B,10,"EXPONENT",eH,S),R(B,10,"TIMES",KV,S),R(B,10,"TIMESTAMPS",ZV,S),R(B,10,"SET_OPERATIONS",QV,S),R(B,10,"JOIN_METHODS",zV,S),R(B,10,"JOIN_SIDES",JV,S),R(B,10,"JOIN_KINDS",XV,S),R(B,10,"LAMBDAS",jV,S),R(B,10,"COLUMN_OPERATORS",WV,S),R(B,10,"CAST_COLUMN_OPERATORS",_V,S),R(B,10,"EXPRESSION_PARSERS",HV,S),R(B,10,"STATEMENT_PARSERS",VV,S),R(B,10,"UNARY_PARSERS",YV,S),R(B,10,"STRING_PARSERS",GV,S),R(B,10,"NUMERIC_PARSERS",$V,S),R(B,10,"PRIMARY_PARSERS",BV,S),R(B,10,"PLACEHOLDER_PARSERS",FV,S),R(B,10,"RANGE_PARSERS",vV,S),R(B,10,"PIPE_SYNTAX_TRANSFORM_PARSERS",UV,S),R(B,10,"PROPERTY_PARSERS",qV,S),R(B,10,"CONSTRAINT_PARSERS",DV,S),R(B,10,"ALTER_PARSERS",kV,S),R(B,10,"NO_PAREN_FUNCTION_PARSERS",MV,S),R(B,10,"INVALID_FUNC_NAME_TOKENS",wV,S),R(B,10,"KEY_VALUE_DEFINITIONS",LV,S),R(B,10,"FUNCTION_PARSERS",PV,S),R(B,10,"QUERY_MODIFIER_PARSERS",bV,S),R(B,10,"QUERY_MODIFIER_TOKENS",CV,S),R(B,10,"TYPE_LITERAL_PARSERS",yV,S),R(B,10,"TYPE_CONVERTERS",IV,S),R(B,10,"DDL_SELECT_TOKENS",NV,S),R(B,10,"PRE_VOLATILE_TOKENS",mV,S),R(B,10,"OPTYPE_FOLLOW_TOKENS",OV,S),R(B,10,"TABLE_INDEX_HINT_TOKENS",RV,S),R(B,10,"WINDOW_ALIAS_TOKENS",SV,S),R(B,10,"WINDOW_BEFORE_PAREN_TOKENS",TV,S),R(B,10,"JSON_KEY_VALUE_SEPARATOR_TOKENS",fV,S),R(B,10,"FETCH_TOKENS",xV,S),R(B,10,"ADD_CONSTRAINT_TOKENS",dV,S),R(B,10,"DISTINCT_TOKENS",AV,S),R(B,10,"UNNEST_OFFSET_ALIAS_TOKENS",EV,S),R(B,10,"SELECT_START_TOKENS",gV,S),R(B,10,"PRIVILEGE_FOLLOW_TOKENS",hV,S),R(B,10,"AMBIGUOUS_ALIAS_TOKENS",uV,S),R(B,10,"MODIFIABLES",lV,S),It(B,S),yt(B,3,S),n(S,"Parser"),S._showTrie=void 0,S._setTrie=void 0,S.FAST_COLUMN_TOKENS=new Set(["var","identifier"]),S.BRACKETS=new Set(["lBracket","lBrace"]),S.COLUMN_POSTFIX_TOKENS=new Set(["lParen","lBracket","lBrace","colon","joinMarker"]),S.TABLE_POSTFIX_TOKENS=new Set(["lParen","lBracket","lBrace","pivot","unpivot","tableSample"]),S.JOIN_HINTS=new Set,S.TYPED_LAMBDA_ARGS=!1,S.LAMBDA_ARG_TERMINATORS=new Set(["comma","rParen"]),S.ALTER_ALTER_PARSERS={DISTKEY:n(function(){return this.parseAlterDiststyle()},"DISTKEY"),DISTSTYLE:n(function(){return this.parseAlterDiststyle()},"DISTSTYLE"),SORTKEY:n(function(){return this.parseAlterSortkey()},"SORTKEY"),COMPOUND:n(function(){return this.parseAlterSortkey({compound:!0})},"COMPOUND")},S.SCHEMA_UNNAMED_CONSTRAINTS=new Set(["CHECK","EXCLUDE","FOREIGN KEY","LIKE","PERIOD","PRIMARY KEY","UNIQUE","BUCKET","TRUNCATE"]),S.FUNCTIONS_WITH_ALIASED_ARGS=new Set(["STRUCT"]),S.SET_PARSERS={GLOBAL:n(function(){return this.parseSetItemAssignment({kind:"GLOBAL"})},"GLOBAL"),LOCAL:n(function(){return this.parseSetItemAssignment({kind:"LOCAL"})},"LOCAL"),SESSION:n(function(){return this.parseSetItemAssignment({kind:"SESSION"})},"SESSION"),TRANSACTION:n(function(){return this.parseSetTransaction()},"TRANSACTION")},S.SHOW_PARSERS={},S.TRANSACTION_KIND=new Set(["DEFERRED","IMMEDIATE","EXCLUSIVE"]),S.TRANSACTION_CHARACTERISTICS={ISOLATION:[["LEVEL","REPEATABLE","READ"],["LEVEL","READ","COMMITTED"],["LEVEL","READ","UNCOMITTED"],["LEVEL","SERIALIZABLE"]],READ:["WRITE","ONLY"]},S.CONFLICT_ACTIONS={...Object.fromEntries(["ABORT","FAIL","IGNORE","REPLACE","ROLLBACK","UPDATE"].map(e=>[e,[]])),DO:["NOTHING","UPDATE"]},S.TRIGGER_TIMING={INSTEAD:[["OF"]],BEFORE:[],AFTER:[]},S.TRIGGER_FOR_EACH={ROW:[],STATEMENT:[]},S.TRIGGER_DEFERRABLE={NOT:[["DEFERRABLE"]],DEFERRABLE:[]},S.TRIGGER_INITIALLY_VALUE={IMMEDIATE:[],DEFERRED:[]},S.CREATE_SEQUENCE={SCALE:["EXTEND","NOEXTEND"],ShaRD:["EXTEND","NOEXTEND"],NO:["CYCLE","CACHE","MAXVALUE","MINVALUE"],...Object.fromEntries(["SESSION","GLOBAL","KEEP","NOKEEP","ORDER","NOORDER","NOCACHE","CYCLE","NOCYCLE","NOMINVALUE","NOMAXVALUE","NOSCALE","NOSHARD"].map(e=>[e,[]]))},S.ISOLATED_LOADING_OPTIONS={FOR:["ALL","INSERT","NONE"]},S.USABLES=Object.fromEntries(["ROLE","WAREHOUSE","DATABASE","SCHEMA","CATALOG"].map(e=>[e,[]])),S.CAST_ACTIONS=Object.fromEntries(["RENAME","ADD"].map(e=>[e,["FIELDS"]])),S.SCHEMA_BINDING_OPTIONS={TYPE:["EVOLUTION"],...Object.fromEntries(["BINDING","COMPENSATION","EVOLUTION"].map(e=>[e,[]]))},S.PROCEDURE_OPTIONS={},S.EXECUTE_AS_OPTIONS=Object.fromEntries(["CALLER","SELF","OWNER"].map(e=>[e,[]])),S.KEY_CONSTRAINT_OPTIONS={NOT:["ENFORCED"],MATCH:["FULL","PARTIAL","SIMPLE"],INITIALLY:["DEFERRED","IMMEDIATE"],USING:["BTREE","HASH"],...Object.fromEntries(["DEFERRABLE","NORELY","RELY"].map(e=>[e,[]]))},S.WINDOW_EXCLUDE_OPTIONS={NO:["OTHERS"],CURRENT:["ROW"],...Object.fromEntries(["GROUP","TIES"].map(e=>[e,[]]))},S.INSERT_ALTERNATIVES=new Set(["ABORT","FAIL","IGNORE","REPLACE","ROLLBACK"]),S.CLONE_KEYWORDS=new Set(["CLONE","COPY"]),S.HISTORICAL_DATA_PREFIX=new Set(["AT","BEFORE","END"]),S.HISTORICAL_DATA_KIND=new Set(["OFFSET","STATEMENT","STREAM","TIMESTAMP","VERSION"]),S.OPCLASS_FOLLOW_KEYWORDS=new Set(["ASC","DESC","NULLS","WITH"]),S.VIEW_ATTRIBUTES=new Set(["ENCRYPTION","SCHEMABINDING","VIEW_METADATA"]),S.WINDOW_SIDES=new Set(["FOLLOWING","PRECEDING"]),S.COPY_INTO_VARLEN_OPTIONS=new Set(["FILE_FORMAT","COPY_OPTIONS","FORMAT_OPTIONS","CREDENTIAL"]),S.IS_JSON_PREDICATE_KIND=new Set(["VALUE","SCALAR","ARRAY","OBJECT"]),S.ODBC_DATETIME_LITERALS={},S.ON_CONDITION_TOKENS=new Set(["ERROR","NULL","TRUE","FALSE","EMPTY"]),S.DESCRIBE_STYLES=new Set(["ANALYZE","EXTENDED","FORMATTED","HISTORY"]),S.SET_ASSIGNMENT_DELIMITERS=new Set(["=",":=","TO"]),S.ANALYZE_STYLES=new Set(["BUFFER_USAGE_LIMIT","FULL","LOCAL","NO_WRITE_TO_BINLOG","SAMPLE","SKIP_LOCKED","VERBOSE"]),S.ANALYZE_EXPRESSION_PARSERS={ALL:n(function(){return this.parseAnalyzeColumns()},"ALL"),COMPUTE:n(function(){return this.parseAnalyzeStatistics()},"COMPUTE"),DELETE:n(function(){return this.parseAnalyzeDelete()},"DELETE"),DROP:n(function(){return this.parseAnalyzeHistogram()},"DROP"),ESTIMATE:n(function(){return this.parseAnalyzeStatistics()},"ESTIMATE"),LIST:n(function(){return this.parseAnalyzeList()},"LIST"),PREDICATE:n(function(){return this.parseAnalyzeColumns()},"PREDICATE"),UPDATE:n(function(){return this.parseAnalyzeHistogram()},"UPDATE"),VALIDATE:n(function(){return this.parseAnalyzeValidate()},"VALIDATE")},S.PARTITION_KEYWORDS=new Set(["PARTITION","SUBPARTITION"]),S.OPERATION_MODIFIERS=new Set,S.RECURSIVE_CTE_SEARCH_KIND=new Set(["BREADTH","DEPTH","CYCLE"]),S.SECURITY_PROPERTY_KEYWORDS=["DEFINER","INVOKER","NONE"],S.STRICT_CAST=!0,S.PREFIXED_PIVOT_COLUMNS=!1,S.IDENTIFY_PIVOT_STRINGS=!1,S.LOG_DEFAULTS_TO_LN=!1,S.TABLESAMPLE_CSV=!1,S.DEFAULT_SAMPLING_METHOD=void 0,S.SET_REQUIRES_ASSIGNMENT_DELIMITER=!0,S.TRIM_PATTERN_FIRST=!1,S.STRING_ALIASES=!1,S.MODIFIERS_ATTACHED_TO_SET_OP=!0,S.SET_OP_MODIFIERS=new Set(["order","limit","offset"]),S.NO_PAREN_IF_COMMANDS=!0,S.JSON_ARROWS_REQUIRE_JSON_TYPE=!1,S.COLON_IS_VARIANT_EXTRACT=!1,S.VALUES_FOLLOWED_BY_PAREN=!0,S.SUPPORTS_IMPLICIT_UNNEST=!1,S.INTERVAL_SPANS=!0,S.SUPPORTS_PARTITION_SELECTION=!1,S.WRAPPED_TRANSFORM_COLUMN_CONSTRAINT=!0,S.OPTIONAL_ALIAS_TOKEN_CTE=!0,S.ALTER_RENAME_REQUIRES_COLUMN=!0,S.ALTER_TABLE_PARTITIONS=!1,S.JOINS_HAVE_EQUAL_PRECEDENCE=!1,S.ZONE_AWARE_TIMESTAMP_CONSTRUCTOR=!1,S.MAP_KEYS_ARE_ARBITRARY_EXPRESSIONS=!1,S.JSON_EXTRACT_REQUIRES_JSON_EXPRESSION=!1,S.ADD_JOIN_ON_TRUE=!1,S.SUPPORTS_OMITTED_INTERVAL_SPAN_UNIT=!1;var iy=S;var kH,DH,CD,xr=class xr extends(DH=Fr,kH=[O],DH){static get KEYWORDS(){return{"..":"dot"}}};CD=Ft(DH),R(CD,10,"KEYWORDS",kH,xr),It(CD,xr),yt(CD,3,xr),n(xr,"JsonPathTokenizer"),xr.SINGLE_TOKENS={"(":"lParen",")":"rParen","[":"lBracket","]":"rBracket",":":"colon",",":"comma","-":"dash",".":"dot","?":"placeholder","@":"parameter","'":"quote",'"':"quote",$:"dollar","*":"star"},xr.IDENTIFIER_ESCAPES=["\\"],xr.STRING_ESCAPES=["\\"],xr.VAR_TOKENS=new Set(["var"]);var VA=xr;var nJ={jsonPathFilter:(a,e)=>`?${e.args.this}`,jsonPathKey:(a,e)=>a.jsonPathKeySql(e),jsonPathRecursive:(a,e)=>`..${e.args.this||""}`,jsonPathRoot:(a,e)=>"$",jsonPathScript:(a,e)=>`(${e.args.this}`,jsonPathSelector:(a,e)=>`[${a.jsonPathPart(e.args.this)}]`,jsonPathSlice:(a,e)=>[e.args.start,e.args.end,e.args.step].filter(s=>s!==void 0).map(s=>s===void 0?"":a.jsonPathPart(s)).join(":"),jsonPathSubscript:(a,e)=>a.jsonPathSubscriptSql(e),jsonPathUnion:(a,e)=>`[${(e.args.expressions??[]).map(t=>a.jsonPathPart(t)).join(",")}]`,jsonPathWildcard:(a,e)=>"*"},bD=new Set([Vs,kt,fr,Qt,Hs,ci,Tr,ts,Sr,qt]);function PD(a,e){let t=ae.getOrRaise(e?.dialect).jsonpathTokenizer(),s=t.tokenize(a),r=s.length,i=0;function o(){return i<r?s[i].tokenType:void 0}n(o,"curr");function c(){return s[i-1]}n(c,"prev");function p(){return i+=1,c()}n(p,"advance");function u(m){return`${m} at index ${i}: ${a}`}n(u,"error");function h(m,C={}){let{raiseUnmatched:q=!1}=C;if(o()===m)return p();if(q)throw new Ke(u(`Expected ${m}`))}n(h,"match");function g(m){let C=o();if(C!==void 0)return m.has(C)?p():void 0}n(g,"matchSet");function x(){let m=h("string")||h("identifier");if(m)return m.text;if(h("star"))return new qt({});if(h("placeholder")||h("lParen")){let U=c().text==="(",_=i;for(;;){h("lBracket")&&T();let Ie=o();if(Ie==="rBracket"||Ie===void 0)break;p()}let ne=U?Hs:Vs,K=s[_].start??0,H=i<r?s[i].end??a.length:a.length;return new ne({this:a.slice(K,H)})}let C=h("dash")?"-":"",q=h("number");return q&&(C+=q.text),C?parseInt(C,10):!1}n(x,"parseLiteral");function f(){let m=x(),C=!!h("colon"),q=C?x():void 0,U=!!h("colon"),_=U?x():void 0;return!C&&!U?m:new Tr({start:m,end:q,step:_})}n(f,"parseSlice");function T(){let m=f();if(typeof m=="string"||m!==!1){let C=[m];for(;h("comma");){let U=f();U!==!1&&C.push(U)}let q;return C.length===1?typeof m=="string"?q=new kt({this:C[0]}):m instanceof Hs||m instanceof Vs?q=new ci({this:C[0]}):q=new ts({this:C[0]}):q=new Sr({expressions:C}),h("rBracket",{raiseUnmatched:!0}),q}else throw new Ke(u("Cannot have empty segment"))}n(T,"parseBracket");function y(){let m=i-2;for(;g(t.constructor.VAR_TOKENS););let C=m<0?0:(s[m].end??0)+1,q;return s.length<=i?q=a.slice(C):q=a.slice(C,s[i].start??a.length),q}n(y,"parseVarText"),h("dollar");let b=[new Qt({})];for(;o();)if(h("dot")||h("colon")){let m=c().text==="..",C;if(g(t.constructor.VAR_TOKENS)?C=y():h("identifier")?C=c().text:h("star")?C=new qt({}):C=void 0,m)b.push(new fr({this:C}));else if(C)b.push(new kt({this:C}));else throw new Ke(u("Expected key name or * after DOT"))}else if(h("lBracket"))b.push(T());else if(g(t.constructor.VAR_TOKENS))b.push(new kt({this:y()}));else if(h("identifier"))b.push(new kt({this:c().text}));else if(h("star"))b.push(new qt({}));else throw new Ke(u(`Unexpected ${s[i].tokenType}`));return new Er({expressions:b})}n(PD,"parse");function SJ(a,e={}){let{dialect:t}=e,s=ae.getOrRaise(t);function r(i){return i=pj(i),i=lj(i,s),i=hj(i,{promoteToInferredDatetimeType:s._constructor.PROMOTE_TO_INFERRED_DATETIME_TYPE}),i=gj(i),i=MD(i,wD),i=Ej(i),i}return n(r,"_canonicalize"),a.transform(r,{copy:!1})}n(SJ,"canonicalize");function pj(a){if(a instanceof we&&a.type instanceof d&&a.type.args.this&&N.TEXT_TYPES.has(a.type.args.this)){let e=a.args.this,t=a.args.expression;return!e||!t?a:new $t({expressions:[e,t],coalesce:!1})}return a}n(pj,"addTextToConcat");function lj(a,e){if(a instanceof pi||a instanceof os){let t=a.args.expressions,s=a instanceof pi?a.args.zone:void 0,r=a.args.this;if(!(t&&Array.isArray(t)&&0<t.length)&&!s&&r){let o=r;if(o.isString&&EA(o.name))return new z({this:r,to:new N({this:"date"})})}}if(a instanceof Lh&&!a.args.zone){let r=a;a.type||(r=Kt(a,{dialect:e}));let i=r.args.this;if(!i)return a;let o=r.type||new N({this:"timestamp"});return o instanceof N?new z({this:i,to:o}):a}return a}n(lj,"replaceDateFuncs");var uj=O(()=>[we,Ce,Me,xt,je,Je,Fe,nt,Ks,Ur]);function hj(a,e={}){let{promoteToInferredDatetimeType:t=!1}=e;if(uj().some(r=>a instanceof r)){let r=a.args.this,i=a.args.expression;r&&i&&qH(r,i,{promoteToInferredDatetimeType:t})}else if(a instanceof Ss){let r=a.args.this,i=a.args.low;r&&i&&qH(r,i,{promoteToInferredDatetimeType:t})}else if(a instanceof lr){let r=a.args.expression;if(r){let i=r;i.type instanceof d&&i.type.args.this&&N.TEMPORAL_TYPES.has(i.type.args.this)||LD(i,"datetime")}}else if(a instanceof ft||a instanceof Xt||a instanceof ls){let r=a.args.this,i=a.args.unit;r&&UH(r,i)}else a instanceof _s&&Aj(a);return a}n(hj,"coerceType");function gj(a){if(a instanceof z){let e=a.args.this,t=a.args.to;if(e&&t){let s=e,r=t;if(s.type&&r.equals(s.type))return s}}if(a instanceof pi||a instanceof os){let e=a.args.this;if(e){let t=e;if(t.type instanceof d&&t.type.args.this==="date"){let s=t.type.args.expressions;if(!(s&&Array.isArray(s)&&0<s.length))return t}}}return a}n(gj,"removeRedundantCasts");function MD(a,e){if(a instanceof Ae){let t=a.args.this,s=a.args.expression;t&&e(t),s&&e(s)}else if(a instanceof Le){let t=a.args.this;t&&e(t)}else if(a instanceof xe){let t=a.parent;if(!(t instanceof ut&&t.args.this)){let r=a.args.this;r&&e(r)}}else if(a instanceof St||a instanceof xs){let t=a.args.this;t&&e(t)}return a}n(MD,"ensureBools");function Ej(a){if(a instanceof hs){let e=a.args;e.desc===!1&&(e.desc=void 0)}return a}n(Ej,"removeAscendingOrder");function qH(a,e,t){let{promoteToInferredDatetimeType:s}=t;for(let[r,i]of[[a,e],[e,a]]){if(i instanceof qe){let h=i.args.unit;UH(r,h)}let o=r.type;if(!o||!(o instanceof d)||!o.args.this||!N.TEMPORAL_TYPES.has(o.args.this))continue;let c=o,p=i.type;if(!p||!(p instanceof d)||!p.args.this||!N.TEXT_TYPES.has(p.args.this))continue;let u;if(s){let h;if(i.isString){let x=i.name;EA(x)?h="date":QI(x)?h="datetime":h=c.args.this}else h="datetime";let g=Yl.COERCES_TO.get(c.args.this);u=g&&g.has(h)?h:c.args.this}else u=c.args.this;u!==c.args.this&&LD(r,u),LD(i,u)}}n(qH,"coerceDate");function UH(a,e){if(!a.type)return a;if(a.type instanceof d&&a.type.args.this&&N.TEXT_TYPES.has(a.type.args.this)){let t=a.name,s=EA(t);if(s&&AA(e))return a.replace(new z({this:a.copy(),to:new N({this:"date"})}));if(s||QI(t))return a.replace(new z({this:a.copy(),to:new N({this:"datetime"})}))}else if(a.type instanceof d&&a.type.args.this==="date"&&!AA(e))return a.replace(new z({this:a.copy(),to:new N({this:"datetime"})}));return a}n(UH,"coerceTimeunitArg");function Aj(a){let e=a.args.this,t=a.args.expression;for(let s of[e,t])if(s){let r=s;r.type instanceof d&&r.type.args.this&&!N.TEMPORAL_TYPES.has(r.type.args.this)&&r.replace(new z({this:r.copy(),to:new N({this:"datetime"})}))}}n(Aj,"coerceDateDiffArgs");function LD(a,e){a.replace(new z({this:a.copy(),to:new N({this:e})}))}n(LD,"replaceCast");function wD(a){if(a instanceof tt){let e=a.args.this;e instanceof d&&wD(e);let t=a.args.expressions;if(t)for(let s of t)s instanceof d&&wD(s)}else a.type instanceof d&&a.type.args.this&&N.INTEGER_TYPES.has(a.type.args.this)&&a.replace(a.neq(0))}n(wD,"replaceIntPredicate");var dj=["on","side","kind","using","method"];function yJ(a){for(let e of a.findAll(se)){let t=Et(e.args.joins??[],fe);if(!vH(t))continue;let s={},r=[];for(let i of t){let o=kD(i);if(0<o.size)for(let c of o)s[c]||(s[c]=[]),s[c].push(i);else r.push([i.aliasOrName,i])}for(let[i,o]of r)for(let c of s[i]??[]){let p=c.args.on;if(p instanceof Ae){if(kD(c).size<2)continue;let u=p.constructor;for(let h of p.flatten())if(wM(h).has(i)){h.replace(We());let g=HA([o.args.on,h],u,{copy:!1});o.on(g,{append:!1,copy:!1})}}}}return a=xj(a),a=fj(a),a}n(yJ,"optimizeJoins");function xj(a){for(let e of a.findAll(rt)){let t=e.parent;if(!t)continue;let s=Et(t.args.joins??[],fe);if(!vH(s))continue;let r=new Map;for(let u of s)r.set(u.aliasOrName,u);let i=new Map;for(let[u,h]of r)i.set(u,kD(h));let o=vY(i),c=e.aliasOrName,p=o.filter(u=>u!==c&&r.has(u)).map(u=>r.get(u));t.setArgKey("joins",p)}return a}n(xj,"reorderJoins");function fj(a){for(let e of a.findAll(fe)){let t=dj.some(r=>e.args[r]!=null),s=e.args;t||(s.kind="cross"),s.kind==="cross"?s.on=void 0:((s.kind==="inner"||s.kind==="outer")&&(s.kind=void 0),!s.on&&!s.using&&(s.on=We()))}return a}n(fj,"normalize");function kD(a){let e=a.args.on;return e?wM(e,{exclude:a.aliasOrName}):new Set}n(kD,"otherTableNames");function vH(a){for(let e of a)if(e.args.side)return!1;return!0}n(vH,"isReorderable");function qJ(a,e){return function(t){let s=t,r=s.constructor;try{for(let c of a)s=c(s)}catch(c){if(c instanceof kr)this.unsupported(c.message);else throw c}if(e)return e.call(this,s);let i=this[`${s._constructor.key}Sql`];if(i instanceof Function)return i.call(this,s);let o=this._constructor.TRANSFORMS.get(s._constructor);if(o){if(r===s.constructor){if(s instanceof E)return this.functionFallbackSql(s);throw new Error(`Expression type ${s.constructor.name} requires a _sql method to be transformed.`)}return o.call(this,s)}throw new Error(`Unsupported expression type ${s.constructor.name}.`)}}n(qJ,"preprocess");function UJ(a){if(a instanceof se){let e=0,t=[];for(let s of a.findAll(Ee)){let r=s.parent;if(!(r instanceof rt||r instanceof fe)||s.args.expressions?.length!==1||!(s.args.expressions[0]instanceof ii))continue;let i=s.args.expressions[0],o=i.args.start,c=i.args.end,p=i.args.step;if(!o||!c||!(p instanceof qe))continue;let u=s.args.alias,h=u instanceof pe?u.columns[0]:void 0,g=Y(h,F)?h:Y(h,d)?h.name:"date_value",x=X(o,"date"),f=new Qe({this:"date_add",expressions:[g,I.number(p.name),p.args.unit||""]}),T=X(f,"date"),y=`_generated_dates${e?`_${e}`:""}`,b=Ye(new Oe({this:x,alias:g})),m=Ye(T).from(y).where(new nt({this:T,expression:X(c,"date")})),C=b.union(m,{distinct:!1});s.replace(Ye(g).from(y).subquery(y)),t.push(Be(new Bt({this:C}),y,{table:[g]})),e++}if(0<t.length){let s=ct(a.args.with,dt)??new dt({expressions:[]});s.setArgKey("recursive",!0),s.setArgKey("expressions",[...t,...s.args.expressions??[]]),a.setArgKey("with",s)}}return a}n(UJ,"unnestGenerateDateArrayUsingRecursiveCte");function vJ(a){let e=a.args.this;if(a instanceof W&&e instanceof As){let t=new Ee({expressions:[e]});return a.args.alias?Be(t,"_u",{table:[a.args.alias instanceof pe?Y(a.args.alias.args.this,F)||typeof a.args.alias.args.this=="string"?a.args.alias.args.this:"":typeof a.args.alias=="string"?a.args.alias:""]}):t}return a}n(vJ,"unnestGenerateSeries");function FJ(a){if(a instanceof se&&a.args.distinct&&a.args.distinct.getArgKey("on")instanceof Ze){let e=En(a.namedSelects,"_row_number"),t=a.args.distinct.pop().getArgKey("on").args.expressions,s=new Ue({this:new yb({}),partitionBy:t}),r=a.args.order;r?s.setArgKey("order",r.pop()):s.setArgKey("order",new ye({expressions:t?.map(c=>c instanceof d?c.copy():c)??[]})),a.select(Be(s,e),{copy:!1});let i=[],o=[e];for(let c of a.selects.slice(0,-1)){if(c.isStar){i=[new Ne];break}let p=c;if(!(p instanceof Oe)){let u=En(o,p.outputName||"_col"),h=p instanceof $&&p.args.this instanceof d?!!p.args.this?.getArgKey("quoted"):void 0;p=p.replace(Be(p,u,{quoted:h}))}o.push(p.outputName),i.push(p.getArgKey("alias"))}return Ye(i).from(a.subquery("_t",{copy:!1})).where(new $({this:e}).eq(1))}return a}n(FJ,"eliminateDistinctOn");function BJ(a){if(a instanceof se&&a.args.qualify){let e=new Set(a.namedSelects);for(let c of a.selects)if(!c.aliasOrName){let p=En(e,"_c");c.replace(Be(c,p)),e.add(p)}let t=n(c=>{let p=c.aliasOrName,u=c.getArgKey("alias")||c.args.this;return u instanceof F?$n({col:p},{quoted:u.args.quoted}):p},"selectAliasOrName"),s=Ye(a.selects.map(t)),r=ct(a.args.qualify.pop().args.this,d),i={};for(let c of a.selects)c instanceof Oe&&(i[c.alias]=c.args.this);let o=a.isStar?[Ue]:[Ue,$];for(let c of[...r?.findAll(o)??[]])if(c instanceof Ue){if(i)for(let h of c.findAll($)){let g=i[h.name];g&&h.replace(g)}let p=En(a.namedSelects,"_w");a.select(Be(c,p),{copy:!1});let u=$n({col:p});c.parent instanceof Xs?r=u:c.replace(u)}else a.namedSelects.includes(c.name)||a.select(c.copy(),{copy:!1});return s.from(a.subquery("_t",{copy:!1}),{copy:!1}).where(r,{copy:!1})}return a}n(BJ,"eliminateQualify");function $J(a){for(let e of a.findAll(N))e.setArgKey("expressions",e.args.expressions?.filter(t=>!(t instanceof Jr)));return a}n($J,"removePrecisionParameterizedTypes");function GJ(a){if(a instanceof se){let e=new Set(Dr(a,[Ee]).filter(t=>t.parent instanceof rt||t.parent instanceof fe).map(t=>t.alias));if(0<e.size)for(let t of a.findAll($)){let s=t.parts[0];s&&s.argKey!=="this"&&s.args&&e.has(s.args.this)&&s.pop()}}return a}n(GJ,"unqualifyUnnest");function YJ(a,e={}){let{unnestUsingArraysZip:t=!0}=e;function s(i,o,c){let{hasMultiExpr:p}=c;if(p){if(!t)throw new kr("Cannot transpile UNNEST with multiple input arrays");let u=[new Qe({this:"ARRAYS_ZIP",expressions:o})];return i.setArgKey("expressions",u),u}return o}n(s,"unnestZipExprs");function r(i,o={}){let{hasMultiExpr:c}=o;return i.args.offset?li:c?Ib:Jt}if(n(r,"getUdtfType"),a instanceof se){let i=a.args.from;if(i&&i.args.this instanceof Ee){let c=i.args.this,p=c.args.alias,u=c.args.expressions,h=1<(u?.length??0),[g]=s(c,u??[],{hasMultiExpr:h}),x=Y(p,pe)?Et(p.columns,F):[],f=c.args.offset;f&&x.unshift(f instanceof F?f:new F({this:"pos",quoted:!1}));let T=r(c,{hasMultiExpr:h});c.replace(new W({this:new T({this:g}),alias:Y(p,pe)?new pe({this:Y(p.args.this,d)||typeof p.args.this=="string"?p.args.this:void 0,columns:x}):void 0}))}let o=a.args.joins||[];for(let c of[...o]){let p=c.args.this,u=p instanceof bt,h=u?p.args.this:p;if(h instanceof Ee){let g=u?p.args.alias:h.args.alias,x=h.args.expressions,f=1<(x?.length??0),T=s(h,x??[],{hasMultiExpr:f});o.splice(o.indexOf(c),1);let y=Y(g,pe)?g:void 0,b=y?Et(y.columns,F):[];if(!f&&b.length!==1&&b.length!==2)throw new kr("CROSS JOIN UNNEST to LATERAL VIEW EXPLODE transformation requires explicit column aliases");let m=h.args.offset;m&&b.unshift(m instanceof F?m:new F({this:"pos",quoted:!1}));let C=r(h,{hasMultiExpr:f});for(let q of T)a.append("laterals",new bt({this:new C({this:q}),view:!0,alias:new pe({this:y&&(Y(y.args.this,d)||typeof y.args.this=="string")?y.args.this:void 0,columns:b})}))}}}return a}n(YJ,"unnestToExplode");function FH(a){let e=a.getArgKey("with");for(let t of a.findAll(dt))if(t.parent!==a)if(!e)e=t.pop(),a.setArgKey("with",e);else{t.recursive&&e.setArgKey("recursive",!0);let s=t.findAncestor(Bt);t.pop();let r=t.args.expressions;if(re(e,dt),s){let i=e.args.expressions?.indexOf(s)??-1;e.args.expressions?.splice(i,0,...Et(r??[],d))}else e.setArgKey("expressions",[...e.args.expressions??[],...Et(r??[],d)])}return a}n(FH,"moveCtesToTopLevel");function VJ(a){if(a instanceof se)for(let e of a.findAll(Tt)){let t=e.args.this;if(t instanceof ee||e.parent instanceof Zt||e.parent instanceof Gs)continue;let s=e.parent;if(s instanceof v){let r=new F({this:"x",quoted:!1});e.replace(r);let i=new ps({this:s.copy(),expressions:[r]});s.replace(new Ys({this:t?.unnest(),expression:i}))}}return a}n(VJ,"anyToExists");function HJ(a=0){return e=>{if(e instanceof se){let t=[...e.namedSelects],r=[...new js({expression:e}).references].map(([h])=>h),i=n((h,g)=>{let x=En(h,g);return h.push(x),x},"newName"),o=[],c=i(t,"pos"),p=i(r,"_u"),u=Be(new Ee({expressions:[new As({start:I.number(a)})]}),p,{table:[c]});for(let h of[...e.selects]){let g=h.find(Jt);if(g){let x,f,T;if(h instanceof Oe){let H=h.getArgKey("alias");f=H instanceof F?H:h.alias,T=h}else if(h instanceof Hn)x=h.aliases[0],f=h.aliases[1],T=h.replace(new Oe({this:h.args.this,alias:""}));else{let H=new Oe({alias:""});h.replace(H),H.setArgKey("this",h),T=H;let Ie=T.find(Jt);Ie&&(g=Ie)}let y=g instanceof li,b=g.args.this;if(g instanceof WA&&b instanceof d){let H=new wt({this:b,expressions:[I.number(0)]});H.setArgKey("safe",!0),H.setArgKey("offset",1),b=_A("IF",_A("ARRAY_SIZE",new tt({expressions:[b,new ue({expressions:[]})]})).eq(I.number(0)),new ue({expressions:[H.copy()]}),b)}b instanceof $&&t.push(b.outputName);let m=i(r,"_u");f||(f=i(t,"col")),y&&!x&&(x=i(t,"pos")),x||(x=i(t,"pos")),T.setArgKey("alias",Z(f instanceof F?f:f??""));let C=u.args.alias?.args.this,q=Z(m),U=n((H,Ie)=>new $({this:Y(H,F)?H.copy():Z(H??""),table:typeof Ie=="string"?Z(Ie):Ie?.copy()}),"mkCol"),_=new xe({this:U(c,C).eq(U(x,q)),true:U(f,q)});if(g.replace(_),y){let H=e.args.expressions,Ie=H?.indexOf(T)??-1;H?.splice(Ie+1,0,Be(new xe({this:U(c,C).eq(U(x,q)),true:U(x,q)}),Y(x,F)||typeof x=="string"?x:void 0)),e.setArgKey("expressions",H)}o.length===0&&(e.args.from?e.join(u,{joinType:"cross",copy:!1}):e.from(u,{copy:!1}));let ne=new Rr({this:b instanceof d?b.copy():b});o.push(ne),e.join(Be(new Ee({expressions:b!==void 0?[b instanceof d?b.copy():b]:void 0,offset:new F({this:x,quoted:!1})}),m,{table:[Y(f,F)||typeof f=="string"?f:""]}),{joinType:"cross",copy:!1});let K=ne;a!==1&&(K=new Re({this:new Ce({this:ne,expression:I.number(1)})})),e.where(U(c,C).eq(U(x,q)).or(new Te({this:new je({this:U(c,C),expression:K}),expression:new Me({this:U(x,q),expression:K.copy()})})),{copy:!1})}}if(0<o.length){let h=new ni({this:o[0],expressions:o.slice(1),ignoreNulls:!1});a!==1&&(h=new Ce({this:h,expression:I.number(1-a)})),ct(u.args.expressions?.[0],d)?.setArgKey("end",h)}}return e}}n(HJ,"explodeProjectionToUnnest");function _J(a){if(MM.some(e=>a instanceof e)&&!(a.parent instanceof ns)&&a.args.expression){let e=a,t=e.args.this?.pop();e.setArgKey("this",e.args.expression?.pop());let s=new ye({expressions:[new hs({this:t,nullsFirst:!1})]});return new ns({this:e,expression:s})}return a}n(_J,"addWithinGroupForPercentiles");function WJ(a){if(a instanceof ns&&MM.some(e=>a.args.this instanceof e)&&a.args.expression instanceof ye){let e=ct(a.args.this,d)?.args.this,t=a.find(hs),s=t?t.args.this:void 0;return a.replace(new wh({this:s,quantile:e}))}return a}n(WJ,"removeWithinGroupForPercentiles");function jJ(a){if(a instanceof dt&&a.recursive){let e=CM("_c_");for(let t of a.args.expressions??[]){re(t,Bt);let s=Y(t.args.alias,pe)?t.args.alias:void 0;if(!s?.columns.length){let r=t.args.this;r instanceof Ge&&(r=r.args.this),re(r,ee),s?.setArgKey("columns",r.selects.map(i=>Z(i.aliasOrName||e())))}}}return a}n(jJ,"addRecursiveCteColumnNames");function XJ(a){return(a instanceof z||a instanceof Gt)&&a.name.toLowerCase()==="epoch"&&N.TEMPORAL_TYPES.has(st(At,(a.args.to instanceof d?a.args.to.args.this?.toString():a.args.to?.toString())??"")??"")&&ct(a.args.this,d)?.replace(I.string("1970-01-01 00:00:00")),a}n(XJ,"epochCastToTs");function JJ(a){if(a instanceof se){let e=a.args.joins||[];for(let t of[...e]){re(t,fe);let s=t.args.on;if(s&&(t.args.kind==="semi"||t.args.kind==="anti")){let r=Ye("1").from(t.args.this).where(s),i=new Ys({this:r});t.args.kind==="anti"&&(i=i.not()),t.pop(),a.where(i,{copy:!1})}}}return a}n(JJ,"eliminateSemiAndAntiJoins");function zJ(a){if(a instanceof se){let e=a.args.joins||[],s=Et(e,fe).map((r,i)=>({index:i,join:r})).filter(({join:r})=>r.args.side==="full");if(s.length===1){let r=a.copy();a.setArgKey("limit",void 0);let{index:i,join:o}=s[0],c=a.args.from?.aliasOrName,p=o.aliasOrName,u=o.args.on||new Te({expressions:(o.args.using||[]).map(T=>new Me({this:new $({this:T,table:c}),expression:new $({this:T,table:p})}))});o.setArgKey("side","left");let h=Ye("1").from(a.args.from).where(u);r.args.joins?.[i]?.setArgKey("side","right");let x=new Ys({this:h}).not();return r.where(x,{copy:!1}).setArgKey("with",void 0),a.setArgKey("order",void 0),jA([a,r],{distinct:!1})??a}}return a}n(zJ,"eliminateFullOuterJoin");function BH(a){let e=n(t=>{(t.isNumber||!(t instanceof Us)&&t.isType(["unknown",...N.NUMERIC_TYPES])||t instanceof $&&!t.type)&&t.replace(t.neq(0))},"_ensureBool");for(let t of a.walk())MD(t,e);return a}n(BH,"ensureBools");function QJ(a){for(let e of a.findAll($)){let t=e.parts;for(let s=0;s<t.length-1;s++)t[s].pop()}return a}n(QJ,"unqualifyColumns");function ZJ(a){if(!(a instanceof ss))return a;for(let e of a.findAll(Mu))e.parent&&e.parent.pop();return a}n(ZJ,"removeUniqueConstraints");function KJ(a,e=t=>t){if(!(a instanceof ss))return a;let s=a.args.properties?.args.expressions?.some(r=>r instanceof $s);return a.kind==="table"&&s?a.args.expression?new ss({kind:"temporary view",this:a.args.this,expression:a.args.expression}):e(a):a}n(KJ,"ctasWithTmpTablesToCreateTmpView");function ez(a){if(!(a instanceof ss))return a;let e=a.args.this instanceof Rt,t=a.kind==="table"||a.kind==="view";if(e&&t){let s=a.find(Cs);if(s&&s.args.this&&!(s.args.this instanceof Rt)){let r=a.args.this;re(r,Rt);let i=new Set(s.args.this.args.expressions?.map(c=>c instanceof d?c.name.toUpperCase():c.toString())),o=r.args.expressions?.filter(c=>i.has(c.name.toUpperCase()));r.setArgKey("expressions",r.args.expressions?.filter(c=>!o?.includes(c))),s.replace(new Cs({this:new Rt({expressions:Et(o??[],d)})})),a.setArgKey("this",r)}}return a}n(ez,"moveSchemaColumnsToPartitionedBy");function tz(a){if(!(a instanceof ss))return a;let e=a.find(Cs);if(e&&e.args.this instanceof Rt&&e.args.this.args.expressions?.every(t=>t instanceof Pe&&t.kind)){let t=new Ze({expressions:e.args.this.args.expressions.map(r=>{let i=r.args.this;return i instanceof d?Z(Y(i,F)?i:i.name):Z(i?.toString()??"")})}),s=a.args.this;for(let r of e.args.this.args.expressions)s.append("expressions",r);e.setArgKey("this",t)}return a}n(tz,"movePartitionedByToSchemaColumns");function sz(a){if(a instanceof se&&a.args.windows){let e=a.args.windows;a.setArgKey("windows",void 0);let t={},s=n(r=>{let i=r.alias?.toLowerCase();if(i===void 0)return;let o=t[i];if(o){r.setArgKey("alias",void 0);for(let c of["partitionBy","order","spec"]){let p=o.getArgKey(c);p instanceof d&&r.setArgKey(c,p.copy()),Array.isArray(p)&&0<p.length&&r.setArgKey(c,[...p])}}},"inlineInheritedWindow");for(let r of e)s(r),t[r.name.toLowerCase()]=r;for(let r of Dr(a,[Ue]))s(r)}return a}n(sz,"eliminateWindowClause");function rz(a){if(a instanceof ue&&a.args.structNameInheritance&&a.args.expressions?.[0]instanceof Es){let e=a.args.expressions[0];if(!e.args.expressions?.every(s=>s instanceof ot))return a;let t=e.args.expressions.map(s=>s.args.this);for(let s of a.args.expressions.slice(1)){if(!(s instanceof Es)||s.args.expressions?.length!==t.length)continue;let r=s.args.expressions.map((i,o)=>{if(!(i instanceof ot)){let c=t[o],p=c instanceof d?c.args.this:c,u=new ot({this:new F({this:p instanceof d?p.copy():p?.toString()||"",quoted:!1}),expression:i});return u.type=i.type,u}return i});s.setArgKey("expressions",r)}}return a}n(rz,"inheritStructFieldNames");var Tj=/\\(\d+)/g;function Cb(a,...e){let t=a._constructor.name,s=this.dialect._constructor.name;for(let r of e){let[i,o]=typeof r=="string"?[r,void 0]:r;a.getArgKey(i)&&this.unsupported(o??`Argument '${i}' is not supported for expression '${t}' when targeting ${s}.`)}}n(Cb,"unsupportedArgs");var $H,GH,YH,VH,HH,_H,WH,jH,XH,JH,zH,QH,rs;QH=[O,O],zH=[O],JH=[O],XH=[O],jH=[O],WH=[O],_H=[O],HH=[O],VH=[O],YH=[O],GH=[O],$H=[O];var L=class L{constructor(e={}){this.pretty=void 0;this.identify=void 0;this.normalize=void 0;this.pad=void 0;this.indentAmount=void 0;this.normalizeFunctions=void 0;this.unsupportedLevel=void 0;this.maxUnsupported=void 0;this.leadingComma=void 0;this.maxTextWidth=void 0;this.comments=void 0;this.dialect=void 0;this.unsupportedMessages=void 0;this.escapedQuoteEnd=void 0;this.nextName=void 0;this.escapedByteQuoteEnd=void 0;this.escapedIdentifierEnd=void 0;this.identifierStart=void 0;this.identifierEnd=void 0;this.quoteJsonPathKeyUsingBrackets=void 0;this.pretty=e.pretty??!1,this.identify=e.identify??!1,this.normalize=e.normalize??!1,this.pad=e.pad??2,this.indentAmount=e.indent??2,this.unsupportedLevel=e.unsupportedLevel??1,this.maxUnsupported=e.maxUnsupported??3,this.leadingComma=e.leadingComma??!1,this.maxTextWidth=e.maxTextWidth??80,this.comments=e.comments??!0,this.dialect=ae.getOrRaise(e.dialect);let t=this.dialect._constructor;this.normalizeFunctions=e.normalizeFunctions??t.NORMALIZE_FUNCTIONS??"upper";let s=t.tokenizerClass.STRING_ESCAPES,r=s&&0<s.length?s[0]:"";this.escapedQuoteEnd=r+this.dialect._constructor.QUOTE_END,this.escapedByteQuoteEnd=this.dialect._constructor.BYTE_END?r+this.dialect._constructor.BYTE_END:"",this.escapedIdentifierEnd=this.dialect._constructor.IDENTIFIER_END+this.dialect._constructor.IDENTIFIER_END,this.identifierStart=this.dialect._constructor.IDENTIFIER_START,this.identifierEnd=this.dialect._constructor.IDENTIFIER_END,this.unsupportedMessages=[],this.nextName=CM("_t"),this.quoteJsonPathKeyUsingBrackets=!0}static get NULL_ORDERING_SUPPORTED(){return"supported"}static get SUPPORTED_JSON_PATH_PARTS(){return new Set([...bD])}static get UNWRAPPED_INTERVAL_VALUES(){return new Set([$,I,Pt,Re])}static get WITH_SEPARATED_COMMENTS(){return new Set([$r,ss,Ql,Gr,tu,rt,es,fe,nu,ye,Yr,xs,se,Ge,us,St,dt])}static get EXCLUDE_COMMENTS(){return new Set([v,Ge])}static get TYPE_MAPPING(){return new Map([["datetime2","TIMESTAMP"],["nchar","CHAR"],["nvarchar","VARCHAR"],["mediumtext","TEXT"],["longtext","TEXT"],["tinytext","TEXT"],["blob","VARBINARY"],["mediumblob","BLOB"],["longblob","BLOB"],["tinyblob","BLOB"],["inet","INET"],["rowversion","VARBINARY"],["smalldatetime","TIMESTAMP"]])}static get UNSUPPORTED_TYPES(){return new Set}static get PARAMETERIZABLE_TEXT_TYPES(){return new Set(["nvarchar","varchar","char","nchar"])}static get TOKEN_MAPPING(){return{}}static get ORIGINAL_TRANSFORMS(){return new Map([[ph,function(e){return this.binary(e,"-|-")}],[Vn,function(e){return`ALLOWED_VALUES ${this.expressions(e,{flat:!0})}`}],[hu,function(e){return this.sql(e,"this")}],[uu,function(e){return this.expressions(e,{prefix:"WITH ",sep:" "})}],[Fn,function(e){return this.binary(e,"@>")}],[Fb,function(e){return this.binary(e,"&&")}],[Mb,function(e){return`ASSUME (${this.sql(e,"this")})`}],[Xn,function(e){return`AUTO REFRESH ${this.sql(e,"this")}`}],[Jn,function(e){return`BACKUP ${this.sql(e,"this")}`}],[kn,e=>`${e.getArgKey("not")?"NOT ":""}CASESPECIFIC`],[ti,function(e){return this.ceilFloor(e)}],[fu,function(e){return`CHARACTER SET ${this.sql(e,"this")}`}],[zr,function(e){return`${e.getArgKey("default")?"DEFAULT ":""}CHARACTER SET=${this.sql(e,"this")}`}],[Tu,function(e){return`CLUSTERED (${this.expressions(e,{key:"this",indent:!1})})`}],[Su,function(e){return`COLLATE ${this.sql(e,"this")}`}],[Ru,function(e){return`COMMENT ${this.sql(e,"this")}`}],[Eh,function(e){return`CONNECT_BY_ROOT ${this.sql(e,"this")}`}],[vb,function(e){return this.func("CONVERT",[e.args.this,e.args.dest,e.args.source])}],[Qn,()=>"COPY GRANTS"],[ld,function(e){return`CREDENTIALS=(${this.expressions(e,{key:"expressions",sep:" "})})`}],[Mh,()=>"CURRENT_CATALOG"],[kh,()=>"SESSION_USER"],[Ou,function(e){return`FORMAT ${this.sql(e,"this")}`}],[mu,function(e){return`DEFAULT ${this.sql(e,"this")}`}],[zA,()=>"API"],[QA,()=>"APPLICATION"],[ZA,()=>"CATALOG"],[KA,()=>"COMPUTE"],[ed,()=>"DATABASE"],[Aa,()=>"DYNAMIC"],[da,()=>"EMPTY"],[du,()=>"END"],[Nu,function(e){return`ENCODE ${this.sql(e,"this")}`}],[ga,function(e){return`ENVIRONMENT (${this.expressions(e,{flat:!0})})`}],[ra,function(e){return`HANDLER ${this.sql(e,"this")}`}],[ia,function(e){return`PARAMETER STYLE ${this.sql(e,"this")}`}],[yu,function(e){return`EPHEMERAL${e.args.this?" "+this.sql(e,"this"):""}`}],[Iu,function(e){return`EXCLUDE ${this.sql(e,"this").trimStart()}`}],[nr,function(e){return this.nakedProperty(e)}],[cr,function(e){return this.setOperations(e)}],[oa,()=>"EXTERNAL"],[fh,function(e){return this.ceilFloor(e)}],[bb,function(e){return this.getPutSql(e)}],[ca,()=>"GLOBAL"],[na,()=>"HEAP"],[td,()=>"HYBRID"],[pa,()=>"ICEBERG"],[la,function(e){return`INHERITS (${this.expressions(e,{flat:!0})})`}],[Cu,function(e){return`INLINE LENGTH ${this.sql(e,"this")}`}],[ua,function(e){return`INPUT${this.sql(e,"this")}`}],[ei,function(e){return this.setOperations(e)}],[Wr,function(e){return`${this.sql(e,"this")} TO ${this.sql(e,"expression")}`}],[Uh,function(e){return this.sql(X(e.args.this||"","bigint"))}],[Rh,function(e){return this.binary(e,"?|")}],[Oh,function(e){return this.binary(e,"?&")}],[mh,function(e){return this.binary(e,"#-")}],[Vs,function(e){return`?${e.args.this}`}],[fr,function(e){return`..${e.args.this||""}`}],[Qt,()=>"$"],[Hs,function(e){return`(${e.args.this}`}],[ci,function(e){return`[${this.jsonPathPart(e.args.this)}]`}],[Tr,function(e){return[e.args.start,e.args.end,e.args.step].filter(t=>t!==void 0).map(t=>t===!1?"":this.jsonPathPart(t)).join(":")}],[Sr,function(e){return`[${(e.args.expressions??[]).map(s=>this.jsonPathPart(s)).join(",")}]`}],[qt,()=>"*"],[Qr,function(e){return this.nakedProperty(e)}],[Zr,function(e){return this.nakedProperty(e)}],[xa,e=>`${e.getArgKey("no")?"NO ":""}LOG`],[sd,()=>"MASKING"],[fa,()=>"MATERIALIZED"],[rd,()=>"NETWORK"],[Yb,function(e){return`NET.${this.sql(e,"this")}`}],[bu,function(e){return`NONCLUSTERED (${this.expressions(e,{key:"this",indent:!1})})`}],[Ta,()=>"NO PRIMARY INDEX"],[Pu,()=>"NOT FOR REPLICATION"],[Hr,e=>`ON COMMIT ${e.getArgKey("delete")?"DELETE":"PRESERVE"} ROWS`],[Vr,function(e){return`ON ${this.sql(e,"this")}`}],[Lu,function(e){return`ON UPDATE ${this.sql(e,"this")}`}],[ch,function(e){return this.binary(e,"")}],[ha,function(e){return`OUTPUT${this.sql(e,"this")}`}],[nh,function(e){return this.binary(e,"&<")}],[ah,function(e){return this.binary(e,"&>")}],[Du,function(e){return`PATH ${this.sql(e,"this")}`}],[Xu,function(e){return this.func("BUCKET",[e.args.this,e.args.expression])}],[Ju,function(e){return this.func("TRUNCATE",[e.args.this,e.args.expression])}],[wn,function(e){return`ANY${this.sql(e,"this")}`}],[Pb,function(e){return`#${this.sql(e,"this")}`}],[kb,function(e){return`PROJECTION POLICY ${this.sql(e,"this")}`}],[wb,()=>"ZEROFILL"],[XA,function(e){return this.getPutSql(e)}],[Ra,function(e){return`REMOTE WITH CONNECTION ${this.sql(e,"this")}`}],[Kr,function(e){return e.getArgKey("null")?"RETURNS NULL ON NULL INPUT":this.nakedProperty(e)}],[Ub,function(e){return`SAFE.${this.sql(e,"this")}`}],[Na,function(e){return`SAMPLE BY ${this.sql(e,"this")}`}],[id,()=>"ROW ACCESS"],[La,()=>"SECURE"],[nd,()=>"SECURITY"],[JA,function(e){return this.sql(e,"this")}],[_r,e=>`${e.getArgKey("multi")?"MULTI":""}SET`],[Ca,function(e){return`SETTINGS${this.seg("")}${this.expressions(e)}`}],[ya,function(e){return`SHARING=${this.sql(e,"this")}`}],[vs,e=>e.name],[Pa,function(e){return`SQL SECURITY ${this.sql(e,"this")}`}],[Fs,e=>e.name],[Eu,function(e){return`STREAM ${this.sql(e,"this")}`}],[Sa,()=>"STREAMING"],[Oa,()=>"STRICT"],[Kl,function(e){return`SWAP WITH ${this.sql(e,"this")}`}],[Gl,function(e){return this.sql(e.args.this)}],[ad,function(e){return`TAG (${this.expressions(e,{flat:!0})})`}],[$s,()=>"TEMPORARY"],[wu,function(e){return`TITLE ${this.sql(e,"this")}`}],[vh,function(e){return`MAP ${this.sql(e,"this")}`}],[aa,function(e){return`TO ${this.sql(e.args.this)}`}],[wa,function(e){return this.func("TRANSFORM",e.args.expressions||[])}],[Ma,()=>"TRANSIENT"],[or,function(e){return this.setOperations(e)}],[ka,()=>"UNLOGGED"],[od,function(e){return`USING TEMPLATE ${this.sql(e,"this")}`}],[gu,function(e){return`USING DATA ${this.sql(e,"this")}`}],[ku,()=>"UPPERCASE"],[Bb,function(e){return this.sql(new pr({this:I.string("UTC")}))}],[$b,function(e){return this.sql(new si({this:I.string("UTC")}))}],[Gb,function(e){return this.sql(new ri({this:I.string("UTC")}))}],[Lb,function(e){return`VARIADIC ${this.sql(e,"this")}`}],[Rs,function(e){return this.func("MAP",[e.args.keys,e.args.values])}],[Da,function(e){return`WITH ${this.sql(e,"this")}`}],[qa,()=>"VOLATILE"],[Ua,function(e){return`WITH JOURNAL TABLE=${this.sql(e,"this")}`}],[Fa,function(e){return`WITH ${this.expressions(e,{flat:!0})}`}],[va,function(e){return`WITH SCHEMA ${this.sql(e,"this")}`}],[eu,function(e){return`${this.sql(e,"this")} WITH ${this.sql(e,"op")}`}],[cd,()=>"FORCE"]])}static get TRANSFORMS(){let e=new Map(this.ORIGINAL_TRANSFORMS);for(let t of Array.from(bD).filter(s=>!this.SUPPORTED_JSON_PATH_PARTS.has(s)))e.delete(t);return e}static get PROPERTIES_LOCATION(){return new Map([[Vn,"postSchema"],[Wn,"postCreate"],[zA,"postCreate"],[QA,"postCreate"],[jn,"postSchema"],[Xn,"postSchema"],[Jn,"postSchema"],[qu,"postName"],[ZA,"postCreate"],[zr,"postSchema"],[Uu,"postName"],[zn,"postSchema"],[KA,"postCreate"],[Qn,"postSchema"],[rr,"postSchema"],[Ea,"postSchema"],[ea,"postSchema"],[Bu,"postSchema"],[vu,"postName"],[ed,"postCreate"],[Fu,"postSchema"],[Zn,"postCreate"],[_u,"postSchema"],[Hu,"postSchema"],[Aa,"postCreate"],[Kn,"postSchema"],[ta,"postSchema"],[da,"postSchema"],[hd,"postExpression"],[sa,"postSchema"],[ga,"postSchema"],[ra,"postSchema"],[ia,"postSchema"],[nr,"postSchema"],[oa,"postCreate"],[$u,"postName"],[ir,"postWith"],[Gu,"postName"],[ca,"postCreate"],[na,"postWith"],[td,"postCreate"],[la,"postSchema"],[pa,"postCreate"],[gd,"postSchema"],[ua,"postSchema"],[Yu,"postName"],[Vu,"postName"],[Qr,"postSchema"],[Wu,"postSchema"],[Zr,"postSchema"],[ud,"postSchema"],[ju,"postAlias"],[xa,"postName"],[sd,"postCreate"],[fa,"postCreate"],[qn,"postName"],[rd,"postCreate"],[Ta,"postExpression"],[Vr,"postSchema"],[Hr,"postExpression"],[ye,"postSchema"],[ha,"postSchema"],[Cs,"postWith"],[zu,"postSchema"],[ru,"postSchema"],[w,"postWith"],[qb,"postSchema"],[Ra,"postSchema"],[Kr,"postSchema"],[Db,"unsupported"],[ma,"postSchema"],[Qu,"postSchema"],[Zu,"postSchema"],[id,"postCreate"],[Na,"postSchema"],[Ia,"postSchema"],[La,"postCreate"],[nd,"postCreate"],[Ku,"postSchema"],[Zl,"postSchema"],[Ca,"postSchema"],[_r,"postCreate"],[JA,"postSchema"],[ya,"postExpression"],[Br,"postExpression"],[Gn,"postExpression"],[ba,"postSchema"],[vs,"postSchema"],[Pa,"postSchema"],[Fs,"postSchema"],[eh,"postSchema"],[Sa,"postCreate"],[Oa,"postSchema"],[ad,"postWith"],[$s,"postCreate"],[aa,"postSchema"],[Ma,"postCreate"],[wa,"postSchema"],[Pn,"postSchema"],[ka,"postCreate"],[od,"postSchema"],[Da,"postSchema"],[qa,"postCreate"],[th,"postExpression"],[Ua,"postName"],[Fa,"postSchema"],[va,"postSchema"],[sh,"postSchema"],[cd,"postCreate"]])}get _constructor(){return this.constructor}generate(e,t={}){let{copy:s=!0}=t,r=s?e.copy():e;r=this.preprocess(r),this.unsupportedMessages=[];let i=this.sql(r).trim();if(this.pretty&&(i=i.replaceAll(this._constructor.SENTINEL_LINE_BREAK,`
|
|
6
6
|
`)),this.unsupportedLevel===0)return i;if(this.unsupportedLevel===1)for(let o of this.unsupportedMessages)console.warn(o);else if(this.unsupportedLevel===2&&0<this.unsupportedMessages.length)throw new kr(gM(this.unsupportedMessages,this.maxUnsupported));return i}preprocess(e){return e=this.moveCtesToTopLevel(e),this._constructor.ENSURE_BOOLS&&(e=BH(e)),e}moveCtesToTopLevel(e){return!e.parent&&this.constructor.EXPRESSIONS_WITHOUT_NESTED_CTES.has(e._constructor)&&[...e.findAll(dt)].some(t=>t.parent!==e)?FH(e):e}unsupported(e){if(this.unsupportedLevel===3)throw new kr(e);this.unsupportedMessages.push(e)}sep(e=" "){return this.pretty?`${e.trim()}
|
|
7
7
|
`:e}seg(e,t=" "){return`${this.sep(t)}${e}`}sanitizeComment(e){let t=e;return t[0]&&t[0].trim()!==""&&(t=" "+t),t[t.length-1]&&t[t.length-1].trim()!==""&&(t=t+" "),t=t.replace(/\*\//g,"* /").replace(/\/\*/g,"/ *"),t}wrap(e){let t;return typeof e!="string"&&Ls.some(s=>e instanceof s)?t=this.sql(e):t=this.sql(e,"this"),t?(t=this.indent(t,{level:1,pad:0}),`(${this.sep("")}${t}${this.seg(")","")}`):"()"}noIdentify(e,...t){let s=this.identify;this.identify=!1;let r=e(...t);return this.identify=s,r}normalizeFunc(e){return this.normalizeFunctions==="upper"?e.toUpperCase():this.normalizeFunctions==="lower"?e.toLowerCase():e}indent(e,t={}){let{skipFirst:s=!1,skipLast:r=!1,pad:i=this.pad,level:o=0}=t;if(!this.pretty||!e)return e;let c=e.split(`
|
|
8
8
|
`);return c.map((p,u)=>s&&u===0||r&&u===c.length-1?p:`${" ".repeat(o*this.indentAmount+i)}${p}`).join(`
|
|
9
|
-
`)}sql(e,t,s={}){let{comment:r=!0}=s;if(e===void 0)return"";if(typeof e=="number"||typeof e=="string"||typeof e=="boolean")return e.toString();if(Array.isArray(e))return e.map(c=>this.sql(c)).join(", ");if(t){let c=e.getArgKey(t);return c&&(typeof c=="string"||c instanceof d)?this.sql(c):""}let i=this._constructor.TRANSFORMS.get(e._constructor),o="";if(i instanceof Function)o=i.call(this,e);else if(e instanceof d){let c=`${e._constructor.key}Sql`,p=this[c];if(p instanceof Function)o=p.call(this,e);else if(e instanceof E||
|
|
10
|
-
`?`${this.sep()}${c}${e}`:`${c}${this.sep()}${e}`:`${e} ${c}`}uncacheSql(e){let t=this.sql(e,"this");return`UNCACHE TABLE${e.args.exists?" IF EXISTS":""} ${t}`}cacheSql(e){let t=e.args.lazy?" LAZY":"",s=this.sql(e,"this"),r=e.args.options,i=r?.length?` OPTIONS(${this.sql(r[0])} = ${this.sql(r[1])})`:"",o=this.sql(e,"expression");return o=o?` AS${this.sep()}${o}`:"",o=`CACHE${t} TABLE ${s}${i}${o}`,this.prependCtes(e,o)}characterSetSql(e){return e.parent instanceof z?`CHAR CHARACTER SET ${this.sql(e,"this")}`:`${e.args.default?"DEFAULT ":""}CHARACTER SET=${this.sql(e,"this")}`}columnParts(e){return[e.args.catalog,e.args.db,e.args.table,e.args.this].filter(Boolean).map(s=>this.sql(s)).join(".")}columnSql(e){let t=e.args.joinMark?" (+)":"";return t&&!this.dialect._constructor.SUPPORTS_COLUMN_JOIN_MARKS?(this.unsupported("Outer join syntax using the (+) operator is not supported."),this.columnParts(e)):`${this.columnParts(e)}${t}`}pseudocolumnSql(e){return this.columnSql(e)}columnPositionSql(e){let t=this.sql(e,"this"),s=t?` ${t}`:"";return`${this.sql(e,"position")}${s}`}columnDefSql(e,t={}){let{sep:s=" "}=t,r=this.sql(e,"this"),i=this.sql(e,"kind"),o=this.expressions(e,{key:"constraints",sep:" ",flat:!0}),c=e.args.exists?"IF NOT EXISTS ":"";i=i?`${s}${i}`:"";let p=o?` ${o}`:"",u=this.sql(e,"position");return u=u?` ${u}`:"",0<Array.from(e.findAll(Dn)).length&&!this._constructor.COMPUTED_COLUMN_WITH_TYPE&&(i=""),`${c}${r}${i}${p}${u}`}columnConstraintSql(e){let t=this.sql(e,"this"),s=this.sql(e,"kind").trim();return t?`CONSTRAINT ${t} ${s}`:s}computedColumnConstraintSql(e){let t=this.sql(e,"this"),s;return e.args.notNull?s=" PERSISTED NOT NULL":e.args.persisted?s=" PERSISTED":s="",`AS ${t}${s}`}autoIncrementColumnConstraintSql(e){return this.tokenSql("autoIncrement")}compressColumnConstraintSql(e){let t;return Array.isArray(e.args.this)?t=this.wrap(this.expressions(e,{key:"this",flat:!0})):t=this.sql(e,"this"),`COMPRESS ${t}`}generatedAsIdentityColumnConstraintSql(e){let t="";if(e.args.this!==void 0){let y=e.args.onNull?" ON NULL":"";t=e.args.this?" ALWAYS":` BY DEFAULT${y}`}let s=e.args.start,r=s?`START WITH ${s}`:"",i=e.args.increment,o=i?` INCREMENT BY ${i}`:"",c=e.args.minvalue,p=c?` MINVALUE ${c}`:"",u=e.args.maxvalue,h=u?` MAXVALUE ${u}`:"",g=e.args.cycle,f="";g!==void 0&&(f=`${g?"":" NO"} CYCLE`,f=!r&&!o?f.trim():f);let x="";(r||o||f)&&(x=`${r}${o}${p}${h}${f}`,x=` (${x.trim()})`);let T=this.sql(e,"expression");return T=T?`(${T})`:"IDENTITY",`GENERATED${t} AS ${T}${x}`}generatedAsRowColumnConstraintSql(e){let t=e.args.start?"START":"END",s=e.args.hidden?" HIDDEN":"";return`GENERATED ALWAYS AS ROW ${t}${s}`}periodForSystemTimeConstraintSql(e){return`PERIOD FOR SYSTEM_TIME (${this.sql(e,"this")}, ${this.sql(e,"expression")})`}notNullColumnConstraintSql(e){return e.args.allowNull?"NULL":"NOT NULL"}primaryKeyColumnConstraintSql(e){let t=e.args.desc;if(t!==void 0)return`PRIMARY KEY${t?" DESC":" ASC"}`;let s=this.expressions(e,{key:"options",flat:!0,sep:" "});return s=s?` ${s}`:"",`PRIMARY KEY${s}`}uniqueColumnConstraintSql(e){let t=this.sql(e,"this");t=t?` ${t}`:"";let s=e.args.indexType,r=s?` USING ${s}`:"",i=this.sql(e,"onConflict");i=i?` ${i}`:"";let o=e.args.nulls?" NULLS NOT DISTINCT":"",c=this.expressions(e,{key:"options",flat:!0,sep:" "});return c=c?` ${c}`:"",`UNIQUE${o}${t}${r}${i}${c}`}inOutColumnConstraintSql(e){let t=e.args.input,s=e.args.output;return e.args.variadic?"VARIADIC":t&&s?`IN${this._constructor.INOUT_SEPARATOR}OUT`:t?"IN":s?"OUT":""}createableSql(e,t){return this.sql(e,"this")}createSql(e){let t=this.sql(e,"kind").toUpperCase();t=this.dialect._constructor.INVERSE_CREATABLE_KIND_MAPPING[t]??t;let s=e.args.properties;t==="TRIGGER"&&s&&s instanceof He&&s.args.expressions?.length&&s.args.expressions[0]instanceof Gn&&s.args.expressions[0].args.constraint&&(t=`CONSTRAINT ${t}`),s&&re(s,He);let r=s?this.locateProperties(s):new Map,i=this.createableSql(e,r),o="",c=r.get("postSchema"),p=r.get("postWith");if(c?.length||p?.length){let Xe=new He({expressions:[...c??[],...p??[]]});Xe.parent=e,o=this.sql(Xe),c?.length?o=this.sep()+o:this.pretty||(o=` ${o}`)}let u=e.args.begin?" BEGIN":"",h=this.sql(e,"expression");if(h&&(h=`${u}${this.sep()}${h}`,this._constructor.CREATE_FUNCTION_RETURN_AS||!(e.args.expression instanceof ou))){let Xe="",mt=r.get("postAlias");mt&&(Xe=this.properties(new He({expressions:mt}),{wrapped:!1})),Xe=Xe?` ${Xe}`:"",h=` AS${Xe}${h}`}let g="",f=r.get("postIndex");f&&(g=this.properties(new He({expressions:f}),{wrapped:!1,prefix:" "}));let x=this.expressions(e,{key:"indexes",indent:!1,sep:" "});x=x?` ${x}`:"";let T=x+g,y=e.args.replace?" OR REPLACE":"",C=e.args.refresh?" OR REFRESH":"",I=e.args.unique?" UNIQUE":"",b=e.args.clustered,k="";b===void 0?k="":b?k=" CLUSTERED COLUMNSTORE":k=" NONCLUSTERED COLUMNSTORE";let B="",j=r.get("postCreate");j&&(B=this.properties(new He({expressions:j}),{sep:" ",prefix:" ",wrapped:!1}));let Q=`${k}${y}${C}${I}${B}`,ne="",H=r.get("postExpression");H&&(ne=this.properties(new He({expressions:H}),{sep:" ",prefix:" ",wrapped:!1}));let Pe=e.args.concurrently?" CONCURRENTLY":"",me=e.args.exists?" IF NOT EXISTS":"",Ot=e.args.noSchemaBinding?" WITH NO SCHEMA BINDING":"",gt=this.sql(e,"clone");gt=gt?` ${gt}`:"";let Cs;return this._constructor.EXPRESSION_PRECEDES_PROPERTIES_CREATABLES.has(t)?Cs=`${h}${o}`:Cs=`${o}${h}`,h=`CREATE${Q} ${t}${Pe}${me} ${i}${Cs}${ne}${T}${Ot}${gt}`,this.prependCtes(e,h)}sequencePropertiesSql(e){let t=this.sql(e,"start");t=t?`START WITH ${t}`:"";let s=this.sql(e,"increment");s=s?` INCREMENT BY ${s}`:"";let r=this.sql(e,"minvalue");r=r?` MINVALUE ${r}`:"";let i=this.sql(e,"maxvalue");i=i?` MAXVALUE ${i}`:"";let o=this.sql(e,"owned");o=o?` OWNED BY ${o}`:"";let c=e.args.cache,p="";c===void 0?p="":c===!0?p=" CACHE":p=` CACHE ${c}`;let u=this.expressions(e,{key:"options",flat:!0,sep:" "}),h=u?` ${u}`:"";return`${t}${s}${r}${i}${p}${h}${o}`.trimStart()}triggerPropertiesSql(e){let t=e.args.timing??"",s=(e.args.events??[]).map(f=>this.sql(f)).join(" OR "),i=[t||s?`${t} ${s}`.trim():"","ON",this.sql(e,"table")],o=e.args.referencedTable;o&&i.push("FROM",this.sql(o));let c=e.args.deferrable;c&&i.push(c);let p=e.args.initially;p&&i.push(`INITIALLY ${p}`);let u=e.args.referencing;u&&i.push(this.sql(u));let h=e.args.forEach;h&&i.push(`FOR EACH ${h}`);let g=e.args.when;return g&&i.push(`WHEN (${this.sql(g)})`),i.push(this.sql(e,"execute")),i.join(this.sep())}triggerExecuteSql(e){return`EXECUTE FUNCTION ${this.sql(e,"this")}`}triggerReferencingSql(e){let t=[],s=e.args.old;s&&t.push(`OLD TABLE AS ${this.sql(s)}`);let r=e.args.new;return r&&t.push(`NEW TABLE AS ${this.sql(r)}`),`REFERENCING ${t.join(" ")}`}triggerEventSql(e){return e.args.columns?`${e.args.this} OF ${this.expressions(e,{key:"columns",flat:!0})}`:String(e.args.this??"")}cloneSql(e){let t=this.sql(e,"this"),s=e.args.shallow?"SHALLOW ":"",r=e.args.copy&&this._constructor.SUPPORTS_TABLE_COPY?"COPY":"CLONE";return`${s}${r} ${t}`}describeSql(e){let t=e.args.style,s=t?` ${t}`:"",r=this.sql(e,"partition");r=r?` ${r}`:"";let i=this.sql(e,"format");i=i?` ${i}`:"";let o=e.args.asJson?" AS JSON":"";return`DESCRIBE${s}${i} ${this.sql(e,"this")}${r}${o}`}heredocSql(e){let t=this.sql(e,"tag");return`$${t}$${this.sql(e,"this")}$${t}$`}prependCtes(e,t){let s=this.sql(e,"with");return s?`${s}${this.sep()}${t}`:t}withSql(e){let t=this.expressions(e,{flat:!0}),s=this._constructor.CTE_RECURSIVE_KEYWORD_REQUIRED&&e.args.recursive?"RECURSIVE ":"",r=this.sql(e,"search");return r=r?` ${r}`:"",`WITH ${s}${t}${r}`}cteSql(e){let t=e.args.alias;t&&t.addComments?.(e.popComments());let s=this.sql(e,"alias"),r=e.args.materialized,i="";r===!1?i="NOT MATERIALIZED ":r&&(i="MATERIALIZED ");let o=this.expressions(e,{key:"keyExpressions",flat:!0}),c=o?` USING KEY (${o})`:"";return`${s}${c} AS ${i}${this.wrap(e)}`}tableAliasSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{key:"columns",flat:!0});return s=s?`(${s})`:"",s&&!this._constructor.SUPPORTS_TABLE_ALIAS_COLUMNS&&(s="",this.unsupported("Named columns are not supported in table alias.")),!t&&!this.dialect._constructor.UNNEST_COLUMN_ONLY&&(t=this.nextName()),`${t}${s}`}bitStringSql(e){let t=this.sql(e,"this");return this.dialect._constructor.BIT_START?`${this.dialect._constructor.BIT_START}${t}${this.dialect._constructor.BIT_END}`:`${parseInt(t,2)}`}hexStringSql(e,t={}){let{binaryFunctionRepr:s}=t,r=this.sql(e,"this"),i=e.args.isInteger;if(i&&!this.dialect._constructor.HEX_STRING_IS_INTEGER_TYPE||!this.dialect._constructor.HEX_START&&!s)return`${parseInt(r,16)}`;if(!i){if(s)return this.func(s,[Hl(r)]);this.dialect._constructor.HEX_STRING_IS_INTEGER_TYPE&&this.unsupported("Unsupported transpilation from BINARY/BLOB hex string")}return`${this.dialect._constructor.HEX_START}${r}${this.dialect._constructor.HEX_END}`}byteStringSql(e){let t=this.sql(e,"this");if(this.dialect._constructor.BYTE_START){let s=this.escapeStr(t,{escapeBackslash:!1,delimiter:this.dialect._constructor.BYTE_END,escapedDelimiter:this.escapedByteQuoteEnd,isByteString:!0}),r=e.args.isBytes||!1,i=`${this.dialect._constructor.BYTE_START}${s}${this.dialect._constructor.BYTE_END}`;return r&&!this.dialect._constructor.BYTE_STRING_IS_BYTES_TYPE?this.sql(X(i,"BINARY",{dialect:this.dialect})):!r&&this.dialect._constructor.BYTE_STRING_IS_BYTES_TYPE?this.sql(X(i,"VARCHAR",{dialect:this.dialect})):i}return t}unicodeStringSql(e){let t=this.sql(e,"this"),s=e.args.escape,r,i,o;this.dialect._constructor.UNICODE_START?(r="\\$1",i=this.dialect._constructor.UNICODE_START,o=this.dialect._constructor.UNICODE_END):(r="\\u$1",i=this.dialect._constructor.QUOTE_START,o=this.dialect._constructor.QUOTE_END);let c,p;s?(c=new RegExp(`${s.name}(\\d+)`,"g"),p=this._constructor.SUPPORTS_UESCAPE?` UESCAPE ${this.sql(s)}`:""):(c=xj,p="");let u=t;if(!this.dialect._constructor.UNICODE_START||s&&!this._constructor.SUPPORTS_UESCAPE){let h=this._constructor.UNICODE_SUBSTITUTE||r;u=u.replace(c,h)}return`${i}${u}${o}${p}`}rawStringSql(e){let t=e.args.this?.toString()||"";return t.includes("x21")&&console.log("DEBUG rawStringSql: chars=",[...t].map(s=>s.charCodeAt(0))),this.dialect._constructor.tokenizerClass.STRING_ESCAPES.includes("\\")&&(t=t?.replace(/\\/g,"\\\\")),t=this.escapeStr(t,{escapeBackslash:!1}),`${this.dialect._constructor.QUOTE_START}${t}${this.dialect._constructor.QUOTE_END}`}dataTypeParamSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=s&&this._constructor.DATA_TYPE_SPECIFIERS_ALLOWED?` ${s}`:"";return`${t}${r}`}dataTypeSql(e){let t="",s="",r=e.args.nested,i=r&&this.pretty?this.expressions(e,{dynamic:!0,newLine:!0,skipFirst:!0,skipLast:!0}):this.expressions(e,{flat:!0}),o=e.args.this;typeof o=="string"&&this._constructor.UNSUPPORTED_TYPES.has(o)&&this.unsupported(`Data type ${o} is not supported when targeting ${this.dialect._constructor.name}`);let c;if(o instanceof d)c=o.sql();else if(o==="user-defined"&&e.args.kind)c=this.sql(e,"kind");else{let p=o&&this._constructor.TYPE_MAPPING.get(o),u=o!==void 0&&Object.values(At).includes(o);c=p!==void 0?p:o&&(u?bM(o):o)}if(i)if(r){let p=this._constructor.STRUCT_DELIMITER;if(t=`${p[0]}${i}${p[1]}`,e.args.values?.length){let u=o==="array"?["[","]"]:["(",")"],h=this.expressions(e,{key:"values",flat:!0});s=`${u[0]}${h}${u[1]}`}}else o==="interval"?t=` ${i}`:t=`(${i})`;return c=`${c}${t}${s}`,this._constructor.TZ_TO_WITH_TIME_ZONE&&(o==="timetz"||o==="timestamptz")&&(c=`${c} WITH TIME ZONE`),c}directorySql(e){let t=e.args.local?"LOCAL ":"",s=this.sql(e,"rowFormat");return s=s?` ${s}`:"",`${t}DIRECTORY ${this.sql(e,"this")}${s}`}deleteSql(e){let t=this.sql(e,"this"),s=t?` FROM ${t}`:"",r=this.expressions(e,{key:"using"});r=r?` USING ${r}`:"";let i=this.sql(e,"cluster");i=i?` ${i}`:"";let o=this.sql(e,"where"),c=this.sql(e,"returning"),p=this.sql(e,"order"),u=this.sql(e,"limit"),h=this.expressions(e,{key:"tables"});h=h?` ${h}`:"";let g;return this._constructor.RETURNING_END?g=`${s}${r}${i}${o}${c}${p}${u}`:g=`${c}${s}${r}${i}${o}${p}${u}`,this.prependCtes(e,`DELETE${h}${g}`)}dropSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});s=s?` (${s})`:"";let r=e.args.kind?.toString().toUpperCase(),i=r&&(this.dialect._constructor.INVERSE_CREATABLE_KIND_MAPPING?.[r]||r),o=e.args.exists?" IF EXISTS ":" ",c=e.args.concurrently?" CONCURRENTLY":"",p=this.sql(e,"cluster");p=p?` ${p}`:"";let u=e.args.temporary?" TEMPORARY":"",h=e.args.materialized?" MATERIALIZED":"",g=e.args.iceberg&&this._constructor.SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY?" ICEBERG":"",f=e.args.cascade?" CASCADE":"",x=e.args.restrict?" RESTRICT":"",T=e.args.constraints?" CONSTRAINTS":"",y=e.args.purge?" PURGE":"",C=e.args.sync?" SYNC":"";return`DROP${u}${h}${g} ${i}${c}${o}${t}${p}${s}${f}${x}${T}${y}${C}`}setOperation(e){let t=e._constructor,s=t.key.toUpperCase(),r=e.args.distinct;r===!1&&(e instanceof cr||e instanceof ei)&&!this._constructor.EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE&&this.unsupported(`${s} ALL is not supported`);let i=this.dialect._constructor.SET_OP_DISTINCT_BY_DEFAULT?.[t.key];r===void 0&&(r=i,r===void 0&&this.unsupported(`${s} requires DISTINCT or ALL to be specified`));let o;r===i?o="":o=r?" DISTINCT":" ALL";let c=[e.args.side,e.args.kind].filter(Boolean).join(" ").toUpperCase(),p=c?`${c} `:"",u=e.args.byName?" BY NAME":"",h=this.expressions(e,{key:"on",flat:!0});return h=h?` ON (${h})`:"",`${p}${s}${o}${u}${h}`}setOperations(e){if(!this._constructor.SET_OP_MODIFIERS){let i=e.args.limit,o=e.args.order;if(i||o){let p=this.moveCtesToTopLevel(DD(e,"_l_0",{copy:!1}).select("*",{copy:!1}));return i&&(p=p.limit(typeof i=="number"?i:i.pop(),{copy:!1})),o&&(p=p.orderBy(o.pop(),{copy:!1})),this.sql(p)}}let t=[],s=[e];for(;0<s.length;){let i=s.pop();if(i instanceof Ge)i.args.expression&&s.push(i.args.expression),s.push(this.maybeComment(this.setOperation(i),void 0,i.comments,!0)),i.args.this&&s.push(i.args.this);else{let o=typeof i=="string"?i:this.sql(i);t.push(o)}}let r=t.join(this.sep());return r=this.queryModifiers(e,r),this.prependCtes(e,r)}fetchSql(e){let t=e.args.direction,s=t?` ${t}`:"",r=this.sql(e,"count"),i=r?` ${r}`:"",o=this.sql(e,"limitOptions"),c=o?`${o}`:" ROWS ONLY";return`${this.seg("FETCH")}${s}${i}${c}`}limitOptionsSql(e){let t=e.args.percent?" PERCENT":"",s=e.args.rows?" ROWS":"",r=e.args.withTies?" WITH TIES":"";return!r&&s&&(r=" ONLY"),`${t}${s}${r}`}filterSql(e){if(this._constructor.AGGREGATE_FILTER_SUPPORTED){let o=this.sql(e,"this"),c=this.sql(e,"expression").trim();return`${o} FILTER(${c})`}let s=e.args.this,r=s?s.args.this:void 0,i=e.args.expression?.args.this;return r instanceof d&&i instanceof d&&r.replace(new fe({this:i.copy(),true:r.copy()})),this.sql(s)}hintSql(e){return this._constructor.QUERY_HINTS?` /*+ ${this.expressions(e,{sep:this._constructor.QUERY_HINT_SEP}).trim()} */`:(this.unsupported("Hints are not supported"),"")}indexParametersSql(e){let t=this.sql(e,"using");t=t?` USING ${t}`:"";let s=this.expressions(e,{key:"columns",flat:!0}),r=s?`(${s})`:"",i=this.expressions(e,{key:"partitionBy",flat:!0}),o=i?` PARTITION BY ${i}`:"",c=this.sql(e,"where"),p=this.expressions(e,{key:"include",flat:!0});p&&(p=` INCLUDE (${p})`);let u=this.expressions(e,{key:"withStorage",flat:!0}),h=u?` WITH (${u})`:"",g=this.sql(e,"tablespace"),f=g?` USING INDEX TABLESPACE ${g}`:"",x=this.sql(e,"on"),T=x?` ON ${x}`:"";return`${t}${r}${p}${h}${f}${o}${c}${T}`}indexSql(e){let t=e.args.unique?"UNIQUE ":"",s=e.args.primary?"PRIMARY ":"",r=e.args.amp?"AMP ":"",i=this.sql(e,"this");i=i?`${i} `:"";let o=this.sql(e,"table");o=o?`${this._constructor.INDEX_ON} ${o}`:"";let c=o?"":"INDEX ",p=this.sql(e,"params");return`${t}${s}${r}${c}${i}${o}${p}`}identifierSql(e){let t=e.name,s=t.toLowerCase();return t=this.normalize&&!e.args.quoted?s:t,t=t.replaceAll(this.identifierEnd,this.escapedIdentifierEnd),(e.args.quoted||this.dialect.canQuote(e,{identify:this.identify})||this._constructor.RESERVED_KEYWORDS.has(s)||!this.dialect._constructor.IDENTIFIERS_CAN_START_WITH_DIGIT&&/^\d/.test(t))&&(t=`${this.identifierStart}${t}${this.identifierEnd}`),t}hexSql(e){let t=this._constructor.HEX_FUNC,s=this.func(t,[this.sql(e,"this")]);return this.dialect._constructor.HEX_LOWERCASE&&(s=this.func("LOWER",[s])),s}lowerHexSql(e){let t=this._constructor.HEX_FUNC,s=this.func(t,[this.sql(e,"this")]);return this.dialect._constructor.HEX_LOWERCASE||(s=this.func("LOWER",[s])),s}inputOutputFormatSql(e){let t=this.sql(e,"inputFormat"),s=t?`INPUTFORMAT ${t}`:"",r=this.sql(e,"outputFormat"),i=r?`OUTPUTFORMAT ${r}`:"";return[s,i].join(this.sep())}nationalSql(e,t={}){let{prefix:s="N"}=t,r=this.sql(Hl(e.name));return`${s}${r}`}partitionSql(e){return`${e.args.subpartition?"SUBPARTITION":"PARTITION"}(${this.expressions(e,{flat:!0})})`}propertiesSql(e){let t=[],s=[];for(let p of e.args.expressions||[]){let u=this._constructor.PROPERTIES_LOCATION.get(p._constructor);u==="postWith"?s.push(p):u==="postSchema"&&t.push(p)}let r=new He({expressions:t});r.parent=e.parent;let i=new He({expressions:s});i.parent=e.parent;let o=this.rootProperties(r),c=this.withProperties(i);return o&&c&&!this.pretty&&(c=` ${c}`),o+c}rootProperties(e){return 0<(e.args.expressions||[]).length?this.expressions(e,{indent:!1,sep:" "}):""}properties(e,t={}){let{prefix:s="",sep:r=", ",suffix:i="",wrapped:o=!0}=t;if(0<(e.args.expressions||[]).length){let c=this.expressions(e,{sep:r,indent:!1});if(c){let p=o?this.wrap(c):c;return`${s}${s.trim()?" ":""}${p}${i}`}}return""}withProperties(e){return this.properties(e,{prefix:this.seg(this._constructor.WITH_PROPERTIES_PREFIX,"")})}locateProperties(e){let t=new Map,s=e.args.expressions||[];for(let r of s){let i=this._constructor.PROPERTIES_LOCATION.get(r._constructor)||"unsupported";i!=="unsupported"?(t.has(i)||t.set(i,[]),t.get(i)?.push(r)):this.unsupported(`Unsupported property ${r._constructor.key}`)}return t}propertyName(e,t={}){let{stringKey:s=!1}=t;return e.args.this instanceof ge?this.sql(e,"this"):s?`'${e.name}'`:e.name}propertySql(e){let t=e._constructor;if(t===w)return`${this.propertyName(e)}=${this.sql(e,"value")}`;let s=He.PROPERTY_TO_NAME?.[t.key];return s||this.unsupported(`Unsupported property ${e._constructor.key}`),`${s}=${this.sql(e,"this")}`}uuidPropertySql(e){return`UUID ${this.sql(e,"this")}`}likePropertySql(e){if(this._constructor.SUPPORTS_CREATE_TABLE_LIKE){let s=(e.args.expressions||[]).map(o=>`${o.name} ${this.sql(o,"value")}`).join(" "),r=s?` ${s}`:"",i=`LIKE ${this.sql(e,"this")}${r}`;return this._constructor.LIKE_PROPERTY_INSIDE_SCHEMA&&!(e.parent instanceof Rt)?`(${i})`:i}e.args.expressions?.length&&this.unsupported("Transpilation of LIKE property options is unsupported");let t=Ye("*").from(e.args.this).limit(0);return`AS ${this.sql(t)}`}fallbackPropertySql(e){let t=e.args.no?"NO ":"",s=e.args.protection?" PROTECTION":"";return`${t}FALLBACK${s}`}journalPropertySql(e){let t=e.args.no?"NO ":"",s=e.args.local,r=s?`${s} `:"",i=e.args.dual?"DUAL ":"",o=e.args.before?"BEFORE ":"",c=e.args.after?"AFTER ":"";return`${t}${r}${i}${o}${c}JOURNAL`}freespacePropertySql(e){let t=this.sql(e,"this"),s=e.args.percent?" PERCENT":"";return`FREESPACE=${t}${s}`}checksumPropertySql(e){let t;return e.args.default?t="DEFAULT":e.args.on?t="ON":t="OFF",`CHECKSUM=${t}`}mergeBlockRatioPropertySql(e){if(e.args.no)return"NO MERGEBLOCKRATIO";if(e.args.default)return"DEFAULT MERGEBLOCKRATIO";let t=e.args.percent?" PERCENT":"";return`MERGEBLOCKRATIO=${this.sql(e,"this")}${t}`}dataBlocksizePropertySql(e){let t=e.args.default,s=e.args.minimum,r=e.args.maximum;if(t||s||r){let c;return t?c="DEFAULT":s?c="MINIMUM":c="MAXIMUM",`${c} DATABLOCKSIZE`}let i=e.args.units,o=i?` ${i}`:"";return`DATABLOCKSIZE=${this.sql(e,"size")}${o}`}blockCompressionPropertySql(e){let t=e.args.autotemp,s=e.args.always,r=e.args.default,i=e.args.manual,o=e.args.never,c;return t!==void 0?c=`AUTOTEMP${this.sql(t)}`:s?c="ALWAYS":r?c="DEFAULT":i?c="MANUAL":o?c="NEVER":c="",`BLOCKCOMPRESSION=${c}`}isolatedLoadingPropertySql(e){let s=e.args.no?" NO":"",i=e.args.concurrent?" CONCURRENT":"",o=this.sql(e,"target");return o=o?` ${o}`:"",`WITH${s}${i} ISOLATED LOADING${o}`}partitionBoundSpecSql(e){if(Array.isArray(e.args.this))return`IN (${this.expressions(e,{key:"this",flat:!0})})`;if(e.args.this){let r=this.sql(e,"this"),i=this.sql(e,"expression");return`WITH (MODULUS ${r}, REMAINDER ${i})`}let t=this.expressions(e,{key:"fromExpressions",flat:!0}),s=this.expressions(e,{key:"toExpressions",flat:!0});return`FROM (${t}) TO (${s})`}partitionedOfPropertySql(e){let t=this.sql(e,"this"),s=e.args.expression??"";return s instanceof au?s=` FOR VALUES ${this.sql(s)}`:s=" DEFAULT",`PARTITION OF ${t}${s}`}lockingPropertySql(e){let t=e.args.kind,s=e.args.this?` ${this.sql(e,"this")}`:"",r=e.args.forOrIn,i=r?` ${r}`:"",o=e.args.lockType,c=e.args.override?" OVERRIDE":"";return`LOCKING ${t}${s}${i} ${o}${c}`}withDataPropertySql(e){let t=`WITH ${e.args.no?"NO ":""}DATA`,s=e.args.statistics,r="";return s!==void 0&&(r=` AND ${s?"":"NO "}STATISTICS`),`${t}${r}`}withSystemVersioningPropertySql(e){let t=this.sql(e,"this");t=t?`HISTORY_TABLE=${t}`:"";let s=this.sql(e,"dataConsistency"),r=s?`DATA_CONSISTENCY_CHECK=${s}`:void 0,i=this.sql(e,"retentionPeriod"),o=i?`HISTORY_RETENTION_PERIOD=${i}`:void 0,c;t?c=this.func("ON",[t,r,o]):c=e.args.on?"ON":"OFF";let p=`SYSTEM_VERSIONING=${c}`;return e.args.with?`WITH(${p})`:p}insertSql(e){let t=this.sql(e,"hint"),s=e.args.overwrite,r=e.args.this instanceof su,i;r?i=s?" OVERWRITE":" INTO":i=s?this._constructor.INSERT_OVERWRITE:" INTO";let o=this.sql(e,"stored"),c=o?` ${o}`:"",p=e.args.alternative,u=p?` OR ${p}`:"",h=e.args.ignore?" IGNORE":"";e.args.isFunction&&(i=`${i} FUNCTION`);let f=`${i} ${this.sql(e,"this")}`,x=e.args.exists?" IF EXISTS":"",T=this.sql(e,"where"),y=T?`${this.sep()}REPLACE WHERE ${T}`:"",C=`${this.sep()}${this.sql(e,"expression")}`,I=this.sql(e,"conflict"),b=I?` ${I}`:"",k=e.args.byName?" BY NAME":"",B=e.args.default?"DEFAULT VALUES":"",j=this.sql(e,"returning");this._constructor.RETURNING_END?C=`${C}${b}${B}${j}`:C=`${j}${C}${b}`;let Q=this.sql(e,"partition"),ne=Q?` ${Q}`:"",H=this.sql(e,"settings"),Pe=H?` ${H}`:"",me=this.sql(e,"source"),Ot=me?`TABLE ${me}`:"",gt=`INSERT${t}${u}${h}${f}${c}${k}${x}${ne}${Pe}${y}${C}${Ot}`;return this.prependCtes(e,gt)}introducerSql(e){return`${this.sql(e,"this")} ${this.sql(e,"expression")}`}killSql(e){return`KILL ${e.args.kind?`${e.args.kind} `:""}${this.sql(e,"this")}`}pseudoTypeSql(e){return e.name}objectIdentifierSql(e){return e.name}onConflictSql(e){let t=e.args.duplicate?"ON DUPLICATE KEY":"ON CONFLICT",s=this.sql(e,"constraint");s=s?` ON CONSTRAINT ${s}`:"";let r=this.expressions(e,{key:"conflictKeys",flat:!0});r&&(r=`(${r})`);let i=this.sql(e,"indexPredicate");r=`${r}${i} `;let o=this.sql(e,"action"),c=this.expressions(e,{flat:!0});c&&(c=` ${this._constructor.DUPLICATE_KEY_UPDATE_WITH_SET?"SET ":""}${c}`);let p=this.sql(e,"where");return`${t}${s}${r}${o}${c}${p}`}returningSql(e){return this.opExpressions("RETURNING",e)}rowFormatDelimitedPropertySql(e){let t=this.sql(e,"fields"),s=t?` FIELDS TERMINATED BY ${t}`:"",r=this.sql(e,"collectionItems"),i=r?` COLLECTION ITEMS TERMINATED BY ${r}`:"",o=this.sql(e,"mapKeys"),c=o?` MAP KEYS TERMINATED BY ${o}`:"",p=this.sql(e,"lines"),u=p?` LINES TERMINATED BY ${p}`:"",h=this.sql(e,"null"),g=h?` NULL DEFINED AS ${h}`:"";return`ROW FORMAT DELIMITED${s}${i}${c}${u}${g}`}withTableHintSql(e){return`WITH (${this.expressions(e,{flat:!0})})`}indexTableHintSql(e){let t=`${this.sql(e,"this")} INDEX`,s=this.sql(e,"target");return s=s?` FOR ${s}`:"",`${t}${s} (${this.expressions(e,{flat:!0})})`}historicalDataSql(e){let t=this.sql(e,"this"),s=this.sql(e,"kind"),r=this.sql(e,"expression");return`${t} (${s} => ${r})`}tableParts(e){return[e.args.catalog,e.args.db,e.args.this].filter(t=>t!==void 0).map(t=>this.sql(t)).join(".")}tableSql(e,t={}){let{sep:s=" AS "}=t,r=this.tableParts(e),i=e.args.only?"ONLY ":"",o=this.sql(e,"partition");o=o?` ${o}`:"";let c=this.sql(e,"version");c=c?` ${c}`:"";let p=this.sql(e,"alias");p=p?`${s}${p}`:"";let u=this.sql(e,"sample"),h="",g="";this.dialect._constructor.ALIAS_POST_TABLESAMPLE?h=u:g=u,this.dialect._constructor.ALIAS_POST_VERSION?h=`${h}${c}`:g=`${g}${c}`;let f=this.expressions(e,{key:"hints",sep:" "});f=f&&this._constructor.TABLE_HINTS?` ${f}`:"";let x=this.expressions(e,{key:"pivots",sep:"",flat:!0}),T=this.indent(this.expressions(e,{key:"joins",sep:"",flat:!0}),{skipFirst:!0}),y=this.expressions(e,{key:"laterals",sep:""}),C=this.sql(e,"format");if(C){let H=this.sql(e,"pattern"),Pe=H?`, PATTERN => ${H}`:"";C=` (FILE_FORMAT => ${C}${Pe})`}let I=e.args.ordinality||"";I&&(I=` WITH ORDINALITY${p}`,p="");let b=this.sql(e,"when"),k=r;b&&(k=`${r} ${b}`);let B=this.sql(e,"changes");B=B?` ${B}`:"";let j=this.expressions(e,{key:"rowsFrom"});j&&(k=`ROWS FROM ${this.wrap(j)}`);let Q=e.args.indexed,ne;return Q!==void 0?ne=Q?` INDEXED BY ${this.sql(Q)}`:" NOT INDEXED":ne="",`${i}${k}${B}${o}${C}${h}${p}${ne}${f}${x}${g}${T}${y}${I}`}tableFromRowsSql(e){let t=this.func("TABLE",[e.args.this]),s=this.sql(e,"alias");s=s?` AS ${s}`:"";let r=this.sql(e,"sample"),i=this.expressions(e,{key:"pivots",sep:"",flat:!0}),o=this.indent(this.expressions(e,{key:"joins",sep:"",flat:!0}),{skipFirst:!0});return`${t}${s}${i}${r}${o}`}pivotSql(e){let t=this.expressions(e,{flat:!0}),s=e.args.unpivot?"UNPIVOT":"PIVOT",r=this.sql(e,"group");if(e.args.this){let g=this.sql(e,"this"),f;if(!t)f=`UNPIVOT ${g}`;else{let x=`${this.seg("ON")} ${t}`,T=this.sql(e,"into");T=T?`${this.seg("INTO")} ${T}`:"";let y=this.expressions(e,{key:"using",flat:!0});y=y?`${this.seg("USING")} ${y}`:"",f=`${s} ${g}${x}${T}${y}${r}`}return this.prependCtes(e,f)}let i=this.sql(e,"alias");i=i?` AS ${i}`:"";let o=this.expressions(e,{key:"fields",sep:" ",dynamic:!0,newLine:!0,skipFirst:!0,skipLast:!0}),c=e.args.includeNulls,p;c!==void 0?p=c?" INCLUDE NULLS ":" EXCLUDE NULLS ":p="";let u=this.sql(e,"defaultOnNull");u=u?` DEFAULT ON NULL (${u})`:"";let h=`${this.seg(s)}${p}(${t} FOR ${o}${u}${r})${i}`;return this.prependCtes(e,h)}versionSql(e){let t=`FOR ${e.name}`,s=e.text?.("kind")||"",r=this.sql(e,"expression");return`${t} ${s} ${r}`}tupleSql(e){return`(${this.expressions(e,{dynamic:!0,newLine:!0,skipFirst:!0,skipLast:!0})})`}updateFromJoinsSql(e){let t=e.args.from;if(this.constructor.UPDATE_STATEMENT_SUPPORTS_FROM||!t)return["",this.sql(e,"from")];let s=e.args.this;if(s instanceof _){let c=K(s.aliasOrName);for(let p of e.args.expressions||[]){let u=p.args.this;u instanceof $&&!u.table&&u.setArgKey("table",c)}}let r=t.args.this,i=(Y(r,d)?r.args.joins:void 0)||[];0<i.length&&Y(r,d)&&r.setArgKey("joins",void 0);let o=Y(r,d)?this.sql(new xe({this:r,on:We()})):"";for(let c of i)!c.getArgKey("on")&&!c.getArgKey("using")&&c.setArgKey("on",We()),o+=this.sql(c);return[o,""]}updateSql(e){let t=this.sql(e,"this"),[s,r]=this.updateFromJoinsSql(e),i=this.expressions(e,{flat:!0}),o=this.sql(e,"where"),c=this.sql(e,"returning"),p=this.sql(e,"order"),u=this.sql(e,"limit"),h;this._constructor.RETURNING_END?h=`${r}${o}${c}`:h=`${c}${r}${o}`;let g=this.expressions(e,{key:"options"});g=g?` OPTION(${g})`:"";let f=`UPDATE ${t}${s} SET ${i}${h}${p}${u}${g}`;return this.prependCtes(e,f)}valuesSql(e,t={}){let{valuesAsTable:s=!0}=t;if(s&&this._constructor.VALUES_AS_TABLE||!e.findAncestor(rt,xe)){let g=this.expressions(e),f=this.sql(e,"alias"),x=`VALUES${this.seg("")}${g}`;return this._constructor.WRAP_DERIVED_VALUES&&(f||[rt,_].some(y=>e.parent instanceof y))&&(x=`(${x})`),x=this.queryModifiers(e,x),f?`${x} AS ${f}`:x}let i=Y(e.args.alias,pe)?e.args.alias:void 0,o=i?.columns,c=[],p=e.args.expressions;if(p)for(let g=0;g<p.length;g++){let x=p[g].args.expressions||[];g===0&&o&&0<o.length&&(x=x.map((T,y)=>{let C=o[y];return Be(T,C instanceof v?C:C.name,{copy:!1})})),c.push(new se({expressions:x}))}if(c.length===0)return"";if(this.pretty){let g=c.reduce((T,y)=>WA([T,y],{distinct:!1,copy:!1})??T),f=i?.args.this,x=f instanceof d?f:void 0;return this.subquerySql(g.subquery(x,{copy:!1}))}let u=i?` AS ${this.sql(i,"this")}`:"";return`(${c.map(g=>this.sql(g)).join(" UNION ALL ")})${u}`}varSql(e){return this.sql(e,"this")}intoSql(e){Cb.call(this,e,"expressions");let t=e.args.temporary?" TEMPORARY":"",s=e.args.unlogged?" UNLOGGED":"",r=t||s;return`${this.seg("INTO")}${r} ${this.sql(e,"this")}`}fromSql(e){return`${this.seg("FROM")} ${this.sql(e,"this")}`}groupingSetsSql(e){let t=this.expressions(e,{indent:!1});return`GROUPING SETS ${this.wrap(t)}`}rollupSql(e){let t=this.expressions(e,{indent:!1});return t?`ROLLUP ${this.wrap(t)}`:"WITH ROLLUP"}rollupIndexSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0}),r=this.sql(e,"fromIndex"),i=r?` FROM ${r}`:"",o=e.args.properties;o&&re(o,He);let c=o?` ${this.properties(o,{prefix:"PROPERTIES"})}`:"";return`${t}(${s})${i}${c}`}rollupPropertySql(e){return`ROLLUP (${this.expressions(e,{flat:!0})})`}cubeSql(e){let t=this.expressions(e,{indent:!1});return t?`CUBE ${this.wrap(t)}`:"WITH CUBE"}groupSql(e){let t=e.args.all,s="";t===!0?s=" ALL":t===!1&&(s=" DISTINCT");let r=this.opExpressions(`GROUP BY${s}`,e),i=this.expressions(e,{key:"groupingSets"}),o=this.expressions(e,{key:"cube"}),c=this.expressions(e,{key:"rollup"}),p=JI([i?this.seg(i):"",o?this.seg(o):"",c?this.seg(c):"",e.args.totals?this.seg("WITH TOTALS"):""],{sep:this._constructor.GROUPINGS_SEP}),u=r;return e.args.expressions?.length&&p&&p.trim()!=="WITH CUBE"&&p.trim()!=="WITH ROLLUP"&&(u=`${u}${this._constructor.GROUPINGS_SEP}`),`${u}${p}`}havingSql(e){let t=this.indent(this.sql(e,"this"));return`${this.seg("HAVING")}${this.sep()}${t}`}connectSql(e){let t=this.sql(e,"start");t=t?this.seg(`START WITH ${t}`):"";let s=e.args.nocycle?" NOCYCLE":"",r=this.sql(e,"connect"),i=this.seg(`CONNECT BY${s} ${r}`);return t+i}priorSql(e){return`PRIOR ${this.sql(e,"this")}`}joinSql(e){let t=this._constructor,s;!t.SEMI_ANTI_JOIN_WITH_SIDE&&(e.args.kind==="semi"||e.args.kind==="anti")?s=void 0:s=e.args.side?.toUpperCase();let r=[e.args.method,e.args.global?"GLOBAL":void 0,s,e.args.kind==="straightJoin"?"STRAIGHT_JOIN":e.args.kind?.toUpperCase(),e.args.hint&&t.JOIN_HINTS?e.args.hint:void 0,e.args.directed&&t.DIRECTED_JOINS?"DIRECTED":void 0].filter(x=>x).join(" "),i=this.sql(e,"matchCondition");i=i?` MATCH_CONDITION (${i})`:"";let o=this.sql(e,"on"),c=e.args.using;!o&&c&&(o=c.map(x=>this.sql(x)).join(", "));let p=e.args.this,u=this.sql(p),h=this.expressions(e);if(h&&(u=`${u},${this.seg(h)}`),o){o=this.indent(o,{skipFirst:!0});let x=this.pretty?this.seg(" ".repeat(this.pad)):" ";c?o=`${x}USING (${o})`:o=`${x}ON ${o}`}else if(!r)return p instanceof Ct&&p.args.crossApply!==void 0?` ${u}`:`, ${u}`;let g=e.args.kind!=="straightJoin"?r?`${r} JOIN`:"JOIN":r,f=this.expressions(e,{key:"pivots",sep:"",flat:!0});return`${this.seg(g)} ${u}${i}${o}${f}`}lambdaSql(e,t={}){let{arrowSep:s="->",wrap:r=!0}=t,i=this.expressions(e,{flat:!0});return i=r&&1<i.split(",").length?`(${i})`:i,`${i} ${s} ${this.sql(e,"this")}`}lateralOp(e){let t=e.args.crossApply,s="";return t===!0?s="INNER JOIN ":t===!1&&(s="LEFT JOIN "),`${s}LATERAL`}lateralSql(e){let t=this.sql(e,"this");if(e.args.view){let i=e.args.alias,o=this.expressions(i,{key:"columns",flat:!0}),c=i?.name?` ${i.name}`:"",p=o?` AS ${o}`:"",u=e.args.outer?" OUTER":"";return`${this.seg(`LATERAL VIEW${u}`)}${this.sep()}${t}${c}${p}`}let s=this.sql(e,"alias");s=s?` AS ${s}`:"";let r=e.args.ordinality||"";return r&&(r=` WITH ORDINALITY${s}`,s=""),`${this.lateralOp(e)} ${t}${s}${r}`}limitSql(e,t={}){let{top:s=!1}=t,r=this.sql(e,"this"),i=["offset","expression"].map(h=>e.getArgKey(h)).filter(Boolean).map(h=>this._constructor.LIMIT_ONLY_LITERALS?this.simplifyUnlessLiteral(h):h),o=i.map(h=>this.sql(h)).join(", ");s&&i.some(h=>!h.isNumber)&&(o=`(${o})`);let c=this.expressions(e,{flat:!0}),p=this.sql(e,"limitOptions");c=c?` BY ${c}`:"";let u=s?"TOP":"LIMIT";return`${r}${this.seg(u)} ${o}${p}${c}`}offsetSql(e){let t=this.sql(e,"this"),s=e.args.expression;s=this._constructor.LIMIT_ONLY_LITERALS?this.simplifyUnlessLiteral(s):s;let r=this.expressions(e,{flat:!0}),i=r?` BY ${r}`:"";return`${t}${this.seg("OFFSET")} ${this.sql(s)}${i}`}setItemSql(e){let t=this.sql(e,"kind").toUpperCase();!this._constructor.SET_ASSIGNMENT_REQUIRES_VARIABLE_KEYWORD&&t==="VARIABLE"?t="":t=t?`${t} `:"";let s=this.sql(e,"this"),r=this.expressions(e),i=this.sql(e,"collate");return i=i?` COLLATE ${i}`:"",`${e.args.global?"GLOBAL ":""}${t}${s}${r}${i}`}setSql(e){let t=` ${this.expressions(e,{flat:!0})}`,s=e.args.tag?" TAG":"";return`${e.args.unset?"UNSET":"SET"}${s}${t}`}queryBandSql(e){let t=this.sql(e,"this"),s=e.args.update?" UPDATE":"",r=this.sql(e,"scope"),i=r?` FOR ${r}`:"";return`QUERY_BAND = ${t}${s}${i}`}pragmaSql(e){return`PRAGMA ${this.sql(e,"this")}`}lockSql(e){if(!this._constructor.LOCKING_READS_SUPPORTED)return this.unsupported("Locking reads using 'FOR UPDATE/SHARE' are not supported"),"";let t=e.args.update,s=e.args.key,r;(t instanceof N?t.args.this!=="0":!!t)?r=s?"FOR NO KEY UPDATE":"FOR UPDATE":r=s?"FOR KEY SHARE":"FOR SHARE";let o=this.expressions(e,{flat:!0}),c=o?` OF ${o}`:"",p=e.args.wait,u="";return p!==void 0&&(p instanceof N?u=` WAIT ${this.sql(p)}`:u=p?" NOWAIT":" SKIP LOCKED"),`${r}${c}${u||""}`}literalSql(e){let t=e.args.this||"";return e.isString&&(t=`${this.dialect._constructor.QUOTE_START}${this.escapeStr(t)}${this.dialect._constructor.QUOTE_END}`),t}escapeStr(e,t={}){let{escapeBackslash:s=!0,delimiter:r,escapedDelimiter:i,isByteString:o=!1}=t;(o?this.dialect._constructor.BYTE_STRINGS_SUPPORT_ESCAPED_SEQUENCES:this.dialect._constructor.STRINGS_SUPPORT_ESCAPED_SEQUENCES)&&(e=Array.from(e).map(u=>{let h=this.dialect._constructor.ESCAPED_SEQUENCES[u];return h!==void 0&&(s||u!=="\\")?h:u}).join(""));let p=r||this.dialect._constructor.QUOTE_END;return this.replaceLineBreaks(e).replaceAll(p,i||this.escapedQuoteEnd)}loadDataSql(e){let t=e.args.local?" LOCAL":"",s=` INPATH ${this.sql(e,"inpath")}`,r=e.args.overwrite?" OVERWRITE":"",i=` INTO TABLE ${this.sql(e,"this")}`,o=this.sql(e,"partition"),c=o?` ${o}`:"",p=this.sql(e,"inputFormat"),u=p?` INPUTFORMAT ${p}`:"",h=this.sql(e,"serde"),g=h?` SERDE ${h}`:"";return`LOAD DATA${t}${s}${r}${i}${c}${u}${g}`}nullSql(...e){return"NULL"}booleanSql(e){return e.args.this?"TRUE":"FALSE"}boolandSql(e){return`((${this.sql(e,"this")}) AND (${this.sql(e,"expression")}))`}boolorSql(e){return`((${this.sql(e,"this")}) OR (${this.sql(e,"expression")}))`}orderSql(e,t={}){let{flat:s=!1}=t,r=this.sql(e,"this");r=r&&`${r} `;let i=e.args.siblings?"SIBLINGS ":"";return this.opExpressions(`${r}ORDER ${i}BY`,e,{flat:s||!!r})}withFillSql(e){let t=this.sql(e,"from");t=t?` FROM ${t}`:"";let s=this.sql(e,"to");s=s?` TO ${s}`:"";let r=this.sql(e,"step");r=r?` STEP ${r}`:"";let o=e.args.interpolate?.map(p=>p instanceof Re?`${this.sql(p,"alias")} AS ${this.sql(p,"this")}`:this.sql(p,"this"))||[],c=o.length?` INTERPOLATE (${o.join(", ")})`:"";return`WITH FILL${t}${s}${r}${c}`}clusterSql(e){return this.opExpressions("CLUSTER BY",e)}distributeSql(e){return this.opExpressions("DISTRIBUTE BY",e)}sortSql(e){return this.opExpressions("SORT BY",e)}orderedSql(e){let t=e.args.desc,s=!t,r=e.args.nullsFirst,i=!r,o=this.dialect._constructor.NULL_ORDERING==="nulls_are_large",c=this.dialect._constructor.NULL_ORDERING==="nulls_are_small",p=this.dialect._constructor.NULL_ORDERING==="nulls_are_last",u=this.sql(e,"this"),h=t?" DESC":t===!1?" ASC":"",g="";if(r&&(s&&o||t&&c||p)?g=" NULLS FIRST":i&&(s&&c||t&&o)&&!p&&(g=" NULLS LAST"),g&&this._constructor.NULL_ORDERING_SUPPORTED!=="supported"){let x=e.findAncestor(Ue,se),T,y;if(x instanceof Ue&&(T=x.args.this,T?.constructor&&(T.constructor.key==="ignoreNulls"||T.constructor.key==="respectNulls")&&(T=T.args.this),y=x.args.spec),!(T instanceof d&&this._constructor.WINDOW_FUNCS_WITH_NULL_ORDERING.some(I=>T instanceof I)&&(!y||y instanceof pu&&String(y.args.kind).toUpperCase()==="ROWS")))if(T&&y)this.unsupported(`'${g.trim()}' translation not supported in window function ${T._constructor.name}`),g="";else if(this._constructor.NULL_ORDERING_SUPPORTED==="partial"&&(s&&g===" NULLS LAST"||t&&g===" NULLS FIRST")){let I=e.findAncestor(q,Ue,se);I instanceof Ue&&(I=I.args.this),I instanceof q&&(this.unsupported(`'${g.trim()}' translation not supported for aggregate function ${I._constructor.name} with ${h} sort order`),g="")}else this._constructor.NULL_ORDERING_SUPPORTED==="unsupported"&&(e.args.this?.isInteger?this.unsupported(`'${g.trim()}' translation not supported with positional ordering`):e.args.this instanceof vr||(u=`CASE WHEN ${u} IS NULL THEN 1 ELSE 0 END${g===" NULLS FIRST"?" DESC":""}, ${u}`),g="")}let f=this.sql(e,"withFill");return f=f?` ${f}`:"",`${u}${h}${g}${f}`}matchRecognizeMeasureSql(e){let t=this.sql(e,"windowFrame"),s=t?`${t} `:"",r=this.sql(e,"this");return`${s}${r}`}matchRecognizeSql(e){let t=this.partitionBySql(e),s=this.sql(e,"order"),r=this.expressions(e,{key:"measures"}),i=r?this.seg(`MEASURES${this.seg(r)}`):"",o=this.sql(e,"rows"),c=o?this.seg(o):"",p=this.sql(e,"after"),u=p?this.seg(p):"",h=this.sql(e,"pattern"),g=h?this.seg(`PATTERN (${h})`):"",f=(e.args.define||[]).map(b=>`${this.sql(b,"alias")} AS ${this.sql(b,"this")}`),x=this.expressions(void 0,{sqls:f}),T=x?this.seg(`DEFINE${this.seg(x)}`):"",y=[t,s,i,c,u,g,T].join(""),C=this.sql(e,"alias"),I=C?` ${C}`:"";return`${this.seg("MATCH_RECOGNIZE")} ${this.wrap(y)}${I}`}queryModifiers(e,...t){let s=e.getArgKey("limit");if(s!==void 0&&!(s instanceof hr||s instanceof kt))return"";let r=this._constructor.LIMIT_FETCH;return r==="LIMIT"&&s instanceof hr?s=new kt({expression:$e(s.args.count)}):r==="FETCH"&&s instanceof kt&&(s=new hr({direction:"FIRST",count:$e(s.args.expression)})),JI([...t,...e.args.joins?.map(i=>this.sql(i))??[],this.sql(e,"match"),...e.args.laterals?.map(i=>this.sql(i))??[],this.sql(e,"prewhere"),this.sql(e,"where"),this.sql(e,"connect"),this.sql(e,"group"),this.sql(e,"having"),...Array.from(this._constructor.AFTER_HAVING_MODIFIER_TRANSFORMS.values()).map(i=>i.call(this,e)),this.sql(e,"order"),...this.offsetLimitModifiers(e,{fetch:s instanceof hr},s),...this.afterLimitModifiers(e),this.optionsModifier(e),this.forModifiers(e)],{sep:""})}optionsModifier(e){let t=this.expressions(e,{key:"options"});return t?` ${t}`:""}forModifiers(e){let t=this.expressions(e,{key:"for"});return t?`${this.sep()}FOR XML${this.seg(t)}`:""}queryOptionSql(e){return this.unsupported("Unsupported query option."),""}afterLimitModifiers(e){let t=this.expressions(e,{key:"locks",sep:" "});return t=t?` ${t}`:"",[t,this.sql(e,"sample")]}selectSql(e){let t=e.args.into;!this._constructor.SUPPORTS_SELECT_INTO&&t&&t.pop();let s=this.sql(e,"hint"),r=this.sql(e,"distinct");r=r?` ${r}`:"";let i=this.sql(e,"kind"),o=e.args.limit,c="";this._constructor.LIMIT_IS_TOP&&o instanceof kt&&(c=this.limitSql(o,{top:!0}),o.pop());let p=this.expressions(e),u=this._constructor;if(i)if(u.SELECT_KINDS.includes(i))i=` AS ${i}`;else{if(i==="STRUCT"){let C=(e.args.expressions||[]).map(I=>I instanceof Re?new ot({this:I.args.alias instanceof v?I.args.alias:new v({this:I.args.alias?.toString()||""}),expression:I.args.this}):I);p=this.expressions(void 0,{sqls:[new Es({expressions:C})]})}i=""}let h=this.expressions(e,{key:"operationModifiers",sep:" "}),g=h?`${this.sep()}${h}`:"",f=u.LIMIT_IS_TOP?`${r}${s}${c}`:`${c}${s}${r}`,x=e.args.exclude;if(!u.STAR_EXCLUDE_REQUIRES_DERIVED_TABLE&&x){let y=this.expressions({sqls:x,flat:!0});p=`${p}${this.seg("EXCLUDE")} (${y})`}p=p&&`${this.sep()}${p}`;let T=this.queryModifiers(e,`SELECT${f}${g}${i}${p}`,this.sql(e,"into",{comment:!1}),this.sql(e,"from",{comment:!1}));if(T=this.prependCtes(e,T),u.STAR_EXCLUDE_REQUIRES_DERIVED_TABLE&&x){e.setArgKey("exclude",void 0);let y=e.subquery({copy:!1}),C=new Ne({except:x});T=this.sql(Ye(C).from(y,{copy:!1}))}if(!u.SUPPORTS_SELECT_INTO&&t){re(t,iu);let y="";t.args.temporary?y=" TEMPORARY":u.SUPPORTS_UNLOGGED_TABLES&&t.args.unlogged&&(y=" UNLOGGED"),T=`CREATE${y} TABLE ${this.sql(t.args.this)} AS ${T}`}return T}schemaSql(e){let t=this.sql(e,"this"),s=this.schemaColumnsSql(e);return t&&s?`${t} ${s}`:t||s}schemaColumnsSql(e){return e.args.expressions?.length?`(${this.sep("")}${this.expressions(e)}${this.seg(")","")}`:""}starSql(e){let t=this.expressions(e,{key:"except",flat:!0});t=t?`${this.seg(this._constructor.STAR_EXCEPT)} (${t})`:"";let s=this.expressions(e,{key:"replace",flat:!0});s=s?`${this.seg("REPLACE")} (${s})`:"";let r=this.expressions(e,{key:"rename",flat:!0});return r=r?`${this.seg("RENAME")} (${r})`:"",`*${t}${s}${r}`}parameterSql(e){let t=this.sql(e,"this");return`${this._constructor.PARAMETER_TOKEN}${t}`}sessionParameterSql(e){let t=this.sql(e,"this"),s=e.text("kind");return s&&(s=`${s}.`),`@@${s}${t}`}placeholderSql(e){return e.args.this!==void 0?`${this._constructor.NAMED_PLACEHOLDER_TOKEN}${e.name}`:"?"}subquerySql(e,t={}){let{sep:s=" AS "}=t,r=this.sql(e,"alias");r=r?`${s}${r}`:"";let i=this.sql(e,"sample");this.dialect._constructor.ALIAS_POST_TABLESAMPLE&&i&&(r=`${i}${r}`,e.setArgKey("sample",void 0));let o=this.expressions(e,{key:"pivots",sep:"",flat:!0}),c=this.queryModifiers(e,this.wrap(e),r,o);return this.prependCtes(e,c)}qualifySql(e){let t=this.indent(this.sql(e,"this"));return`${this.seg("QUALIFY")}${this.sep()}${t}`}unnestSql(e){let t=this.expressions(e,{flat:!0}),s=e.args.alias,r=e.args.offset;this._constructor.UNNEST_WITH_ORDINALITY&&s&&r instanceof v&&(re(s,pe),s.args.columns?s.args.columns.push(r):s.setArgKey("columns",[r]));let i="";if(s&&this.dialect._constructor.UNNEST_COLUMN_ONLY){re(s,pe);let c=s.columns;i=c[0]?this.sql(c[0]):""}else i=this.sql(s);i=i&&` AS ${i}`;let o="";return this._constructor.UNNEST_WITH_ORDINALITY?o=r?` WITH ORDINALITY${i}`:i:r instanceof d?o=`${i} WITH OFFSET AS ${this.sql(r)}`:r?o=`${i} WITH OFFSET`:o=i,`UNNEST(${t})${o}`}preWhereSql(e){return""}whereSql(e){let t=this.indent(this.sql(e,"this"));return`${this.seg("WHERE")}${this.sep()}${t}`}windowSql(e){let t=this.sql(e,"this"),s=this.partitionBySql(e),r=e.args.order;r&&re(r,Ie);let i=r?this.orderSql(r,{flat:!0}):"",o=this.sql(e,"spec"),c=this.sql(e,"alias"),p=this.sql(e,"over")||"OVER";t=`${t} ${e.argKey==="windows"?"AS":p}`;let u=e.args.first,h="";if(u!==void 0&&(h=u?"FIRST":"LAST"),!s&&!i&&!o&&c)return`${t} ${c}`;let g=this.formatArgs([c,h,s,i,o].filter(f=>f),{sep:" "});return`${t} (${g})`}partitionBySql(e){let t=this.expressions(e,{key:"partitionBy",flat:!0});return t?`PARTITION BY ${t}`:""}windowSpecSql(e){let t=this.sql(e,"kind"),s=JI([this.sql(e,"start"),this.sql(e,"startSide")],{sep:" "}),r=JI([this.sql(e,"end"),this.sql(e,"endSide")],{sep:" "})||"CURRENT ROW",i=`${t} BETWEEN ${s} AND ${r}`,o=this.sql(e,"exclude");return o&&(this._constructor.SUPPORTS_WINDOW_EXCLUDE?i+=` EXCLUDE ${o}`:this.unsupported("EXCLUDE clause is not supported in the WINDOW clause")),i}withinGroupSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return s=s.substring(1),`${t} WITHIN GROUP (${s})`}betweenSql(e){let t=this.sql(e,"this"),s=this.sql(e,"low"),r=this.sql(e,"high"),i=e.args.symmetric;if(i&&!this._constructor.SUPPORTS_BETWEEN_FLAGS)return`(${t} BETWEEN ${s} AND ${r} OR ${t} BETWEEN ${r} AND ${s})`;let o=i?" SYMMETRIC":i===!1&&this._constructor.SUPPORTS_BETWEEN_FLAGS?" ASYMMETRIC":"";return`${t} BETWEEN${o} ${s} AND ${r}`}bracketOffsetExpressions(e,t={}){if(e.args.jsonAccess)return e.args.expressions||[];let{indexOffset:s}=t,r=(s!==void 0?s:this.dialect._constructor.INDEX_OFFSET)-(e.args.offset||0),i=e.args.this instanceof d?e.args.this:new d({});return dA(i,e.args.expressions||[],r,{dialect:this.dialect})}bracketSql(e){let s=this.bracketOffsetExpressions(e).map(r=>this.sql(r)).join(", ");return`${this.sql(e,"this")}[${s}]`}allSql(e){let t=this.sql(e,"this"),s=e.args.this;return s&&!(s instanceof Ze||s instanceof Se)&&(t=this.wrap(t)),`ALL ${t}`}anySql(e){let t=this.sql(e,"this"),s=e.args.this;return Ls.some(r=>s instanceof r)||s instanceof Se?(Ls.some(r=>s instanceof r)&&(t=this.wrap(t)),`ANY${t}`):`ANY ${t}`}existsSql(e){return`EXISTS${this.wrap(e)}`}caseSql(e){let t=this.sql(e,"this"),s=[t?`CASE ${t}`:"CASE"],r=e.args.ifs;if(r)for(let o of r)s.push(`WHEN ${this.sql(o,"this")}`),s.push(`THEN ${this.sql(o,"true")}`);let i=this.sql(e,"default");return i&&s.push(`ELSE ${i}`),s.push("END"),this.pretty&&this.tooWide(s)?this.indent(s.join(`
|
|
11
|
-
`),{skipFirst:!0,skipLast:!0}):s.join(" ")}constraintSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});return`CONSTRAINT ${t} ${s}`}nextValueForSql(e){let t=e.args.order;t&&re(t,
|
|
12
|
-
`:" ";return i.join(c)}bitwiseAndSql(e){return this.binary(e,"&")}bitwiseLeftShiftSql(e){return this.binary(e,"<<")}bitwiseNotSql(e){return`~${this.sql(e,"this")}`}bitwiseOrSql(e){return this.binary(e,"|")}bitwiseRightShiftSql(e){return this.binary(e,">>")}bitwiseXorSql(e){return this.binary(e,"^")}castSql(e,t={}){let{safePrefix:s}=t,r=this.sql(e,"format");r=r?` FORMAT ${r}`:"";let i=this.sql(e,"to");i=i?` ${i}`:"";let o=this.sql(e,"action");o=o?` ${o}`:"";let c=this.sql(e,"default");return c=c?` DEFAULT ${c} ON CONVERSION ERROR`:"",`${s||""}CAST(${this.sql(e,"this")} AS${i}${c}${r}${o})`}strToTimeSql(e){return this.func("STR_TO_TIME",[e.args.this??"",e.args.format])}currentDateSql(e){let t=this.sql(e,"this");return t?`CURRENT_DATE(${t})`:"CURRENT_DATE"}collateSql(e){return this._constructor.COLLATE_IS_FUNC?this.functionFallbackSql(e):this.binary(e,"COLLATE")}commandSql(e){let t=this.sql(e,"this"),s=e.text("expression").trim();return`${t} ${s}`}commentSql(e){let t=this.sql(e,"this"),s=e.args.kind,r=e.args.materialized?" MATERIALIZED":"",i=e.args.exists?" IF EXISTS ":" ",o=this.sql(e,"expression");return`COMMENT${i}ON${r} ${s} ${t} IS ${o}`}mergeTreeTtlActionSql(e){let t=this.sql(e,"this"),s=e.args.delete?" DELETE":"",r=this.sql(e,"recompress"),i=r?` RECOMPRESS ${r}`:"",o=this.sql(e,"toDisk"),c=o?` TO DISK ${o}`:"",p=this.sql(e,"toVolume"),u=p?` TO VOLUME ${p}`:"";return`${t}${s}${i}${c}${u}`}mergeTreeTtlSql(e){let t=this.sql(e,"where"),s=this.sql(e,"group"),r=this.expressions(e,{key:"aggregates"}),i=r?`${this.seg("SET")}${this.seg(r)}`:"";return!t&&!s&&!i&&e.args.expressions?.length===1?`TTL ${this.expressions(e,{flat:!0})}`:`TTL${this.seg(this.expressions(e))}${t}${s}${i}`}transactionSql(e){let t=this.expressions(e,{key:"modes"});return`BEGIN${t?` ${t}`:""}`}commitSql(e){let t=e.args.chain,s="";return t!==void 0&&(s=t?" AND CHAIN":" AND NO CHAIN"),`COMMIT${s}`}rollbackSql(e){let t=e.args.savepoint;return`ROLLBACK${t?` TO ${t}`:""}`}alterColumnSql(e){let t=this.sql(e,"this"),s=this.sql(e,"dtype");if(s){let u=this.sql(e,"collate");u=u?` COLLATE ${u}`:"";let h=this.sql(e,"using");h=h?` USING ${h}`:"";let g=this._constructor.ALTER_SET_TYPE,f=g?`${g} `:"";return`ALTER COLUMN ${t} ${f}${s}${u}${h}`}let r=this.sql(e,"default");if(r)return`ALTER COLUMN ${t} SET DEFAULT ${r}`;let i=this.sql(e,"comment");if(i)return`ALTER COLUMN ${t} COMMENT ${i}`;let o=e.args.visible;if(o)return`ALTER COLUMN ${t} SET ${o}`;let c=e.args.allowNull,p=e.args.drop;return!p&&!c&&this.unsupported("Unsupported ALTER COLUMN syntax"),c!==void 0?`ALTER COLUMN ${t} ${p?"DROP":"SET"} NOT NULL`:`ALTER COLUMN ${t} DROP DEFAULT`}modifyColumnSql(e){return this._constructor.SUPPORTS_MODIFY_COLUMN||this.unsupported("MODIFY COLUMN is not supported in this dialect"),`MODIFY COLUMN ${this.sql(e,"this")}`}alterIndexSql(e){let t=this.sql(e,"this"),r=e.args.visible?"VISIBLE":"INVISIBLE";return`ALTER INDEX ${t} ${r}`}alterDistStyleSql(e){let t=this.sql(e,"this");return e.args.this instanceof Ve||(t=`KEY DISTKEY ${t}`),`ALTER DISTSTYLE ${t}`}alterSortKeySql(e){let t=e.args.compound?" COMPOUND":"",s=this.sql(e,"this"),r=this.expressions(e,{flat:!0});return r=r?`(${r})`:"",`ALTER${t} SORTKEY ${s||r}`}alterRenameSql(e,t={}){let{includeTo:s=!0}=t,r=e;this._constructor.RENAME_TABLE_WITH_DB||(r=e.transform(c=>c instanceof _?new _({this:c.args.this}):c).assertIs(Yn));let i=this.sql(r,"this");return`RENAME${s?" TO":""} ${i}`}renameColumnSql(e){let t=e.args.exists?" IF EXISTS":"",s=this.sql(e,"this"),r=this.sql(e,"to");return`RENAME COLUMN${t} ${s} TO ${r}`}alterSetSql(e){let t=this.expressions(e,{flat:!0});return this._constructor.ALTER_SET_WRAPPED&&(t=`(${t})`),`SET ${t}`}alterSql(e){let t=e.args.actions||[],s;if(!this.dialect._constructor.ALTER_TABLE_ADD_REQUIRED_FOR_EACH_COLUMN&&t[0]instanceof be)s=this.expressions(e,{key:"actions",flat:!0}),s=`ADD ${s}`;else{let T=[];for(let y of t){let C=y,I;C instanceof be||C instanceof Rt?I=this.addColumnSql(C):(I=this.sql(C),(C instanceof se||C instanceof or)&&(I=`AS ${I}`)),T.push(I)}s=this.formatArgs(T).replace(/^\n+/,"")}let r=e.args.iceberg&&this._constructor.SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY?"ICEBERG ":"",i=e.args.exists?" IF EXISTS":"",o=this.sql(e,"cluster");o=o?` ${o}`:"";let c=e.args.only?" ONLY":"",p=this.expressions(e,{key:"options"});p=p?`, ${p}`:"";let u=this.sql(e,"kind").toUpperCase(),h=e.args.notValid?" NOT VALID":"",g=e.args.check?" WITH CHECK":"",f=e.args.cascade&&this.dialect._constructor.ALTER_TABLE_SUPPORTS_CASCADE?" CASCADE":"",x=this.sql(e,"this");return x=x?` ${x}`:"",`ALTER ${r}${u}${i}${c}${x}${o}${g}${this.sep()}${s}${h}${p}${f}`}alterSessionSql(e){let t=this.expressions(e,{flat:!0});return`${e.args.unset?"UNSET":"SET"} ${t}`}addColumnSql(e){let t=this.sql(e),s;return e instanceof Rt?s=" COLUMNS":e instanceof be&&this._constructor.ALTER_TABLE_INCLUDE_COLUMN_KEYWORD?s=" COLUMN":s="",`ADD${s} ${t}`}dropPartitionSql(e){let t=this.expressions(e);return`DROP${e.args.exists?" IF EXISTS ":" "}${t}`}addConstraintSql(e){return`ADD ${this.expressions(e,{indent:!1})}`}addPartitionSql(e){let t=e.args.exists?"IF NOT EXISTS ":"",s=this.sql(e,"location");return s=s?` ${s}`:"",`ADD ${t}${this.sql(e,"this")}${s}`}distinctSql(e){let t=this.expressions(e,{flat:!0});if(!this._constructor.MULTI_ARG_DISTINCT&&1<(e.args.expressions?.length??0)){let r=qD();for(let i of e.args.expressions||[])r=r.when(i.is(le()),le());t=this.sql(r.else(`(${t})`))}t=t?` ${t}`:"";let s=this.sql(e,"on");return s=s?` ON ${s}`:"",`DISTINCT${t}${s}`}ignoreNullsSql(e){return this.embedIgnoreNulls(e,"IGNORE NULLS")}respectNullsSql(e){return this.embedIgnoreNulls(e,"RESPECT NULLS")}havingMaxSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=e.args.max?"MAX":"MIN";return`${t} HAVING ${r} ${s}`}intDivSql(e){return this.sql(new z({this:new wt({this:e.args.this,expression:e.args.expression}),to:new m({this:"int"})}))}dPipeSql(e){if(this.dialect._constructor.STRICT_STRING_CONCAT&&e.args.safe){let t=Array.from(e.flatten()).map(s=>X(s,"text",{copy:!1}));return this.func("CONCAT",t)}return this.binary(e,"||")}divSql(e){let t=e.left,s=e.right;if(!this.dialect._constructor.SAFE_DIVISION&&e.args.safe&&s?.replace(new qh({this:s.copy(),expression:N.number(0)})),this.dialect._constructor.TYPED_DIVISION&&!e.args.typed)!t?.isType(Array.from(m.REAL_TYPES))&&!s?.isType(Array.from(m.REAL_TYPES))&&t?.replace(X(t.copy(),"double"));else if(!this.dialect._constructor.TYPED_DIVISION&&e.args.typed&&t?.isType(Array.from(m.INTEGER_TYPES))&&s?.isType(Array.from(m.INTEGER_TYPES)))return this.sql(X(t.div(s),"bigint"));return this.binary(e,"/")}safeDivideSql(e){let t=mr(e.args.this,U),s=mr(e.args.expression,U);return!t||!s?"":this.sql(new fe({this:s.neq(0),true:t.div(s),false:le()}))}overlapsSql(e){return this.binary(e,"OVERLAPS")}distanceSql(e){return this.binary(e,"<->")}dotSql(e){return`${this.sql(e,"this")}.${this.sql(e,"expression")}`}eqSql(e){return this.binary(e,"=")}propertyEqSql(e){return this.binary(e,":=")}escapeSql(e){let t=e.args.this;return(t instanceof Qt||t instanceof Gs)&&(t.args.expression instanceof cs||t.args.expression instanceof Tt)&&!this._constructor.SUPPORTS_LIKE_QUANTIFIERS?this.likeSql(t,e):this.binary(e,"ESCAPE")}globSql(e){return this.binary(e,"GLOB")}gtSql(e){return this.binary(e,">")}gteSql(e){return this.binary(e,">=")}isSql(e){if(!this._constructor.IS_BOOL_ALLOWED&&e.args.expression instanceof at){let t=e.args.this;return this.sql(e.args.expression.args.this?t:ks(t instanceof d||typeof t=="string"?t:void 0))}return this.binary(e,"IS")}iLikeSql(e){return this.likeSql(e)}likeSql(e,t){let s=e.args.this,r=e.args.expression,i,o;if(e instanceof Qt?(i=Qt,o="LIKE"):(i=Gs,o="ILIKE"),(r instanceof cs||r instanceof Tt)&&!this._constructor.SUPPORTS_LIKE_QUANTIFIERS){let c,p=r.args.this instanceof d?r.args.this.unnest():void 0;p instanceof Ze?c=p.args.expressions:p?c=[p]:c=[];let u=r instanceof Tt?Vt:ve,h=n(x=>{let T=new i({this:s,expression:x});return t&&(T=new t.constructor({this:T,expression:t.args.expression.copy()})),T},"makeLike"),g=h(c[0]);for(let x=1;x<(c?.length||0);x++)g=u([g,h(c[x]||0)]);let f=t?t.parent:e.parent;return f instanceof Ce&&!(f instanceof Se)&&!(f instanceof g._constructor)&&(g=zs(g,{copy:!1})),this.sql(g)}return this.binary(e,o)}matchSql(e){return this.binary(e,"MATCH")}similarToSql(e){return this.binary(e,"SIMILAR TO")}ltSql(e){return this.binary(e,"<")}lteSql(e){return this.binary(e,"<=")}modSql(e){return this.binary(e,"%")}mulSql(e){return this.binary(e,"*")}neqSql(e){return this.binary(e,"<>")}nullSafeEqSql(e){return this.binary(e,"IS NOT DISTINCT FROM")}nullSafeNeqSql(e){return this.binary(e,"IS DISTINCT FROM")}subSql(e){return this.binary(e,"-")}tryCastSql(e){return this.castSql(e,{safePrefix:"TRY_"})}jsonCastSql(e){return this.castSql(e)}trySql(e){return this._constructor.TRY_SUPPORTED?this.func("TRY",[e.args.this]):(this.unsupported("Unsupported TRY function"),this.sql(e,"this"))}logSql(e){let t=e.args.this,s=e.args.expression;if(this.dialect._constructor.LOG_BASE_FIRST===!1)[t,s]=[s,t];else if(this.dialect._constructor.LOG_BASE_FIRST===void 0&&s){if(!t)return"";let r=t.name;if(r==="2"||r==="10")return this.func(`LOG${r}`,[s]);this.unsupported(`Unsupported logarithm with base ${this.sql(t)}`)}return this.func("LOG",[t,s])}useSql(e){let t=this.sql(e,"kind"),s=t?` ${t}`:"",r=this.sql(e,"this")||this.expressions(e,{flat:!0}),i=r?` ${r}`:"";return`USE${s}${i}`}binary(e,t){let s=[],r=[e],i=e._constructor;for(;0<r.length;){let o=r.pop();if(o instanceof U&&o._constructor===i){let c=o.args.operator;c&&(t=`OPERATOR(${this.sql(c)})`),r.push(o.right||""),r.push(` ${this.maybeComment(t,void 0,o.comments)} `),r.push(o.left||"")}else s.push(this.sql(o))}return s.join("")}ceilFloor(e){let t=this.sql(e,"to");return t?`${e._constructor.sqlName()}(${this.sql(e,"this")} TO ${t})`:this.functionFallbackSql(e)}functionFallbackSql(e){let t=[];for(let r of e._constructor.availableArgs){let i=e.getArgKey(r);Array.isArray(i)?t.push(...i):t.push(i)}let s;return this.dialect._constructor.PRESERVE_ORIGINAL_NAMES?s=e.meta?.name||e._constructor.sqlName():s=e._constructor.sqlName(),this.func(s,t)}func(e,t,s={}){let{prefix:r="(",suffix:i=")",normalize:o=!0}=s;return`${o?this.normalizeFunc(e):e}${r}${this.formatArgs(t)}${i}`}formatArgs(e,t={}){let{sep:s=", "}=t,r=e.filter(i=>i!==void 0&&typeof i!="boolean").map(i=>this.sql(i)).filter(i=>i!=="");if(this.pretty&&this.tooWide(r)){let i=r.join(`${s.trim()}
|
|
9
|
+
`)}sql(e,t,s={}){let{comment:r=!0}=s;if(e===void 0)return"";if(typeof e=="number"||typeof e=="string"||typeof e=="boolean")return e.toString();if(Array.isArray(e))return e.map(c=>this.sql(c)).join(", ");if(t){let c=e.getArgKey(t);return c&&(typeof c=="string"||c instanceof d)?this.sql(c):""}let i=this._constructor.TRANSFORMS.get(e._constructor),o="";if(i instanceof Function)o=i.call(this,e);else if(e instanceof d){let c=`${e._constructor.key}Sql`,p=this[c];if(p instanceof Function)o=p.call(this,e);else if(e instanceof E||ry.has(e._constructor))o=this.functionFallbackSql(e);else if(e instanceof w)o=this.propertySql(e);else throw new Error(`Unsupported expression type ${e._constructor.name}`)}else throw new Error(`Expected an Expression. Received ${typeof e}: ${e}`);return this.comments&&r?this.maybeComment(o,e):o}maybeComment(e,t,s,r=!1){let i=this.comments?s!==void 0?s:t?.comments:void 0;if(!i||i.length===0||t&&[...this._constructor.EXCLUDE_COMMENTS].some(p=>t instanceof p))return e;let o=i.filter(p=>p).map(p=>`/*${this.sanitizeComment(p)}*/`).join(" ");if(!o)return e;let c=this.replaceLineBreaks(o);return r||t&&[...this._constructor.WITH_SEPARATED_COMMENTS].some(p=>t instanceof p)?!e||e[0]===" "||e[0]===`
|
|
10
|
+
`?`${this.sep()}${c}${e}`:`${c}${this.sep()}${e}`:`${e} ${c}`}uncacheSql(e){let t=this.sql(e,"this");return`UNCACHE TABLE${e.args.exists?" IF EXISTS":""} ${t}`}cacheSql(e){let t=e.args.lazy?" LAZY":"",s=this.sql(e,"this"),r=e.args.options,i=r?.length?` OPTIONS(${this.sql(r[0])} = ${this.sql(r[1])})`:"",o=this.sql(e,"expression");return o=o?` AS${this.sep()}${o}`:"",o=`CACHE${t} TABLE ${s}${i}${o}`,this.prependCtes(e,o)}characterSetSql(e){return e.parent instanceof z?`CHAR CHARACTER SET ${this.sql(e,"this")}`:`${e.args.default?"DEFAULT ":""}CHARACTER SET=${this.sql(e,"this")}`}columnParts(e){return[e.args.catalog,e.args.db,e.args.table,e.args.this].filter(Boolean).map(s=>this.sql(s)).join(".")}columnSql(e){let t=e.args.joinMark?" (+)":"";return t&&!this.dialect._constructor.SUPPORTS_COLUMN_JOIN_MARKS?(this.unsupported("Outer join syntax using the (+) operator is not supported."),this.columnParts(e)):`${this.columnParts(e)}${t}`}pseudocolumnSql(e){return this.columnSql(e)}columnPositionSql(e){let t=this.sql(e,"this"),s=t?` ${t}`:"";return`${this.sql(e,"position")}${s}`}columnDefSql(e,t={}){let{sep:s=" "}=t,r=this.sql(e,"this"),i=this.sql(e,"kind"),o=this.expressions(e,{key:"constraints",sep:" ",flat:!0}),c=e.args.exists?"IF NOT EXISTS ":"";i=i?`${s}${i}`:"";let p=o?` ${o}`:"",u=this.sql(e,"position");return u=u?` ${u}`:"",0<Array.from(e.findAll(Dn)).length&&!this._constructor.COMPUTED_COLUMN_WITH_TYPE&&(i=""),`${c}${r}${i}${p}${u}`}columnConstraintSql(e){let t=this.sql(e,"this"),s=this.sql(e,"kind").trim();return t?`CONSTRAINT ${t} ${s}`:s}computedColumnConstraintSql(e){let t=this.sql(e,"this"),s;return e.args.notNull?s=" PERSISTED NOT NULL":e.args.persisted?s=" PERSISTED":s="",`AS ${t}${s}`}autoIncrementColumnConstraintSql(e){return this.tokenSql("autoIncrement")}compressColumnConstraintSql(e){let t;return Array.isArray(e.args.this)?t=this.wrap(this.expressions(e,{key:"this",flat:!0})):t=this.sql(e,"this"),`COMPRESS ${t}`}generatedAsIdentityColumnConstraintSql(e){let t="";if(e.args.this!==void 0){let y=e.args.onNull?" ON NULL":"";t=e.args.this?" ALWAYS":` BY DEFAULT${y}`}let s=e.args.start,r=s?`START WITH ${s}`:"",i=e.args.increment,o=i?` INCREMENT BY ${i}`:"",c=e.args.minvalue,p=c?` MINVALUE ${c}`:"",u=e.args.maxvalue,h=u?` MAXVALUE ${u}`:"",g=e.args.cycle,x="";g!==void 0&&(x=`${g?"":" NO"} CYCLE`,x=!r&&!o?x.trim():x);let f="";(r||o||x)&&(f=`${r}${o}${p}${h}${x}`,f=` (${f.trim()})`);let T=this.sql(e,"expression");return T=T?`(${T})`:"IDENTITY",`GENERATED${t} AS ${T}${f}`}generatedAsRowColumnConstraintSql(e){let t=e.args.start?"START":"END",s=e.args.hidden?" HIDDEN":"";return`GENERATED ALWAYS AS ROW ${t}${s}`}periodForSystemTimeConstraintSql(e){return`PERIOD FOR SYSTEM_TIME (${this.sql(e,"this")}, ${this.sql(e,"expression")})`}notNullColumnConstraintSql(e){return e.args.allowNull?"NULL":"NOT NULL"}primaryKeyColumnConstraintSql(e){let t=e.args.desc;if(t!==void 0)return`PRIMARY KEY${t?" DESC":" ASC"}`;let s=this.expressions(e,{key:"options",flat:!0,sep:" "});return s=s?` ${s}`:"",`PRIMARY KEY${s}`}uniqueColumnConstraintSql(e){let t=this.sql(e,"this");t=t?` ${t}`:"";let s=e.args.indexType,r=s?` USING ${s}`:"",i=this.sql(e,"onConflict");i=i?` ${i}`:"";let o=e.args.nulls?" NULLS NOT DISTINCT":"",c=this.expressions(e,{key:"options",flat:!0,sep:" "});return c=c?` ${c}`:"",`UNIQUE${o}${t}${r}${i}${c}`}inOutColumnConstraintSql(e){let t=e.args.input,s=e.args.output;return e.args.variadic?"VARIADIC":t&&s?`IN${this._constructor.INOUT_SEPARATOR}OUT`:t?"IN":s?"OUT":""}createableSql(e,t){return this.sql(e,"this")}createSql(e){let t=this.sql(e,"kind").toUpperCase();t=this.dialect._constructor.INVERSE_CREATABLE_KIND_MAPPING[t]??t;let s=e.args.properties;t==="TRIGGER"&&s&&s instanceof He&&s.args.expressions?.length&&s.args.expressions[0]instanceof Gn&&s.args.expressions[0].args.constraint&&(t=`CONSTRAINT ${t}`),s&&re(s,He);let r=s?this.locateProperties(s):new Map,i=this.createableSql(e,r),o="",c=r.get("postSchema"),p=r.get("postWith");if(c?.length||p?.length){let Xe=new He({expressions:[...c??[],...p??[]]});Xe.parent=e,o=this.sql(Xe),c?.length?o=this.sep()+o:this.pretty||(o=` ${o}`)}let u=e.args.begin?" BEGIN":"",h=this.sql(e,"expression");if(h&&(h=`${u}${this.sep()}${h}`,this._constructor.CREATE_FUNCTION_RETURN_AS||!(e.args.expression instanceof ou))){let Xe="",Nt=r.get("postAlias");Nt&&(Xe=this.properties(new He({expressions:Nt}),{wrapped:!1})),Xe=Xe?` ${Xe}`:"",h=` AS${Xe}${h}`}let g="",x=r.get("postIndex");x&&(g=this.properties(new He({expressions:x}),{wrapped:!1,prefix:" "}));let f=this.expressions(e,{key:"indexes",indent:!1,sep:" "});f=f?` ${f}`:"";let T=f+g,y=e.args.replace?" OR REPLACE":"",b=e.args.refresh?" OR REFRESH":"",m=e.args.unique?" UNIQUE":"",C=e.args.clustered,q="";C===void 0?q="":C?q=" CLUSTERED COLUMNSTORE":q=" NONCLUSTERED COLUMNSTORE";let U="",_=r.get("postCreate");_&&(U=this.properties(new He({expressions:_}),{sep:" ",prefix:" ",wrapped:!1}));let ne=e.args.indexPrefix?` ${e.args.indexPrefix}`:"",K=`${q}${y}${b}${m}${ne}${U}`,H="",Ie=r.get("postExpression");Ie&&(H=this.properties(new He({expressions:Ie}),{sep:" ",prefix:" ",wrapped:!1}));let Se=e.args.concurrently?" CONCURRENTLY":"",Ot=e.args.exists?" IF NOT EXISTS":"",gt=e.args.noSchemaBinding?" WITH NO SCHEMA BINDING":"",ds=this.sql(e,"clone");ds=ds?` ${ds}`:"";let mt;return this._constructor.EXPRESSION_PRECEDES_PROPERTIES_CREATABLES.has(t)?mt=`${h}${o}`:mt=`${o}${h}`,h=`CREATE${K} ${t}${Se}${Ot} ${i}${mt}${H}${T}${gt}${ds}`,this.prependCtes(e,h)}sequencePropertiesSql(e){let t=this.sql(e,"start");t=t?`START WITH ${t}`:"";let s=this.sql(e,"increment");s=s?` INCREMENT BY ${s}`:"";let r=this.sql(e,"minvalue");r=r?` MINVALUE ${r}`:"";let i=this.sql(e,"maxvalue");i=i?` MAXVALUE ${i}`:"";let o=this.sql(e,"owned");o=o?` OWNED BY ${o}`:"";let c=e.args.cache,p="";c===void 0?p="":c===!0?p=" CACHE":p=` CACHE ${c}`;let u=this.expressions(e,{key:"options",flat:!0,sep:" "}),h=u?` ${u}`:"";return`${t}${s}${r}${i}${p}${h}${o}`.trimStart()}triggerPropertiesSql(e){let t=e.args.timing??"",s=(e.args.events??[]).map(x=>this.sql(x)).join(" OR "),i=[t||s?`${t} ${s}`.trim():"","ON",this.sql(e,"table")],o=e.args.referencedTable;o&&i.push("FROM",this.sql(o));let c=e.args.deferrable;c&&i.push(c);let p=e.args.initially;p&&i.push(`INITIALLY ${p}`);let u=e.args.referencing;u&&i.push(this.sql(u));let h=e.args.forEach;h&&i.push(`FOR EACH ${h}`);let g=e.args.when;return g&&i.push(`WHEN (${this.sql(g)})`),i.push(this.sql(e,"execute")),i.join(this.sep())}triggerExecuteSql(e){return`EXECUTE FUNCTION ${this.sql(e,"this")}`}triggerReferencingSql(e){let t=[],s=e.args.old;s&&t.push(`OLD TABLE AS ${this.sql(s)}`);let r=e.args.new;return r&&t.push(`NEW TABLE AS ${this.sql(r)}`),`REFERENCING ${t.join(" ")}`}triggerEventSql(e){return e.args.columns?`${e.args.this} OF ${this.expressions(e,{key:"columns",flat:!0})}`:String(e.args.this??"")}cloneSql(e){let t=this.sql(e,"this"),s=e.args.shallow?"SHALLOW ":"",r=e.args.copy&&this._constructor.SUPPORTS_TABLE_COPY?"COPY":"CLONE";return`${s}${r} ${t}`}describeSql(e){let t=e.args.style,s=t?` ${t}`:"",r=this.sql(e,"partition");r=r?` ${r}`:"";let i=this.sql(e,"format");i=i?` ${i}`:"";let o=e.args.asJson?" AS JSON":"";return`DESCRIBE${s}${i} ${this.sql(e,"this")}${r}${o}`}heredocSql(e){let t=this.sql(e,"tag");return`$${t}$${this.sql(e,"this")}$${t}$`}prependCtes(e,t){let s=this.sql(e,"with");return s?`${s}${this.sep()}${t}`:t}withSql(e){let t=this.expressions(e,{flat:!0}),s=this._constructor.CTE_RECURSIVE_KEYWORD_REQUIRED&&e.args.recursive?"RECURSIVE ":"",r=this.sql(e,"search");return r=r?` ${r}`:"",`WITH ${s}${t}${r}`}cteSql(e){let t=e.args.alias;t&&t.addComments?.(e.popComments());let s=this.sql(e,"alias"),r=e.args.materialized,i="";r===!1?i="NOT MATERIALIZED ":r&&(i="MATERIALIZED ");let o=this.expressions(e,{key:"keyExpressions",flat:!0}),c=o?` USING KEY (${o})`:"";return`${s}${c} AS ${i}${this.wrap(e)}`}tableAliasSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{key:"columns",flat:!0});return s=s?`(${s})`:"",s&&!this._constructor.SUPPORTS_TABLE_ALIAS_COLUMNS&&(s="",this.unsupported("Named columns are not supported in table alias.")),!t&&!this.dialect._constructor.UNNEST_COLUMN_ONLY&&(t=this.nextName()),`${t}${s}`}bitStringSql(e){let t=this.sql(e,"this");return this.dialect._constructor.BIT_START?`${this.dialect._constructor.BIT_START}${t}${this.dialect._constructor.BIT_END}`:`${parseInt(t,2)}`}hexStringSql(e,t={}){let{binaryFunctionRepr:s}=t,r=this.sql(e,"this"),i=e.args.isInteger;if(i&&!this.dialect._constructor.HEX_STRING_IS_INTEGER_TYPE||!this.dialect._constructor.HEX_START&&!s)return`${parseInt(r,16)}`;if(!i){if(s)return this.func(s,[Hl(r)]);this.dialect._constructor.HEX_STRING_IS_INTEGER_TYPE&&this.unsupported("Unsupported transpilation from BINARY/BLOB hex string")}return`${this.dialect._constructor.HEX_START}${r}${this.dialect._constructor.HEX_END}`}byteStringSql(e){let t=this.sql(e,"this");if(this.dialect._constructor.BYTE_START){let s=this.escapeStr(t,{escapeBackslash:!1,delimiter:this.dialect._constructor.BYTE_END,escapedDelimiter:this.escapedByteQuoteEnd,isByteString:!0}),r=e.args.isBytes||!1,i=`${this.dialect._constructor.BYTE_START}${s}${this.dialect._constructor.BYTE_END}`;return r&&!this.dialect._constructor.BYTE_STRING_IS_BYTES_TYPE?this.sql(X(i,"BINARY",{dialect:this.dialect})):!r&&this.dialect._constructor.BYTE_STRING_IS_BYTES_TYPE?this.sql(X(i,"VARCHAR",{dialect:this.dialect})):i}return t}unicodeStringSql(e){let t=this.sql(e,"this"),s=e.args.escape,r,i,o;this.dialect._constructor.UNICODE_START?(r="\\$1",i=this.dialect._constructor.UNICODE_START,o=this.dialect._constructor.UNICODE_END):(r="\\u$1",i=this.dialect._constructor.QUOTE_START,o=this.dialect._constructor.QUOTE_END);let c,p;s?(c=new RegExp(`${s.name}(\\d+)`,"g"),p=this._constructor.SUPPORTS_UESCAPE?` UESCAPE ${this.sql(s)}`:""):(c=Tj,p="");let u=t;if(!this.dialect._constructor.UNICODE_START||s&&!this._constructor.SUPPORTS_UESCAPE){let h=this._constructor.UNICODE_SUBSTITUTE||r;u=u.replace(c,h)}return`${i}${u}${o}${p}`}rawStringSql(e){let t=e.args.this?.toString()||"";return t.includes("x21")&&console.log("DEBUG rawStringSql: chars=",[...t].map(s=>s.charCodeAt(0))),this.dialect._constructor.tokenizerClass.STRING_ESCAPES.includes("\\")&&(t=t?.replace(/\\/g,"\\\\")),t=this.escapeStr(t,{escapeBackslash:!1}),`${this.dialect._constructor.QUOTE_START}${t}${this.dialect._constructor.QUOTE_END}`}dataTypeParamSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=s&&this._constructor.DATA_TYPE_SPECIFIERS_ALLOWED?` ${s}`:"";return`${t}${r}`}dataTypeSql(e){let t="",s="",r=e.args.nested,i=r&&this.pretty?this.expressions(e,{dynamic:!0,newLine:!0,skipFirst:!0,skipLast:!0}):this.expressions(e,{flat:!0}),o=e.args.this;typeof o=="string"&&this._constructor.UNSUPPORTED_TYPES.has(o)&&this.unsupported(`Data type ${o} is not supported when targeting ${this.dialect._constructor.name}`);let c;if(o instanceof d)c=o.sql();else if(o==="user-defined"&&e.args.kind)c=this.sql(e,"kind");else{let p=o&&this._constructor.TYPE_MAPPING.get(o),u=o!==void 0&&Object.values(At).includes(o);c=p!==void 0?p:o&&(u?bM(o):o)}if(i)if(r){let p=this._constructor.STRUCT_DELIMITER;if(t=`${p[0]}${i}${p[1]}`,e.args.values?.length){let u=o==="array"?["[","]"]:["(",")"],h=this.expressions(e,{key:"values",flat:!0});s=`${u[0]}${h}${u[1]}`}}else o==="interval"?t=` ${i}`:t=`(${i})`;return c=`${c}${t}${s}`,this._constructor.TZ_TO_WITH_TIME_ZONE&&(o==="timetz"||o==="timestamptz")&&(c=`${c} WITH TIME ZONE`),c}directorySql(e){let t=e.args.local?"LOCAL ":"",s=this.sql(e,"rowFormat");return s=s?` ${s}`:"",`${t}DIRECTORY ${this.sql(e,"this")}${s}`}deleteSql(e){let t=this.sql(e,"this"),s=t?` FROM ${t}`:"",r=this.expressions(e,{key:"using"});r=r?` USING ${r}`:"";let i=this.sql(e,"cluster");i=i?` ${i}`:"";let o=this.sql(e,"where"),c=this.sql(e,"returning"),p=this.sql(e,"order"),u=this.sql(e,"limit"),h=this.expressions(e,{key:"tables"});h=h?` ${h}`:"";let g;return this._constructor.RETURNING_END?g=`${s}${r}${i}${o}${c}${p}${u}`:g=`${c}${s}${r}${i}${o}${p}${u}`,this.prependCtes(e,`DELETE${h}${g}`)}dropSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});s=s?` (${s})`:"";let r=e.args.kind?.toString().toUpperCase(),i=r&&(this.dialect._constructor.INVERSE_CREATABLE_KIND_MAPPING?.[r]||r),o=e.args.exists?" IF EXISTS ":" ",c=e.args.concurrently?" CONCURRENTLY":"",p=this.sql(e,"cluster");p=p?` ${p}`:"";let u=e.args.temporary?" TEMPORARY":"",h=e.args.materialized?" MATERIALIZED":"",g=e.args.iceberg&&this._constructor.SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY?" ICEBERG":"",x=e.args.cascade?" CASCADE":"",f=e.args.restrict?" RESTRICT":"",T=e.args.constraints?" CONSTRAINTS":"",y=e.args.purge?" PURGE":"",b=e.args.sync?" SYNC":"";return`DROP${u}${h}${g} ${i}${c}${o}${t}${p}${s}${x}${f}${T}${y}${b}`}setOperation(e){let t=e._constructor,s=t.key.toUpperCase(),r=e.args.distinct;r===!1&&(e instanceof cr||e instanceof ei)&&!this._constructor.EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE&&this.unsupported(`${s} ALL is not supported`);let i=this.dialect._constructor.SET_OP_DISTINCT_BY_DEFAULT?.[t.key];r===void 0&&(r=i,r===void 0&&this.unsupported(`${s} requires DISTINCT or ALL to be specified`));let o;r===i?o="":o=r?" DISTINCT":" ALL";let c=[e.args.side,e.args.kind].filter(Boolean).join(" ").toUpperCase(),p=c?`${c} `:"",u=e.args.byName?" BY NAME":"",h=this.expressions(e,{key:"on",flat:!0});return h=h?` ON (${h})`:"",`${p}${s}${o}${u}${h}`}setOperations(e){if(!this._constructor.SET_OP_MODIFIERS){let i=e.args.limit,o=e.args.order;if(i||o){let p=this.moveCtesToTopLevel(DD(e,"_l_0",{copy:!1}).select("*",{copy:!1}));return i&&(p=p.limit(typeof i=="number"?i:i.pop(),{copy:!1})),o&&(p=p.orderBy(o.pop(),{copy:!1})),this.sql(p)}}let t=[],s=[e];for(;0<s.length;){let i=s.pop();if(i instanceof Ge)i.args.expression&&s.push(i.args.expression),s.push(this.maybeComment(this.setOperation(i),void 0,i.comments,!0)),i.args.this&&s.push(i.args.this);else{let o=typeof i=="string"?i:this.sql(i);t.push(o)}}let r=t.join(this.sep());return r=this.queryModifiers(e,r),this.prependCtes(e,r)}fetchSql(e){let t=e.args.direction,s=t?` ${t}`:"",r=this.sql(e,"count"),i=r?` ${r}`:"",o=this.sql(e,"limitOptions"),c=o?`${o}`:" ROWS ONLY";return`${this.seg("FETCH")}${s}${i}${c}`}limitOptionsSql(e){let t=e.args.percent?" PERCENT":"",s=e.args.rows?" ROWS":"",r=e.args.withTies?" WITH TIES":"";return!r&&s&&(r=" ONLY"),`${t}${s}${r}`}filterSql(e){if(this._constructor.AGGREGATE_FILTER_SUPPORTED){let o=this.sql(e,"this"),c=this.sql(e,"expression").trim();return`${o} FILTER(${c})`}let s=e.args.this,r=s?s.args.this:void 0,i=e.args.expression?.args.this;return r instanceof d&&i instanceof d&&r.replace(new xe({this:i.copy(),true:r.copy()})),this.sql(s)}hintSql(e){return this._constructor.QUERY_HINTS?` /*+ ${this.expressions(e,{sep:this._constructor.QUERY_HINT_SEP}).trim()} */`:(this.unsupported("Hints are not supported"),"")}indexParametersSql(e){let t=this.sql(e,"using");t=t?` USING ${t}`:"";let s=this.expressions(e,{key:"columns",flat:!0}),r=s?`(${s})`:"",i=this.expressions(e,{key:"partitionBy",flat:!0}),o=i?` PARTITION BY ${i}`:"",c=this.sql(e,"where"),p=this.expressions(e,{key:"include",flat:!0});p&&(p=` INCLUDE (${p})`);let u=this.expressions(e,{key:"withStorage",flat:!0}),h=u?` WITH (${u})`:"",g=this.sql(e,"tablespace"),x=g?` USING INDEX TABLESPACE ${g}`:"",f=this.sql(e,"on"),T=f?` ON ${f}`:"",y=e.args.reverse?" REVERSE":"";return`${t}${r}${y}${p}${h}${x}${o}${c}${T}`}indexSql(e){let t=e.args.unique?"UNIQUE ":"",s=e.args.primary?"PRIMARY ":"",r=e.args.amp?"AMP ":"",i=this.sql(e,"this");i=i?`${i} `:"";let o=this.sql(e,"table");o=o?`${this._constructor.INDEX_ON} ${o}`:"";let c=o?"":"INDEX ",p=this.sql(e,"params");return`${t}${s}${r}${c}${i}${o}${p}`}identifierSql(e){let t=e.name,s=t.toLowerCase();return t=this.normalize&&!e.args.quoted?s:t,t=t.replaceAll(this.identifierEnd,this.escapedIdentifierEnd),(e.args.quoted||this.dialect.canQuote(e,{identify:this.identify})||this._constructor.RESERVED_KEYWORDS.has(s)||!this.dialect._constructor.IDENTIFIERS_CAN_START_WITH_DIGIT&&/^\d/.test(t))&&(t=`${this.identifierStart}${t}${this.identifierEnd}`),t}hexSql(e){let t=this._constructor.HEX_FUNC,s=this.func(t,[this.sql(e,"this")]);return this.dialect._constructor.HEX_LOWERCASE&&(s=this.func("LOWER",[s])),s}lowerHexSql(e){let t=this._constructor.HEX_FUNC,s=this.func(t,[this.sql(e,"this")]);return this.dialect._constructor.HEX_LOWERCASE||(s=this.func("LOWER",[s])),s}inputOutputFormatSql(e){let t=this.sql(e,"inputFormat"),s=t?`INPUTFORMAT ${t}`:"",r=this.sql(e,"outputFormat"),i=r?`OUTPUTFORMAT ${r}`:"";return[s,i].join(this.sep())}nationalSql(e,t={}){let{prefix:s="N"}=t,r=this.sql(Hl(e.name));return`${s}${r}`}partitionSql(e){return`${e.args.subpartition?"SUBPARTITION":"PARTITION"}(${this.expressions(e,{flat:!0})})`}propertiesSql(e){let t=[],s=[];for(let p of e.args.expressions||[]){let u=this._constructor.PROPERTIES_LOCATION.get(p._constructor);u==="postWith"?s.push(p):u==="postSchema"&&t.push(p)}let r=new He({expressions:t});r.parent=e.parent;let i=new He({expressions:s});i.parent=e.parent;let o=this.rootProperties(r),c=this.withProperties(i);return o&&c&&!this.pretty&&(c=` ${c}`),o+c}rootProperties(e){return 0<(e.args.expressions||[]).length?this.expressions(e,{indent:!1,sep:" "}):""}properties(e,t={}){let{prefix:s="",sep:r=", ",suffix:i="",wrapped:o=!0}=t;if(0<(e.args.expressions||[]).length){let c=this.expressions(e,{sep:r,indent:!1});if(c){let p=o?this.wrap(c):c;return`${s}${s.trim()?" ":""}${p}${i}`}}return""}withProperties(e){return this.properties(e,{prefix:this.seg(this._constructor.WITH_PROPERTIES_PREFIX,"")})}locateProperties(e){let t=new Map,s=e.args.expressions||[];for(let r of s){let i=this._constructor.PROPERTIES_LOCATION.get(r._constructor)||"unsupported";i!=="unsupported"?(t.has(i)||t.set(i,[]),t.get(i)?.push(r)):this.unsupported(`Unsupported property ${r._constructor.key}`)}return t}propertyName(e,t={}){let{stringKey:s=!1}=t;return e.args.this instanceof ge?this.sql(e,"this"):s?`'${e.name}'`:e.name}propertySql(e){let t=e._constructor;if(t===w)return`${this.propertyName(e)}=${this.sql(e,"value")}`;let s=He.PROPERTY_TO_NAME?.[t.key];return s||this.unsupported(`Unsupported property ${e._constructor.key}`),`${s}=${this.sql(e,"this")}`}uuidPropertySql(e){return`UUID ${this.sql(e,"this")}`}likePropertySql(e){if(this._constructor.SUPPORTS_CREATE_TABLE_LIKE){let s=(e.args.expressions||[]).map(o=>`${o.name} ${this.sql(o,"value")}`).join(" "),r=s?` ${s}`:"",i=`LIKE ${this.sql(e,"this")}${r}`;return this._constructor.LIKE_PROPERTY_INSIDE_SCHEMA&&!(e.parent instanceof Rt)?`(${i})`:i}e.args.expressions?.length&&this.unsupported("Transpilation of LIKE property options is unsupported");let t=Ye("*").from(e.args.this).limit(0);return`AS ${this.sql(t)}`}fallbackPropertySql(e){let t=e.args.no?"NO ":"",s=e.args.protection?" PROTECTION":"";return`${t}FALLBACK${s}`}journalPropertySql(e){let t=e.args.no?"NO ":"",s=e.args.local,r=s?`${s} `:"",i=e.args.dual?"DUAL ":"",o=e.args.before?"BEFORE ":"",c=e.args.after?"AFTER ":"";return`${t}${r}${i}${o}${c}JOURNAL`}freespacePropertySql(e){let t=this.sql(e,"this"),s=e.args.percent?" PERCENT":"";return`FREESPACE=${t}${s}`}checksumPropertySql(e){let t;return e.args.default?t="DEFAULT":e.args.on?t="ON":t="OFF",`CHECKSUM=${t}`}mergeBlockRatioPropertySql(e){if(e.args.no)return"NO MERGEBLOCKRATIO";if(e.args.default)return"DEFAULT MERGEBLOCKRATIO";let t=e.args.percent?" PERCENT":"";return`MERGEBLOCKRATIO=${this.sql(e,"this")}${t}`}dataBlocksizePropertySql(e){let t=e.args.default,s=e.args.minimum,r=e.args.maximum;if(t||s||r){let c;return t?c="DEFAULT":s?c="MINIMUM":c="MAXIMUM",`${c} DATABLOCKSIZE`}let i=e.args.units,o=i?` ${i}`:"";return`DATABLOCKSIZE=${this.sql(e,"size")}${o}`}blockCompressionPropertySql(e){let t=e.args.autotemp,s=e.args.always,r=e.args.default,i=e.args.manual,o=e.args.never,c;return t!==void 0?c=`AUTOTEMP${this.sql(t)}`:s?c="ALWAYS":r?c="DEFAULT":i?c="MANUAL":o?c="NEVER":c="",`BLOCKCOMPRESSION=${c}`}isolatedLoadingPropertySql(e){let s=e.args.no?" NO":"",i=e.args.concurrent?" CONCURRENT":"",o=this.sql(e,"target");return o=o?` ${o}`:"",`WITH${s}${i} ISOLATED LOADING${o}`}partitionBoundSpecSql(e){if(Array.isArray(e.args.this))return`IN (${this.expressions(e,{key:"this",flat:!0})})`;if(e.args.this){let r=this.sql(e,"this"),i=this.sql(e,"expression");return`WITH (MODULUS ${r}, REMAINDER ${i})`}let t=this.expressions(e,{key:"fromExpressions",flat:!0}),s=this.expressions(e,{key:"toExpressions",flat:!0});return`FROM (${t}) TO (${s})`}partitionedOfPropertySql(e){let t=this.sql(e,"this"),s=e.args.expression??"";return s instanceof au?s=` FOR VALUES ${this.sql(s)}`:s=" DEFAULT",`PARTITION OF ${t}${s}`}lockingPropertySql(e){let t=e.args.kind,s=e.args.this?` ${this.sql(e,"this")}`:"",r=e.args.forOrIn,i=r?` ${r}`:"",o=e.args.lockType,c=e.args.override?" OVERRIDE":"";return`LOCKING ${t}${s}${i} ${o}${c}`}withDataPropertySql(e){let t=`WITH ${e.args.no?"NO ":""}DATA`,s=e.args.statistics,r="";return s!==void 0&&(r=` AND ${s?"":"NO "}STATISTICS`),`${t}${r}`}withSystemVersioningPropertySql(e){let t=this.sql(e,"this");t=t?`HISTORY_TABLE=${t}`:"";let s=this.sql(e,"dataConsistency"),r=s?`DATA_CONSISTENCY_CHECK=${s}`:void 0,i=this.sql(e,"retentionPeriod"),o=i?`HISTORY_RETENTION_PERIOD=${i}`:void 0,c;t?c=this.func("ON",[t,r,o]):c=e.args.on?"ON":"OFF";let p=`SYSTEM_VERSIONING=${c}`;return e.args.with?`WITH(${p})`:p}insertSql(e){let t=this.sql(e,"hint"),s=e.args.overwrite,r=e.args.this instanceof su,i;r?i=s?" OVERWRITE":" INTO":i=s?this._constructor.INSERT_OVERWRITE:" INTO";let o=this.sql(e,"stored"),c=o?` ${o}`:"",p=e.args.alternative,u=p?` OR ${p}`:"",h=e.args.ignore?" IGNORE":"";e.args.isFunction&&(i=`${i} FUNCTION`);let x=`${i} ${this.sql(e,"this")}`,f=e.args.exists?" IF EXISTS":"",T=this.sql(e,"where"),y=T?`${this.sep()}REPLACE WHERE ${T}`:"",b=`${this.sep()}${this.sql(e,"expression")}`,m=this.sql(e,"conflict"),C=m?` ${m}`:"",q=e.args.byName?" BY NAME":"",U=e.args.default?"DEFAULT VALUES":"",_=this.sql(e,"returning");this._constructor.RETURNING_END?b=`${b}${C}${U}${_}`:b=`${_}${b}${C}`;let ne=this.sql(e,"partition"),K=ne?` ${ne}`:"",H=this.sql(e,"settings"),Ie=H?` ${H}`:"",Se=this.sql(e,"source"),Ot=Se?`TABLE ${Se}`:"",gt=`INSERT${t}${u}${h}${x}${c}${q}${f}${K}${Ie}${y}${b}${Ot}`;return this.prependCtes(e,gt)}introducerSql(e){return`${this.sql(e,"this")} ${this.sql(e,"expression")}`}killSql(e){return`KILL ${e.args.kind?`${e.args.kind} `:""}${this.sql(e,"this")}`}pseudoTypeSql(e){return e.name}objectIdentifierSql(e){return e.name}onConflictSql(e){let t=e.args.duplicate?"ON DUPLICATE KEY":"ON CONFLICT",s=this.sql(e,"constraint");s=s?` ON CONSTRAINT ${s}`:"";let r=this.expressions(e,{key:"conflictKeys",flat:!0});r&&(r=`(${r})`);let i=this.sql(e,"indexPredicate");r=`${r}${i} `;let o=this.sql(e,"action"),c=this.expressions(e,{flat:!0});c&&(c=` ${this._constructor.DUPLICATE_KEY_UPDATE_WITH_SET?"SET ":""}${c}`);let p=this.sql(e,"where");return`${t}${s}${r}${o}${c}${p}`}returningSql(e){return this.opExpressions("RETURNING",e)}rowFormatDelimitedPropertySql(e){let t=this.sql(e,"fields"),s=t?` FIELDS TERMINATED BY ${t}`:"",r=this.sql(e,"collectionItems"),i=r?` COLLECTION ITEMS TERMINATED BY ${r}`:"",o=this.sql(e,"mapKeys"),c=o?` MAP KEYS TERMINATED BY ${o}`:"",p=this.sql(e,"lines"),u=p?` LINES TERMINATED BY ${p}`:"",h=this.sql(e,"null"),g=h?` NULL DEFINED AS ${h}`:"";return`ROW FORMAT DELIMITED${s}${i}${c}${u}${g}`}withTableHintSql(e){return`WITH (${this.expressions(e,{flat:!0})})`}indexTableHintSql(e){let t=`${this.sql(e,"this")} INDEX`,s=this.sql(e,"target");return s=s?` FOR ${s}`:"",`${t}${s} (${this.expressions(e,{flat:!0})})`}historicalDataSql(e){let t=this.sql(e,"this"),s=this.sql(e,"kind"),r=this.sql(e,"expression");return`${t} (${s} => ${r})`}tableParts(e){return[e.args.catalog,e.args.db,e.args.this].filter(t=>t!==void 0).map(t=>this.sql(t)).join(".")}tableSql(e,t={}){let{sep:s=" AS "}=t,r=this.tableParts(e),i=e.args.only?"ONLY ":"",o=this.sql(e,"partition");o=o?` ${o}`:"";let c=this.sql(e,"version");c=c?` ${c}`:"";let p=this.sql(e,"alias");p=p?`${s}${p}`:"";let u=this.sql(e,"sample"),h="",g="";this.dialect._constructor.ALIAS_POST_TABLESAMPLE?h=u:g=u,this.dialect._constructor.ALIAS_POST_VERSION?h=`${h}${c}`:g=`${g}${c}`;let x=this.expressions(e,{key:"hints",sep:" "});x=x&&this._constructor.TABLE_HINTS?` ${x}`:"";let f=this.expressions(e,{key:"pivots",sep:"",flat:!0}),T=this.indent(this.expressions(e,{key:"joins",sep:"",flat:!0}),{skipFirst:!0}),y=this.expressions(e,{key:"laterals",sep:""}),b=this.sql(e,"format");if(b){let H=this.sql(e,"pattern"),Ie=H?`, PATTERN => ${H}`:"";b=` (FILE_FORMAT => ${b}${Ie})`}let m=e.args.ordinality||"";m&&(m=` WITH ORDINALITY${p}`,p="");let C=this.sql(e,"when"),q=r;C&&(q=`${r} ${C}`);let U=this.sql(e,"changes");U=U?` ${U}`:"";let _=this.expressions(e,{key:"rowsFrom"});_&&(q=`ROWS FROM ${this.wrap(_)}`);let ne=e.args.indexed,K;return ne!==void 0?K=ne?` INDEXED BY ${this.sql(ne)}`:" NOT INDEXED":K="",`${i}${q}${U}${o}${b}${h}${p}${K}${x}${f}${g}${T}${y}${m}`}tableFromRowsSql(e){let t=this.func("TABLE",[e.args.this]),s=this.sql(e,"alias");s=s?` AS ${s}`:"";let r=this.sql(e,"sample"),i=this.expressions(e,{key:"pivots",sep:"",flat:!0}),o=this.indent(this.expressions(e,{key:"joins",sep:"",flat:!0}),{skipFirst:!0});return`${t}${s}${i}${r}${o}`}pivotSql(e){let t=this.expressions(e,{flat:!0}),s=e.args.unpivot?"UNPIVOT":"PIVOT",r=this.sql(e,"group");if(e.args.this){let g=this.sql(e,"this"),x;if(!t)x=`UNPIVOT ${g}`;else{let f=`${this.seg("ON")} ${t}`,T=this.sql(e,"into");T=T?`${this.seg("INTO")} ${T}`:"";let y=this.expressions(e,{key:"using",flat:!0});y=y?`${this.seg("USING")} ${y}`:"",x=`${s} ${g}${f}${T}${y}${r}`}return this.prependCtes(e,x)}let i=this.sql(e,"alias");i=i?` AS ${i}`:"";let o=this.expressions(e,{key:"fields",sep:" ",dynamic:!0,newLine:!0,skipFirst:!0,skipLast:!0}),c=e.args.includeNulls,p;c!==void 0?p=c?" INCLUDE NULLS ":" EXCLUDE NULLS ":p="";let u=this.sql(e,"defaultOnNull");u=u?` DEFAULT ON NULL (${u})`:"";let h=`${this.seg(s)}${p}(${t} FOR ${o}${u}${r})${i}`;return this.prependCtes(e,h)}versionSql(e){let t=`FOR ${e.name}`,s=e.text?.("kind")||"",r=this.sql(e,"expression");return`${t} ${s} ${r}`}tupleSql(e){return`(${this.expressions(e,{dynamic:!0,newLine:!0,skipFirst:!0,skipLast:!0})})`}updateFromJoinsSql(e){let t=e.args.from;if(this.constructor.UPDATE_STATEMENT_SUPPORTS_FROM||!t)return["",this.sql(e,"from")];let s=e.args.this;if(s instanceof W){let c=Z(s.aliasOrName);for(let p of e.args.expressions||[]){let u=p.args.this;u instanceof $&&!u.table&&u.setArgKey("table",c)}}let r=t.args.this,i=(Y(r,d)?r.args.joins:void 0)||[];0<i.length&&Y(r,d)&&r.setArgKey("joins",void 0);let o=Y(r,d)?this.sql(new fe({this:r,on:We()})):"";for(let c of i)!c.getArgKey("on")&&!c.getArgKey("using")&&c.setArgKey("on",We()),o+=this.sql(c);return[o,""]}updateSql(e){let t=this.sql(e,"this"),[s,r]=this.updateFromJoinsSql(e),i=this.expressions(e,{flat:!0}),o=this.sql(e,"where"),c=this.sql(e,"returning"),p=this.sql(e,"order"),u=this.sql(e,"limit"),h;this._constructor.RETURNING_END?h=`${r}${o}${c}`:h=`${c}${r}${o}`;let g=this.expressions(e,{key:"options"});g=g?` OPTION(${g})`:"";let x=`UPDATE ${t}${s} SET ${i}${h}${p}${u}${g}`;return this.prependCtes(e,x)}valuesSql(e,t={}){let{valuesAsTable:s=!0}=t;if(s&&this._constructor.VALUES_AS_TABLE||!e.findAncestor(rt,fe)){let g=this.expressions(e),x=this.sql(e,"alias"),f=`VALUES${this.seg("")}${g}`;return this._constructor.WRAP_DERIVED_VALUES&&(x||[rt,W].some(y=>e.parent instanceof y))&&(f=`(${f})`),f=this.queryModifiers(e,f),x?`${f} AS ${x}`:f}let i=Y(e.args.alias,pe)?e.args.alias:void 0,o=i?.columns,c=[],p=e.args.expressions;if(p)for(let g=0;g<p.length;g++){let f=p[g].args.expressions||[];g===0&&o&&0<o.length&&(f=f.map((T,y)=>{let b=o[y];return Be(T,b instanceof F?b:b.name,{copy:!1})})),c.push(new se({expressions:f}))}if(c.length===0)return"";if(this.pretty){let g=c.reduce((T,y)=>jA([T,y],{distinct:!1,copy:!1})??T),x=i?.args.this,f=x instanceof d?x:void 0;return this.subquerySql(g.subquery(f,{copy:!1}))}let u=i?` AS ${this.sql(i,"this")}`:"";return`(${c.map(g=>this.sql(g)).join(" UNION ALL ")})${u}`}varSql(e){return this.sql(e,"this")}intoSql(e){Cb.call(this,e,"expressions");let t=e.args.temporary?" TEMPORARY":"",s=e.args.unlogged?" UNLOGGED":"",r=t||s;return`${this.seg("INTO")}${r} ${this.sql(e,"this")}`}fromSql(e){return`${this.seg("FROM")} ${this.sql(e,"this")}`}groupingSetsSql(e){let t=this.expressions(e,{indent:!1});return`GROUPING SETS ${this.wrap(t)}`}rollupSql(e){let t=this.expressions(e,{indent:!1});return t?`ROLLUP ${this.wrap(t)}`:"WITH ROLLUP"}rollupIndexSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0}),r=this.sql(e,"fromIndex"),i=r?` FROM ${r}`:"",o=e.args.properties;o&&re(o,He);let c=o?` ${this.properties(o,{prefix:"PROPERTIES"})}`:"";return`${t}(${s})${i}${c}`}rollupPropertySql(e){return`ROLLUP (${this.expressions(e,{flat:!0})})`}cubeSql(e){let t=this.expressions(e,{indent:!1});return t?`CUBE ${this.wrap(t)}`:"WITH CUBE"}groupSql(e){let t=e.args.all,s="";t===!0?s=" ALL":t===!1&&(s=" DISTINCT");let r=this.opExpressions(`GROUP BY${s}`,e),i=this.expressions(e,{key:"groupingSets"}),o=this.expressions(e,{key:"cube"}),c=this.expressions(e,{key:"rollup"}),p=zI([i?this.seg(i):"",o?this.seg(o):"",c?this.seg(c):"",e.args.totals?this.seg("WITH TOTALS"):""],{sep:this._constructor.GROUPINGS_SEP}),u=r;return e.args.expressions?.length&&p&&p.trim()!=="WITH CUBE"&&p.trim()!=="WITH ROLLUP"&&(u=`${u}${this._constructor.GROUPINGS_SEP}`),`${u}${p}`}havingSql(e){let t=this.indent(this.sql(e,"this"));return`${this.seg("HAVING")}${this.sep()}${t}`}connectSql(e){let t=this.sql(e,"start");t=t?this.seg(`START WITH ${t}`):"";let s=e.args.nocycle?" NOCYCLE":"",r=this.sql(e,"connect"),i=this.seg(`CONNECT BY${s} ${r}`);return t+i}priorSql(e){return`PRIOR ${this.sql(e,"this")}`}joinSql(e){let t=this._constructor,s;!t.SEMI_ANTI_JOIN_WITH_SIDE&&(e.args.kind==="semi"||e.args.kind==="anti")?s=void 0:s=e.args.side?.toUpperCase();let r=[e.args.method,e.args.global?"GLOBAL":void 0,s,e.args.kind==="straightJoin"?"STRAIGHT_JOIN":e.args.kind?.toUpperCase(),e.args.hint&&t.JOIN_HINTS?e.args.hint:void 0,e.args.directed&&t.DIRECTED_JOINS?"DIRECTED":void 0].filter(f=>f).join(" "),i=this.sql(e,"matchCondition");i=i?` MATCH_CONDITION (${i})`:"";let o=this.sql(e,"on"),c=e.args.using;!o&&c&&(o=c.map(f=>this.sql(f)).join(", "));let p=e.args.this,u=this.sql(p),h=this.expressions(e);if(h&&(u=`${u},${this.seg(h)}`),o){o=this.indent(o,{skipFirst:!0});let f=this.pretty?this.seg(" ".repeat(this.pad)):" ";c?o=`${f}USING (${o})`:o=`${f}ON ${o}`}else if(!r)return p instanceof bt&&p.args.crossApply!==void 0?` ${u}`:`, ${u}`;let g=e.args.kind!=="straightJoin"?r?`${r} JOIN`:"JOIN":r,x=this.expressions(e,{key:"pivots",sep:"",flat:!0});return`${this.seg(g)} ${u}${i}${o}${x}`}lambdaSql(e,t={}){let{arrowSep:s="->",wrap:r=!0}=t,i=this.expressions(e,{flat:!0});return i=r&&1<i.split(",").length?`(${i})`:i,`${i} ${s} ${this.sql(e,"this")}`}lateralOp(e){let t=e.args.crossApply,s="";return t===!0?s="INNER JOIN ":t===!1&&(s="LEFT JOIN "),`${s}LATERAL`}lateralSql(e){let t=this.sql(e,"this");if(e.args.view){let i=e.args.alias,o=this.expressions(i,{key:"columns",flat:!0}),c=i?.name?` ${i.name}`:"",p=o?` AS ${o}`:"",u=e.args.outer?" OUTER":"";return`${this.seg(`LATERAL VIEW${u}`)}${this.sep()}${t}${c}${p}`}let s=this.sql(e,"alias");s=s?` AS ${s}`:"";let r=e.args.ordinality||"";return r&&(r=` WITH ORDINALITY${s}`,s=""),`${this.lateralOp(e)} ${t}${s}${r}`}limitSql(e,t={}){let{top:s=!1}=t,r=this.sql(e,"this"),i=["offset","expression"].map(h=>e.getArgKey(h)).filter(Boolean).map(h=>this._constructor.LIMIT_ONLY_LITERALS?this.simplifyUnlessLiteral(h):h),o=i.map(h=>this.sql(h)).join(", ");s&&i.some(h=>!h.isNumber)&&(o=`(${o})`);let c=this.expressions(e,{flat:!0}),p=this.sql(e,"limitOptions");c=c?` BY ${c}`:"";let u=s?"TOP":"LIMIT";return`${r}${this.seg(u)} ${o}${p}${c}`}offsetSql(e){let t=this.sql(e,"this"),s=e.args.expression;s=this._constructor.LIMIT_ONLY_LITERALS?this.simplifyUnlessLiteral(s):s;let r=this.expressions(e,{flat:!0}),i=r?` BY ${r}`:"";return`${t}${this.seg("OFFSET")} ${this.sql(s)}${i}`}setItemSql(e){let t=this.sql(e,"kind").toUpperCase();!this._constructor.SET_ASSIGNMENT_REQUIRES_VARIABLE_KEYWORD&&t==="VARIABLE"?t="":t=t?`${t} `:"";let s=this.sql(e,"this"),r=this.expressions(e),i=this.sql(e,"collate");return i=i?` COLLATE ${i}`:"",`${e.args.global?"GLOBAL ":""}${t}${s}${r}${i}`}setSql(e){let t=` ${this.expressions(e,{flat:!0})}`,s=e.args.tag?" TAG":"";return`${e.args.unset?"UNSET":"SET"}${s}${t}`}queryBandSql(e){let t=this.sql(e,"this"),s=e.args.update?" UPDATE":"",r=this.sql(e,"scope"),i=r?` FOR ${r}`:"";return`QUERY_BAND = ${t}${s}${i}`}pragmaSql(e){return`PRAGMA ${this.sql(e,"this")}`}lockSql(e){if(!this._constructor.LOCKING_READS_SUPPORTED)return this.unsupported("Locking reads using 'FOR UPDATE/SHARE' are not supported"),"";let t=e.args.update,s=e.args.key,r;(t instanceof I?t.args.this!=="0":!!t)?r=s?"FOR NO KEY UPDATE":"FOR UPDATE":r=s?"FOR KEY SHARE":"FOR SHARE";let o=this.expressions(e,{flat:!0}),c=o?` OF ${o}`:"",p=e.args.wait,u="";return p!==void 0&&(p instanceof I?u=` WAIT ${this.sql(p)}`:u=p?" NOWAIT":" SKIP LOCKED"),`${r}${c}${u||""}`}literalSql(e){let t=e.args.this||"";return e.isString&&(t=`${this.dialect._constructor.QUOTE_START}${this.escapeStr(t)}${this.dialect._constructor.QUOTE_END}`),t}escapeStr(e,t={}){let{escapeBackslash:s=!0,delimiter:r,escapedDelimiter:i,isByteString:o=!1}=t;(o?this.dialect._constructor.BYTE_STRINGS_SUPPORT_ESCAPED_SEQUENCES:this.dialect._constructor.STRINGS_SUPPORT_ESCAPED_SEQUENCES)&&(e=Array.from(e).map(u=>{let h=this.dialect._constructor.ESCAPED_SEQUENCES[u];return h!==void 0&&(s||u!=="\\")?h:u}).join(""));let p=r||this.dialect._constructor.QUOTE_END;return this.replaceLineBreaks(e).replaceAll(p,i||this.escapedQuoteEnd)}loadDataSql(e){let t=e.args.local?" LOCAL":"",s=` INPATH ${this.sql(e,"inpath")}`,r=e.args.overwrite?" OVERWRITE":"",i=` INTO TABLE ${this.sql(e,"this")}`,o=this.sql(e,"partition"),c=o?` ${o}`:"",p=this.sql(e,"inputFormat"),u=p?` INPUTFORMAT ${p}`:"",h=this.sql(e,"serde"),g=h?` SERDE ${h}`:"";return`LOAD DATA${t}${s}${r}${i}${c}${u}${g}`}nullSql(...e){return"NULL"}booleanSql(e){return e.args.this?"TRUE":"FALSE"}boolandSql(e){return`((${this.sql(e,"this")}) AND (${this.sql(e,"expression")}))`}boolorSql(e){return`((${this.sql(e,"this")}) OR (${this.sql(e,"expression")}))`}orderSql(e,t={}){let{flat:s=!1}=t,r=this.sql(e,"this");r=r&&`${r} `;let i=e.args.siblings?"SIBLINGS ":"";return this.opExpressions(`${r}ORDER ${i}BY`,e,{flat:s||!!r})}withFillSql(e){let t=this.sql(e,"from");t=t?` FROM ${t}`:"";let s=this.sql(e,"to");s=s?` TO ${s}`:"";let r=this.sql(e,"step");r=r?` STEP ${r}`:"";let o=e.args.interpolate?.map(p=>p instanceof Oe?`${this.sql(p,"alias")} AS ${this.sql(p,"this")}`:this.sql(p,"this"))||[],c=o.length?` INTERPOLATE (${o.join(", ")})`:"";return`WITH FILL${t}${s}${r}${c}`}clusterSql(e){return this.opExpressions("CLUSTER BY",e)}distributeSql(e){return this.opExpressions("DISTRIBUTE BY",e)}sortSql(e){return this.opExpressions("SORT BY",e)}orderedSql(e){let t=e.args.desc,s=!t,r=e.args.nullsFirst,i=!r,o=this.dialect._constructor.NULL_ORDERING==="nulls_are_large",c=this.dialect._constructor.NULL_ORDERING==="nulls_are_small",p=this.dialect._constructor.NULL_ORDERING==="nulls_are_last",u=this.sql(e,"this"),h=t?" DESC":t===!1?" ASC":"",g="";if(r&&(s&&o||t&&c||p)?g=" NULLS FIRST":i&&(s&&c||t&&o)&&!p&&(g=" NULLS LAST"),g&&this._constructor.NULL_ORDERING_SUPPORTED!=="supported"){let f=e.findAncestor(Ue,se),T,y;if(f instanceof Ue&&(T=f.args.this,T?.constructor&&(T.constructor.key==="ignoreNulls"||T.constructor.key==="respectNulls")&&(T=T.args.this),y=f.args.spec),!(T instanceof d&&this._constructor.WINDOW_FUNCS_WITH_NULL_ORDERING.some(m=>T instanceof m)&&(!y||y instanceof pu&&String(y.args.kind).toUpperCase()==="ROWS")))if(T&&y)this.unsupported(`'${g.trim()}' translation not supported in window function ${T._constructor.name}`),g="";else if(this._constructor.NULL_ORDERING_SUPPORTED==="partial"&&(s&&g===" NULLS LAST"||t&&g===" NULLS FIRST")){let m=e.findAncestor(D,Ue,se);m instanceof Ue&&(m=m.args.this),m instanceof D&&(this.unsupported(`'${g.trim()}' translation not supported for aggregate function ${m._constructor.name} with ${h} sort order`),g="")}else this._constructor.NULL_ORDERING_SUPPORTED==="unsupported"&&(e.args.this?.isInteger?this.unsupported(`'${g.trim()}' translation not supported with positional ordering`):e.args.this instanceof vr||(u=`CASE WHEN ${u} IS NULL THEN 1 ELSE 0 END${g===" NULLS FIRST"?" DESC":""}, ${u}`),g="")}let x=this.sql(e,"withFill");return x=x?` ${x}`:"",`${u}${h}${g}${x}`}matchRecognizeMeasureSql(e){let t=this.sql(e,"windowFrame"),s=t?`${t} `:"",r=this.sql(e,"this");return`${s}${r}`}matchRecognizeSql(e){let t=this.partitionBySql(e),s=this.sql(e,"order"),r=this.expressions(e,{key:"measures"}),i=r?this.seg(`MEASURES${this.seg(r)}`):"",o=this.sql(e,"rows"),c=o?this.seg(o):"",p=this.sql(e,"after"),u=p?this.seg(p):"",h=this.sql(e,"pattern"),g=h?this.seg(`PATTERN (${h})`):"",x=(e.args.define||[]).map(C=>`${this.sql(C,"alias")} AS ${this.sql(C,"this")}`),f=this.expressions(void 0,{sqls:x}),T=f?this.seg(`DEFINE${this.seg(f)}`):"",y=[t,s,i,c,u,g,T].join(""),b=this.sql(e,"alias"),m=b?` ${b}`:"";return`${this.seg("MATCH_RECOGNIZE")} ${this.wrap(y)}${m}`}queryModifiers(e,...t){let s=e.getArgKey("limit");if(s!==void 0&&!(s instanceof hr||s instanceof Dt))return"";let r=this._constructor.LIMIT_FETCH;return r==="LIMIT"&&s instanceof hr?s=new Dt({expression:$e(s.args.count)}):r==="FETCH"&&s instanceof Dt&&(s=new hr({direction:"FIRST",count:$e(s.args.expression)})),zI([...t,...e.args.joins?.map(i=>this.sql(i))??[],this.sql(e,"match"),...e.args.laterals?.map(i=>this.sql(i))??[],this.sql(e,"prewhere"),this.sql(e,"where"),this.sql(e,"connect"),this.sql(e,"group"),this.sql(e,"having"),...Array.from(this._constructor.AFTER_HAVING_MODIFIER_TRANSFORMS.values()).map(i=>i.call(this,e)),this.sql(e,"order"),...this.offsetLimitModifiers(e,{fetch:s instanceof hr},s),...this.afterLimitModifiers(e),this.optionsModifier(e),this.forModifiers(e)],{sep:""})}optionsModifier(e){let t=this.expressions(e,{key:"options"});return t?` ${t}`:""}forModifiers(e){let t=this.expressions(e,{key:"for"});return t?`${this.sep()}FOR XML${this.seg(t)}`:""}queryOptionSql(e){return this.unsupported("Unsupported query option."),""}afterLimitModifiers(e){let t=this.expressions(e,{key:"locks",sep:" "});return t=t?` ${t}`:"",[t,this.sql(e,"sample")]}selectSql(e){let t=e.args.into;!this._constructor.SUPPORTS_SELECT_INTO&&t&&t.pop();let s=this.sql(e,"hint"),r=this.sql(e,"distinct");r=r?` ${r}`:"";let i=this.sql(e,"kind"),o=e.args.limit,c="";this._constructor.LIMIT_IS_TOP&&o instanceof Dt&&(c=this.limitSql(o,{top:!0}),o.pop());let p=this.expressions(e),u=this._constructor;if(i)if(u.SELECT_KINDS.includes(i))i=` AS ${i}`;else{if(i==="STRUCT"){let b=(e.args.expressions||[]).map(m=>m instanceof Oe?new ot({this:m.args.alias instanceof F?m.args.alias:new F({this:m.args.alias?.toString()||""}),expression:m.args.this}):m);p=this.expressions(void 0,{sqls:[new Es({expressions:b})]})}i=""}let h=this.expressions(e,{key:"operationModifiers",sep:" "}),g=h?`${this.sep()}${h}`:"",x=u.LIMIT_IS_TOP?`${r}${s}${c}`:`${c}${s}${r}`,f=e.args.exclude;if(!u.STAR_EXCLUDE_REQUIRES_DERIVED_TABLE&&f){let y=this.expressions({sqls:f,flat:!0});p=`${p}${this.seg("EXCLUDE")} (${y})`}p=p&&`${this.sep()}${p}`;let T=this.queryModifiers(e,`SELECT${x}${g}${i}${p}`,this.sql(e,"into",{comment:!1}),this.sql(e,"from",{comment:!1}));if(T=this.prependCtes(e,T),u.STAR_EXCLUDE_REQUIRES_DERIVED_TABLE&&f){e.setArgKey("exclude",void 0);let y=e.subquery({copy:!1}),b=new Ne({except:f});T=this.sql(Ye(b).from(y,{copy:!1}))}if(!u.SUPPORTS_SELECT_INTO&&t){re(t,iu);let y="";t.args.temporary?y=" TEMPORARY":u.SUPPORTS_UNLOGGED_TABLES&&t.args.unlogged&&(y=" UNLOGGED"),T=`CREATE${y} TABLE ${this.sql(t.args.this)} AS ${T}`}return T}schemaSql(e){let t=this.sql(e,"this"),s=this.schemaColumnsSql(e);return t&&s?`${t} ${s}`:t||s}schemaColumnsSql(e){return e.args.expressions?.length?`(${this.sep("")}${this.expressions(e)}${this.seg(")","")}`:""}starSql(e){let t=this.expressions(e,{key:"except",flat:!0});t=t?`${this.seg(this._constructor.STAR_EXCEPT)} (${t})`:"";let s=this.expressions(e,{key:"replace",flat:!0});s=s?`${this.seg("REPLACE")} (${s})`:"";let r=this.expressions(e,{key:"rename",flat:!0});return r=r?`${this.seg("RENAME")} (${r})`:"",`*${t}${s}${r}`}parameterSql(e){let t=this.sql(e,"this");return`${this._constructor.PARAMETER_TOKEN}${t}`}sessionParameterSql(e){let t=this.sql(e,"this"),s=e.text("kind");return s&&(s=`${s}.`),`@@${s}${t}`}placeholderSql(e){return e.args.this!==void 0?`${this._constructor.NAMED_PLACEHOLDER_TOKEN}${e.name}`:"?"}subquerySql(e,t={}){let{sep:s=" AS "}=t,r=this.sql(e,"alias");r=r?`${s}${r}`:"";let i=this.sql(e,"sample");this.dialect._constructor.ALIAS_POST_TABLESAMPLE&&i&&(r=`${i}${r}`,e.setArgKey("sample",void 0));let o=this.expressions(e,{key:"pivots",sep:"",flat:!0}),c=this.queryModifiers(e,this.wrap(e),r,o);return this.prependCtes(e,c)}qualifySql(e){let t=this.indent(this.sql(e,"this"));return`${this.seg("QUALIFY")}${this.sep()}${t}`}unnestSql(e){let t=this.expressions(e,{flat:!0}),s=e.args.alias,r=e.args.offset;this._constructor.UNNEST_WITH_ORDINALITY&&s&&r instanceof F&&(re(s,pe),s.args.columns?s.args.columns.push(r):s.setArgKey("columns",[r]));let i="";if(s&&this.dialect._constructor.UNNEST_COLUMN_ONLY){re(s,pe);let c=s.columns;i=c[0]?this.sql(c[0]):""}else i=this.sql(s);i=i&&` AS ${i}`;let o="";return this._constructor.UNNEST_WITH_ORDINALITY?o=r?` WITH ORDINALITY${i}`:i:r instanceof d?o=`${i} WITH OFFSET AS ${this.sql(r)}`:r?o=`${i} WITH OFFSET`:o=i,`UNNEST(${t})${o}`}preWhereSql(e){return""}whereSql(e){let t=this.indent(this.sql(e,"this"));return`${this.seg("WHERE")}${this.sep()}${t}`}windowSql(e){let t=this.sql(e,"this"),s=this.partitionBySql(e),r=e.args.order;r&&re(r,ye);let i=r?this.orderSql(r,{flat:!0}):"",o=this.sql(e,"spec"),c=this.sql(e,"alias"),p=this.sql(e,"over")||"OVER";t=`${t} ${e.argKey==="windows"?"AS":p}`;let u=e.args.first,h="";if(u!==void 0&&(h=u?"FIRST":"LAST"),!s&&!i&&!o&&c)return`${t} ${c}`;let g=this.formatArgs([c,h,s,i,o].filter(x=>x),{sep:" "});return`${t} (${g})`}partitionBySql(e){let t=this.expressions(e,{key:"partitionBy",flat:!0});return t?`PARTITION BY ${t}`:""}windowSpecSql(e){let t=this.sql(e,"kind"),s=zI([this.sql(e,"start"),this.sql(e,"startSide")],{sep:" "}),r=zI([this.sql(e,"end"),this.sql(e,"endSide")],{sep:" "})||"CURRENT ROW",i=`${t} BETWEEN ${s} AND ${r}`,o=this.sql(e,"exclude");return o&&(this._constructor.SUPPORTS_WINDOW_EXCLUDE?i+=` EXCLUDE ${o}`:this.unsupported("EXCLUDE clause is not supported in the WINDOW clause")),i}withinGroupSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return s=s.substring(1),`${t} WITHIN GROUP (${s})`}betweenSql(e){let t=this.sql(e,"this"),s=this.sql(e,"low"),r=this.sql(e,"high"),i=e.args.symmetric;if(i&&!this._constructor.SUPPORTS_BETWEEN_FLAGS)return`(${t} BETWEEN ${s} AND ${r} OR ${t} BETWEEN ${r} AND ${s})`;let o=i?" SYMMETRIC":i===!1&&this._constructor.SUPPORTS_BETWEEN_FLAGS?" ASYMMETRIC":"";return`${t} BETWEEN${o} ${s} AND ${r}`}bracketOffsetExpressions(e,t={}){if(e.args.jsonAccess)return e.args.expressions||[];let{indexOffset:s}=t,r=(s!==void 0?s:this.dialect._constructor.INDEX_OFFSET)-(e.args.offset||0),i=e.args.this instanceof d?e.args.this:new d({});return dA(i,e.args.expressions||[],r,{dialect:this.dialect})}bracketSql(e){let s=this.bracketOffsetExpressions(e).map(r=>this.sql(r)).join(", ");return`${this.sql(e,"this")}[${s}]`}allSql(e){let t=this.sql(e,"this"),s=e.args.this;return s&&!(s instanceof Ze||s instanceof Re)&&(t=this.wrap(t)),`ALL ${t}`}anySql(e){let t=this.sql(e,"this"),s=e.args.this;return Ls.some(r=>s instanceof r)||s instanceof Re?(Ls.some(r=>s instanceof r)&&(t=this.wrap(t)),`ANY${t}`):`ANY ${t}`}existsSql(e){return`EXISTS${this.wrap(e)}`}caseSql(e){let t=this.sql(e,"this"),s=[t?`CASE ${t}`:"CASE"],r=e.args.ifs;if(r)for(let o of r)s.push(`WHEN ${this.sql(o,"this")}`),s.push(`THEN ${this.sql(o,"true")}`);let i=this.sql(e,"default");return i&&s.push(`ELSE ${i}`),s.push("END"),this.pretty&&this.tooWide(s)?this.indent(s.join(`
|
|
11
|
+
`),{skipFirst:!0,skipLast:!0}):s.join(" ")}constraintSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});return`CONSTRAINT ${t} ${s}`}nextValueForSql(e){let t=e.args.order;t&&re(t,ye);let s=t?` OVER (${this.orderSql(t,{flat:!0})})`:"";return`NEXT VALUE FOR ${this.sql(e,"this")}${s}`}extractSql(e){let t=e.args.this;this._constructor.NORMALIZE_EXTRACT_DATE_PARTS&&(t=KH(t,{dialect:this.dialect})||t);let s=this._constructor.EXTRACT_ALLOWS_QUOTES?this.sql(t):t.name,r=this.sql(e,"expression");return`EXTRACT(${s} FROM ${r})`}trimSql(e){let t=this.sql(e,"position"),s,r=t.toUpperCase();return r==="LEADING"?s="LTRIM":r==="TRAILING"?s="RTRIM":s="TRIM",this.func(s,[e.args.this,e.args.expression])}convertConcatArgs(e){let t=e.args.expressions||[];if(Array.isArray(t)||(t=t?[t]:[]),e instanceof Wt&&(t=t.slice(1)),this.dialect._constructor.STRICT_STRING_CONCAT&&e.args.safe&&(t=t.map(s=>X(s,"text",{dialect:this.dialect}))),!this.dialect._constructor.CONCAT_COALESCE&&e.args.coalesce){let s=n(r=>(r.type||(r=Kt(r,{dialect:this.dialect})),r.isString||r.isType("array")?r:new tt({this:r,expressions:[new I({this:"",isString:!0})]})),"wrapWithCoalesce");t=t.map(s)}return t}concatSql(e){if(this.dialect._constructor.CONCAT_COALESCE&&!e.args.coalesce)return ZH.call(this,e);let t=this.convertConcatArgs(e);return!this._constructor.SUPPORTS_SINGLE_ARG_CONCAT&&t.length===1?this.sql(t[0]):this.func("CONCAT",t)}concatWsSql(e){let s=(e.args.expressions||[])[0],r=this.convertConcatArgs(e);return this.func("CONCAT_WS",[s,...r])}checkSql(e){return`CHECK (${this.sql(e,"this")})`}foreignKeySql(e){let t=this.expressions(e,{flat:!0});t=t?` (${t})`:"";let s=this.sql(e,"reference");s=s?` ${s}`:"";let r=this.sql(e,"delete");r=r?` ON DELETE ${r}`:"";let i=this.sql(e,"update");i=i?` ON UPDATE ${i}`:"";let o=this.expressions(e,{key:"options",flat:!0,sep:" "});return o=o?` ${o}`:"",`FOREIGN KEY${t}${s}${r}${i}${o}`}primaryKeySql(e){let t=this.sql(e,"this");t=t?` ${t}`:"";let s=this.expressions(e,{flat:!0}),r=this.sql(e,"include"),i=this.expressions(e,{key:"options",flat:!0,sep:" "});return i=i?` ${i}`:"",`PRIMARY KEY${t} (${s})${r}${i}`}ifSql(e){return this.caseSql(new ut({ifs:[e],default:e.args.false}))}matchAgainstSql(e){let t=e.args.expressions||[];this._constructor.MATCH_AGAINST_TABLE_PREFIX?t=t.map(i=>i instanceof W?`TABLE ${this.sql(i)}`:i):t=e.args.expressions||[];let s=e.args.modifier,r=s?` ${s}`:"";return`${this.func("MATCH",t)} AGAINST(${this.sql(e,"this")}${r})`}jsonKeyValueSql(e){return`${this.sql(e,"this")}${this._constructor.JSON_KEY_VALUE_PAIR_SEP} ${this.sql(e,"expression")}`}jsonPathSql(e){let t=this.expressions(e,{sep:"",flat:!0}).replace(/^\.+/,"");return e.args.escape&&(t=this.escapeStr(t)),this._constructor.QUOTE_JSON_PATH&&(t=`${this.dialect._constructor.QUOTE_START}${t}${this.dialect._constructor.QUOTE_END}`),t}jsonPathPart(e){if(e===void 0)return"";if(e instanceof Ut){let s=this._constructor.TRANSFORMS.get(e._constructor);return typeof s!="function"?(this.unsupported(`Unsupported JsonPathPart type ${e._constructor.name}`),""):s.call(this,e)}return typeof e=="number"?String(e):this.quoteJsonPathKeyUsingBrackets&&this._constructor.JSON_PATH_SINGLE_QUOTE_ESCAPE?`\\'${e.toString().replaceAll("'","\\'")}\\'`:`"${e.toString().replace(/"/g,'\\"')}"`}formatJsonSql(e){return`${this.sql(e,"this")} FORMAT JSON`}formatPhraseSql(e){let t=this.sql(e,"this"),s=this.sql(e,"format");return`${t} (FORMAT ${s})`}jsonObjectSql(e){let t=e.args.nullHandling,s=t?` ${t}`:"",r=e.args.uniqueKeys,i="";r!=null&&(i=` ${r?"WITH":"WITHOUT"} UNIQUE KEYS`);let o=this.sql(e,"returnType"),c=o?` RETURNING ${o}`:"",p=this.sql(e,"encoding"),u=p?` ENCODING ${p}`:"",h=e instanceof Sh?"JSON_OBJECT":"JSON_OBJECTAGG";return this.func(h,e.args.expressions||[],{suffix:`${s}${i}${c}${u})`})}jsonObjectAggSql(e){return this.jsonObjectSql(e)}jsonArraySql(e){let t=e.args.nullHandling,s=t?` ${t}`:"",r=this.sql(e,"returnType"),i=r?` RETURNING ${r}`:"",o=e.args.strict?" STRICT":"";return this.func("JSON_ARRAY",e.args.expressions||[],{suffix:`${s}${i}${o})`})}jsonArrayAggSql(e){let t=this.sql(e,"this"),s=this.sql(e,"order"),r=e.args.nullHandling,i=r?` ${r}`:"",o=this.sql(e,"returnType"),c=o?` RETURNING ${o}`:"",p=e.args.strict?" STRICT":"";return this.func("JSON_ARRAYAGG",[t],{suffix:`${s}${i}${c}${p})`})}jsonColumnDefSql(e){let t=this.sql(e,"path"),s=t?` PATH ${t}`:"",r=this.sql(e,"nestedSchema");if(r)return`NESTED${s} ${r}`;let i=this.sql(e,"this"),o=this.sql(e,"kind"),c=o?` ${o}`:"",p=e.args.ordinality?" FOR ORDINALITY":"";return`${i}${c}${s}${p}`}jsonSchemaSql(e){return this.func("COLUMNS",e.args.expressions||[])}jsonTableSql(e){let t=this.sql(e,"this"),s=this.sql(e,"path"),r=s?`, ${s}`:"",i=e.args.errorHandling,o=i?` ${i}`:"",c=e.args.emptyHandling,p=c?` ${c}`:"",u=this.sql(e,"schema");return this.func("JSON_TABLE",[t],{suffix:`${r}${o}${p} ${u})`})}openJsonColumnDefSql(e){let t=this.sql(e,"this"),s=this.sql(e,"kind"),r=this.sql(e,"path"),i=r?` ${r}`:"",o=e.args.asJson?" AS JSON":"";return`${t} ${s}${i}${o}`}openJsonSql(e){let t=this.sql(e,"this"),s=this.sql(e,"path"),r=s?`, ${s}`:"",i=this.expressions(e),o=i?` WITH (${this.seg(this.indent(i),"")}${this.seg(")","")}`:"";return`OPENJSON(${t}${r})${o}`}inSql(e){let t=e.args.query,s=e.args.unnest,r=e.args.field,i=e.args.isGlobal?" GLOBAL":"",o;if(t)o=this.sql(t);else if(s)o=this.inUnnestOp(s);else if(r)o=this.sql(r);else{let c={dynamic:!0,newLine:!0,skipFirst:!0,skipLast:!0};o=`(${this.expressions(e,c)})`}return`${this.sql(e,"this")}${i} IN ${o}`}inUnnestOp(e){return`(SELECT ${this.sql(e)})`}intervalSql(e){let t=e.args.unit,s=t?this.sql(t):"";this._constructor.INTERVAL_ALLOWS_PLURAL_FORM||(s=this._constructor.TIME_PART_SINGULARS[s]||s);let r=s?` ${s}`:"";if(this._constructor.SINGLE_STRING_INTERVAL){let o=e.args.this instanceof d?e.args.this?.name||"":e.args.this;return o?t instanceof Wr?`INTERVAL '${o}'${r}`:`INTERVAL '${o}${r}'`:`INTERVAL${r}`}let i=this.sql(e,"this");return i&&(i=e.args.this instanceof d&&this._constructor.UNWRAPPED_INTERVAL_VALUES.has(e.args.this._constructor)?` ${i}`:` (${i})`),`INTERVAL${i}${r}`}returnSql(e){return`RETURN ${this.sql(e,"this")}`}referenceSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});s=s?`(${s})`:"";let r=this.expressions(e,{key:"options",flat:!0,sep:" "});return r=r?` ${r}`:"",`REFERENCES ${t}${s}${r}`}anonymousSql(e){let t=e.parent,s=t instanceof ge&&t.args.expression===e;return this.func(this.sql(e,"this"),e.args.expressions||[],{normalize:!s})}parenSql(e){return`(${this.seg(this.indent(this.sql(e,"this")),"")}${this.seg(")","")}`}negSql(e){let t=this.sql(e,"this");return`-${t[0]==="-"?" ":""}${t}`}notSql(e){return`NOT ${this.sql(e,"this")}`}aliasSql(e){let t=this.sql(e,"alias");return t=t?` AS ${t}`:"",`${this.sql(e,"this")}${t}`}pivotAliasSql(e){let t=e.args.alias,s=e.parent,r=s&&s.parent;if(r instanceof Ln&&r.unpivot){let i=t instanceof F,o=t instanceof I;if(i&&!this._constructor.UNPIVOT_ALIASES_ARE_IDENTIFIERS){let c=new I({this:t.name,isString:!0}),p=this.sql(c);return`${this.sql(e,"this")} AS ${p}`}else if(!i&&o&&this._constructor.UNPIVOT_ALIASES_ARE_IDENTIFIERS){let c=Z(t.name),p=this.sql(c);return`${this.sql(e,"this")} AS ${p}`}}return this.aliasSql(e)}aliasesSql(e){return`${this.sql(e,"this")} AS (${this.expressions(e,{flat:!0})})`}atIndexSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return`${t} AT ${s}`}atTimeZoneSql(e){let t=this.sql(e,"this"),s=this.sql(e,"zone");return`${t} AT TIME ZONE ${s}`}fromTimeZoneSql(e){let t=this.sql(e,"this"),s=this.sql(e,"zone");return`${t} AT TIME ZONE ${s} AT TIME ZONE 'UTC'`}addSql(e){return this.binary(e,"+")}andSql(e,t){return this.connectorSql(e,"AND",t)}orSql(e,t){return this.connectorSql(e,"OR",t)}xorSql(e,t){return this.connectorSql(e,"XOR",t)}connectorSql(e,t,s){if(s!==void 0){if(e.args.expressions&&0<e.args.expressions.length)s.push(this.expressions(e,{sep:` ${t} `}));else{if(s.push(e.right||""),e.comments&&this.comments)for(let p of e.comments)p&&(t+=` /*${this.sanitizeComment(p)}*/`);s.push(t,e.left||"")}return t}let r=[e],i=[],o=new Set;for(;0<r.length;){let p=r.pop();if(p instanceof Ae){let u=`${p._constructor.key}Sql`,h=this[u];typeof h=="function"&&o.add(h.call(this,p,r))}else{let u=this.sql(p),h=i[i.length-1];0<i.length&&o.has(h)?i[i.length-1]+=` ${u}`:i.push(u)}}let c=this.pretty&&this.tooWide(i)?`
|
|
12
|
+
`:" ";return i.join(c)}bitwiseAndSql(e){return this.binary(e,"&")}bitwiseLeftShiftSql(e){return this.binary(e,"<<")}bitwiseNotSql(e){return`~${this.sql(e,"this")}`}bitwiseOrSql(e){return this.binary(e,"|")}bitwiseRightShiftSql(e){return this.binary(e,">>")}bitwiseXorSql(e){return this.binary(e,"^")}castSql(e,t={}){let{safePrefix:s}=t,r=this.sql(e,"format");r=r?` FORMAT ${r}`:"";let i=this.sql(e,"to");i=i?` ${i}`:"";let o=this.sql(e,"action");o=o?` ${o}`:"";let c=this.sql(e,"default");return c=c?` DEFAULT ${c} ON CONVERSION ERROR`:"",`${s||""}CAST(${this.sql(e,"this")} AS${i}${c}${r}${o})`}strToTimeSql(e){return this.func("STR_TO_TIME",[e.args.this??"",e.args.format])}currentDateSql(e){let t=this.sql(e,"this");return t?`CURRENT_DATE(${t})`:"CURRENT_DATE"}collateSql(e){return this._constructor.COLLATE_IS_FUNC?this.functionFallbackSql(e):this.binary(e,"COLLATE")}commandSql(e){let t=this.sql(e,"this"),s=e.text("expression").trim();return`${t} ${s}`}commentSql(e){let t=this.sql(e,"this"),s=e.args.kind,r=e.args.materialized?" MATERIALIZED":"",i=e.args.exists?" IF EXISTS ":" ",o=this.sql(e,"expression");return`COMMENT${i}ON${r} ${s} ${t} IS ${o}`}mergeTreeTtlActionSql(e){let t=this.sql(e,"this"),s=e.args.delete?" DELETE":"",r=this.sql(e,"recompress"),i=r?` RECOMPRESS ${r}`:"",o=this.sql(e,"toDisk"),c=o?` TO DISK ${o}`:"",p=this.sql(e,"toVolume"),u=p?` TO VOLUME ${p}`:"";return`${t}${s}${i}${c}${u}`}mergeTreeTtlSql(e){let t=this.sql(e,"where"),s=this.sql(e,"group"),r=this.expressions(e,{key:"aggregates"}),i=r?`${this.seg("SET")}${this.seg(r)}`:"";return!t&&!s&&!i&&e.args.expressions?.length===1?`TTL ${this.expressions(e,{flat:!0})}`:`TTL${this.seg(this.expressions(e))}${t}${s}${i}`}transactionSql(e){let t=this.expressions(e,{key:"modes"});return`BEGIN${t?` ${t}`:""}`}commitSql(e){let t=e.args.chain,s="";return t!==void 0&&(s=t?" AND CHAIN":" AND NO CHAIN"),`COMMIT${s}`}rollbackSql(e){let t=e.args.savepoint;return`ROLLBACK${t?` TO ${t}`:""}`}alterColumnSql(e){let t=this.sql(e,"this"),s=this.sql(e,"dtype");if(s){let u=this.sql(e,"collate");u=u?` COLLATE ${u}`:"";let h=this.sql(e,"using");h=h?` USING ${h}`:"";let g=this._constructor.ALTER_SET_TYPE,x=g?`${g} `:"";return`ALTER COLUMN ${t} ${x}${s}${u}${h}`}let r=this.sql(e,"default");if(r)return`ALTER COLUMN ${t} SET DEFAULT ${r}`;let i=this.sql(e,"comment");if(i)return`ALTER COLUMN ${t} COMMENT ${i}`;let o=e.args.visible;if(o)return`ALTER COLUMN ${t} SET ${o}`;let c=e.args.allowNull,p=e.args.drop;return!p&&!c&&this.unsupported("Unsupported ALTER COLUMN syntax"),c!==void 0?`ALTER COLUMN ${t} ${p?"DROP":"SET"} NOT NULL`:`ALTER COLUMN ${t} DROP DEFAULT`}modifyColumnSql(e){return this._constructor.SUPPORTS_MODIFY_COLUMN||this.unsupported("MODIFY COLUMN is not supported in this dialect"),`MODIFY COLUMN ${this.sql(e,"this")}`}alterIndexSql(e){let t=this.sql(e,"this"),r=e.args.visible?"VISIBLE":"INVISIBLE";return`ALTER INDEX ${t} ${r}`}alterDistStyleSql(e){let t=this.sql(e,"this");return e.args.this instanceof Ve||(t=`KEY DISTKEY ${t}`),`ALTER DISTSTYLE ${t}`}alterSortKeySql(e){let t=e.args.compound?" COMPOUND":"",s=this.sql(e,"this"),r=this.expressions(e,{flat:!0});return r=r?`(${r})`:"",`ALTER${t} SORTKEY ${s||r}`}alterRenameSql(e,t={}){let{includeTo:s=!0}=t,r=e;this._constructor.RENAME_TABLE_WITH_DB||(r=e.transform(c=>c instanceof W?new W({this:c.args.this}):c).assertIs(Yn));let i=this.sql(r,"this");return`RENAME${s?" TO":""} ${i}`}renameColumnSql(e){let t=e.args.exists?" IF EXISTS":"",s=this.sql(e,"this"),r=this.sql(e,"to");return`RENAME COLUMN${t} ${s} TO ${r}`}alterSetSql(e){let t=this.expressions(e,{flat:!0});return this._constructor.ALTER_SET_WRAPPED&&(t=`(${t})`),`SET ${t}`}alterSql(e){let t=e.args.actions||[],s;if(!this.dialect._constructor.ALTER_TABLE_ADD_REQUIRED_FOR_EACH_COLUMN&&t[0]instanceof Pe)s=this.expressions(e,{key:"actions",flat:!0}),s=`ADD ${s}`;else{let T=[];for(let y of t){let b=y,m;b instanceof Pe||b instanceof Rt?m=this.addColumnSql(b):(m=this.sql(b),(b instanceof se||b instanceof or)&&(m=`AS ${m}`)),T.push(m)}s=this.formatArgs(T).replace(/^\n+/,"")}let r=e.args.iceberg&&this._constructor.SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY?"ICEBERG ":"",i=e.args.exists?" IF EXISTS":"",o=this.sql(e,"cluster");o=o?` ${o}`:"";let c=e.args.only?" ONLY":"",p=this.expressions(e,{key:"options"});p=p?`, ${p}`:"";let u=this.sql(e,"kind").toUpperCase(),h=e.args.notValid?" NOT VALID":"",g=e.args.check?" WITH CHECK":"",x=e.args.cascade&&this.dialect._constructor.ALTER_TABLE_SUPPORTS_CASCADE?" CASCADE":"",f=this.sql(e,"this");return f=f?` ${f}`:"",`ALTER ${r}${u}${i}${c}${f}${o}${g}${this.sep()}${s}${h}${p}${x}`}alterSessionSql(e){let t=this.expressions(e,{flat:!0});return`${e.args.unset?"UNSET":"SET"} ${t}`}addColumnSql(e){let t=this.sql(e),s;return e instanceof Rt?s=" COLUMNS":e instanceof Pe&&this._constructor.ALTER_TABLE_INCLUDE_COLUMN_KEYWORD?s=" COLUMN":s="",`ADD${s} ${t}`}dropPartitionSql(e){let t=this.expressions(e);return`DROP${e.args.exists?" IF EXISTS ":" "}${t}`}addConstraintSql(e){return`ADD ${this.expressions(e,{indent:!1})}`}addPartitionSql(e){let t=e.args.exists?"IF NOT EXISTS ":"",s=this.sql(e,"location");return s=s?` ${s}`:"",`ADD ${t}${this.sql(e,"this")}${s}`}distinctSql(e){let t=this.expressions(e,{flat:!0});if(!this._constructor.MULTI_ARG_DISTINCT&&1<(e.args.expressions?.length??0)){let r=qD();for(let i of e.args.expressions||[])r=r.when(i.is(le()),le());t=this.sql(r.else(`(${t})`))}t=t?` ${t}`:"";let s=this.sql(e,"on");return s=s?` ON ${s}`:"",`DISTINCT${t}${s}`}ignoreNullsSql(e){return this.embedIgnoreNulls(e,"IGNORE NULLS")}respectNullsSql(e){return this.embedIgnoreNulls(e,"RESPECT NULLS")}havingMaxSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=e.args.max?"MAX":"MIN";return`${t} HAVING ${r} ${s}`}intDivSql(e){return this.sql(new z({this:new Mt({this:e.args.this,expression:e.args.expression}),to:new N({this:"int"})}))}dPipeSql(e){if(this.dialect._constructor.STRICT_STRING_CONCAT&&e.args.safe){let t=Array.from(e.flatten()).map(s=>X(s,"text",{copy:!1}));return this.func("CONCAT",t)}return this.binary(e,"||")}divSql(e){let t=e.left,s=e.right;if(!this.dialect._constructor.SAFE_DIVISION&&e.args.safe&&s?.replace(new qh({this:s.copy(),expression:I.number(0)})),this.dialect._constructor.TYPED_DIVISION&&!e.args.typed)!t?.isType(Array.from(N.REAL_TYPES))&&!s?.isType(Array.from(N.REAL_TYPES))&&t?.replace(X(t.copy(),"double"));else if(!this.dialect._constructor.TYPED_DIVISION&&e.args.typed&&t?.isType(Array.from(N.INTEGER_TYPES))&&s?.isType(Array.from(N.INTEGER_TYPES)))return this.sql(X(t.div(s),"bigint"));return this.binary(e,"/")}safeDivideSql(e){let t=mr(e.args.this,v),s=mr(e.args.expression,v);return!t||!s?"":this.sql(new xe({this:s.neq(0),true:t.div(s),false:le()}))}overlapsSql(e){return this.binary(e,"OVERLAPS")}distanceSql(e){return this.binary(e,"<->")}dotSql(e){return`${this.sql(e,"this")}.${this.sql(e,"expression")}`}eqSql(e){return this.binary(e,"=")}propertyEqSql(e){return this.binary(e,":=")}escapeSql(e){let t=e.args.this;return(t instanceof Zt||t instanceof Gs)&&(t.args.expression instanceof cs||t.args.expression instanceof Tt)&&!this._constructor.SUPPORTS_LIKE_QUANTIFIERS?this.likeSql(t,e):this.binary(e,"ESCAPE")}globSql(e){return this.binary(e,"GLOB")}gtSql(e){return this.binary(e,">")}gteSql(e){return this.binary(e,">=")}isSql(e){if(!this._constructor.IS_BOOL_ALLOWED&&e.args.expression instanceof at){let t=e.args.this;return this.sql(e.args.expression.args.this?t:ks(t instanceof d||typeof t=="string"?t:void 0))}return this.binary(e,"IS")}iLikeSql(e){return this.likeSql(e)}likeSql(e,t){let s=e.args.this,r=e.args.expression,i,o;if(e instanceof Zt?(i=Zt,o="LIKE"):(i=Gs,o="ILIKE"),(r instanceof cs||r instanceof Tt)&&!this._constructor.SUPPORTS_LIKE_QUANTIFIERS){let c,p=r.args.this instanceof d?r.args.this.unnest():void 0;p instanceof Ze?c=p.args.expressions:p?c=[p]:c=[];let u=r instanceof Tt?Ht:ve,h=n(f=>{let T=new i({this:s,expression:f});return t&&(T=new t.constructor({this:T,expression:t.args.expression.copy()})),T},"makeLike"),g=h(c[0]);for(let f=1;f<(c?.length||0);f++)g=u([g,h(c[f]||0)]);let x=t?t.parent:e.parent;return x instanceof be&&!(x instanceof Re)&&!(x instanceof g._constructor)&&(g=zs(g,{copy:!1})),this.sql(g)}return this.binary(e,o)}matchSql(e){return this.binary(e,"MATCH")}similarToSql(e){return this.binary(e,"SIMILAR TO")}ltSql(e){return this.binary(e,"<")}lteSql(e){return this.binary(e,"<=")}modSql(e){return this.binary(e,"%")}mulSql(e){return this.binary(e,"*")}neqSql(e){return this.binary(e,"<>")}nullSafeEqSql(e){return this.binary(e,"IS NOT DISTINCT FROM")}nullSafeNeqSql(e){return this.binary(e,"IS DISTINCT FROM")}subSql(e){return this.binary(e,"-")}tryCastSql(e){return this.castSql(e,{safePrefix:"TRY_"})}jsonCastSql(e){return this.castSql(e)}trySql(e){return this._constructor.TRY_SUPPORTED?this.func("TRY",[e.args.this]):(this.unsupported("Unsupported TRY function"),this.sql(e,"this"))}logSql(e){let t=e.args.this,s=e.args.expression;if(this.dialect._constructor.LOG_BASE_FIRST===!1)[t,s]=[s,t];else if(this.dialect._constructor.LOG_BASE_FIRST===void 0&&s){if(!t)return"";let r=t.name;if(r==="2"||r==="10")return this.func(`LOG${r}`,[s]);this.unsupported(`Unsupported logarithm with base ${this.sql(t)}`)}return this.func("LOG",[t,s])}useSql(e){let t=this.sql(e,"kind"),s=t?` ${t}`:"",r=this.sql(e,"this")||this.expressions(e,{flat:!0}),i=r?` ${r}`:"";return`USE${s}${i}`}binary(e,t){let s=[],r=[e],i=e._constructor;for(;0<r.length;){let o=r.pop();if(o instanceof v&&o._constructor===i){let c=o.args.operator;c&&(t=`OPERATOR(${this.sql(c)})`),r.push(o.right||""),r.push(` ${this.maybeComment(t,void 0,o.comments)} `),r.push(o.left||"")}else s.push(this.sql(o))}return s.join("")}ceilFloor(e){let t=this.sql(e,"to");return t?`${e._constructor.sqlName()}(${this.sql(e,"this")} TO ${t})`:this.functionFallbackSql(e)}functionFallbackSql(e){let t=[];for(let r of e._constructor.availableArgs){let i=e.getArgKey(r);Array.isArray(i)?t.push(...i):t.push(i)}let s;return this.dialect._constructor.PRESERVE_ORIGINAL_NAMES?s=e.meta?.name||e._constructor.sqlName():s=e._constructor.sqlName(),this.func(s,t)}func(e,t,s={}){let{prefix:r="(",suffix:i=")",normalize:o=!0}=s;return`${o?this.normalizeFunc(e):e}${r}${this.formatArgs(t)}${i}`}formatArgs(e,t={}){let{sep:s=", "}=t,r=e.filter(i=>i!==void 0&&typeof i!="boolean").map(i=>this.sql(i)).filter(i=>i!=="");if(this.pretty&&this.tooWide(r)){let i=r.join(`${s.trim()}
|
|
13
13
|
`);return this.indent(`
|
|
14
14
|
${i}
|
|
15
|
-
`,{skipFirst:!0,skipLast:!0})}return r.join(s)}tooWide(e){let t=e.reduce((s,r)=>s+r.length,0);return this.maxTextWidth<t}expressions(e,t={}){let{flat:s=!1,indent:r=!0,skipFirst:i=!1,skipLast:o=!1,sep:c=", ",prefix:p="",dynamic:u=!1,newLine:h=!1,key:g,sqls:
|
|
16
|
-
`)):I=C.join(""),r?this.indent(I,{skipFirst:i,skipLast:o}):I}opExpressions(e,t,s={}){let r=(s.flat??!1)||t.parent instanceof He,i=this.expressions(t,{flat:r});return r?`${e} ${i}`:`${this.seg(e)}${i?this.sep():""}${i}`}nakedProperty(e){let t=He.PROPERTY_TO_NAME[e._constructor.key];return t||this.unsupported(`Unsupported property ${e._constructor.key}`),`${t||""} ${this.sql(e,"this")}`}tagSql(e){let t=e.args.prefix||"",s=e.args.postfix||"";return`${t}${this.sql(e.args.this)}${s}`}tokenSql(e){return this._constructor.TOKEN_MAPPING[e]??e.replace(/([A-Z])/g,"_$1").toUpperCase()}userDefinedFunctionSql(e){let t=this.sql(e,"this"),s=this.noIdentify(this.expressions.bind(this),e);return e.args.wrapped?s=this.wrap(s):s=s?` ${s}`:"",s.trim()!==""?`${t}${s}`:t}joinHintSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});return`${t}(${s})`}kwargSql(e){return this.binary(e,"=>")}whenSql(e){let t=e.args.matched?"MATCHED":"NOT MATCHED",s=this._constructor.MATCHED_BY_SOURCE&&e.args.source?" BY SOURCE":"",r=this.sql(e,"condition"),i=r?` AND ${r}`:"",o=e.args.then,c="";if(o instanceof es){let p=this.sql(o,"this");p=p?`INSERT ${p}`:"INSERT";let u=this.sql(o,"expression");c=u?`${p} VALUES ${u}`:p}else if(o instanceof us)if(o.getArgKey("expressions")instanceof Ne)c=`UPDATE ${this.sql(o,"expressions")}`;else{let p=this.expressions(o);c=p?`UPDATE SET${this.sep()}${p}`:"UPDATE"}else c=this.sql(o);return`WHEN ${t}${s}${i} THEN ${c}`}whensSql(e){return this.expressions(e,{sep:" ",indent:!1})}mergeSql(e){let t=e.args.this,s="";if(Y(t,_)){let h=t.args.hints||[];if(0<h.length&&t.alias&&h[0]instanceof cu){let g=t.args.alias,f=Y(g,d)?g.pop():void 0;s=f?` AS ${this.sql(f)}`:""}}let r=this.sql(t),i=`USING ${this.sql(e,"using")}`,o=this.sql(e,"whens"),c=this.sql(e,"on");if(c=c?`ON ${c}`:"",!c){let h=this.expressions(e,{key:"usingCond"});c=h?`USING (${h})`:""}let p=this.sql(e,"returning");p&&(o=`${o}${p}`);let u=this.sep();return this.prependCtes(e,`MERGE INTO ${r}${s}${u}${i}${u}${c}${u}${o}`)}toCharSql(e){return Cb.call(this,e,"format"),this.sql(X(e.args.this,"text"))}toNumberSql(e){if(!this._constructor.SUPPORTS_TO_NUMBER)return this.unsupported("Unsupported TO_NUMBER function"),this.sql(X(e.args.this,"double"));let t=e.args.format;return t?this.func("TO_NUMBER",[e.args.this,t]):(this.unsupported("Conversion format is required for TO_NUMBER"),this.sql(X(e.args.this,"double")))}dictPropertySql(e){let t=this.sql(e,"this"),s=this.sql(e,"kind"),r=this.expressions(e,{key:"settings",sep:" "}),i=r?`(${this.sep("")}${r}${this.seg(")","")}`:"()";return`${t}(${s}${i})`}dictRangeSql(e){let t=this.sql(e,"this"),s=this.sql(e,"max"),r=this.sql(e,"min");return`${t}(MIN ${r} MAX ${s})`}dictSubPropertySql(e){return`${this.sql(e,"this")} ${this.sql(e,"value")}`}duplicateKeyPropertySql(e){return`DUPLICATE KEY (${this.expressions(e,{flat:!0})})`}distributedByPropertySql(e){let t=this.expressions(e,{flat:!0});t=t?` ${this.wrap(t)}`:"";let s=this.sql(e,"buckets"),r=this.sql(e,"kind"),i=s?` BUCKETS ${s}`:"",o=this.sql(e,"order");return`DISTRIBUTED BY ${r}${t}${i}${o}`}onClusterSql(e){return""}clusteredByPropertySql(e){let t=this.expressions(e,{key:"expressions",flat:!0}),s=this.expressions(e,{key:"sortedBy",flat:!0});s=s?` SORTED BY (${s})`:"";let r=this.sql(e,"buckets");return`CLUSTERED BY (${t})${s} INTO ${r} BUCKETS`}anyValueSql(e){let t=this.sql(e,"this"),s=this.sql(e,"having");if(s){let r=e.args.max;return this.func("ANY_VALUE",[`${t} HAVING ${r?"MAX":"MIN"} ${s}`])}return this.func("ANY_VALUE",[e.args.this])}queryTransformSql(e){let t=this.func("TRANSFORM",e.args.expressions||[]),s=this.sql(e,"rowFormatBefore");s=s?` ${s}`:"";let r=this.sql(e,"recordWriter");r=r?` RECORDWRITER ${r}`:"";let i=` USING ${this.sql(e,"commandScript")}`,o=this.sql(e,"schema");o=o?` AS ${o}`:"";let c=this.sql(e,"rowFormatAfter");c=c?` ${c}`:"";let p=this.sql(e,"recordReader");return p=p?` RECORDREADER ${p}`:"",`${t}${s}${r}${i}${o}${c}${p}`}indexConstraintOptionSql(e){let t=this.sql(e,"keyBlockSize");if(t)return`KEY_BLOCK_SIZE = ${t}`;let s=this.sql(e,"using");if(s)return`USING ${s}`;let r=this.sql(e,"parser");if(r)return`WITH PARSER ${r}`;let i=this.sql(e,"comment");if(i)return`COMMENT ${i}`;let o=e.args.visible;if(o!==void 0)return o?"VISIBLE":"INVISIBLE";let c=this.sql(e,"engineAttr");if(c)return`ENGINE_ATTRIBUTE = ${c}`;let p=this.sql(e,"secondaryEngineAttr");return p?`SECONDARY_ENGINE_ATTRIBUTE = ${p}`:(this.unsupported("Unsupported index constraint option."),"")}checkColumnConstraintSql(e){let t=e.args.enforced?" ENFORCED":"";return`CHECK (${this.sql(e,"this")})${t}`}indexColumnConstraintSql(e){let t=this.sql(e,"kind"),s=t?`${t} INDEX`:"INDEX",r=this.sql(e,"this");r=r?` ${r}`:"";let i=this.sql(e,"indexType");i=i?` USING ${i}`:"";let o=this.expressions(e,{flat:!0});o=o?` (${o})`:"";let c=this.expressions(e,{key:"options",flat:!0,sep:" "});return c=c?` ${c}`:"",`${s}${r}${i}${o}${c}`}nvl2Sql(e){if(this._constructor.NVL2_SUPPORTED)return this.functionFallbackSql(e);let t=e.args.this;if(!t)return"";let s=new ut({}).when(t.is(le()).not({copy:!1}),e.args.true??"",{copy:!1}),r=e.args.false;return r&&s.else(r,{copy:!1}),this.sql(s)}comprehensionSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=this.sql(e,"position"),i=r?`, ${r}`:"",o=this.sql(e,"iterator"),c=this.sql(e,"condition"),p=c?` IF ${c}`:"";return`${t} FOR ${s}${i} IN ${o}${p}`}columnPrefixSql(e){return`${this.sql(e,"this")}(${this.sql(e,"expression")})`}opclassSql(e){return`${this.sql(e,"this")} ${this.sql(e,"expression")}`}mlSql(e,t){let s=`MODEL ${this.sql(e,"this")}`,r=e.args.expression,i;if(r){let c=this.sql(e,"expression");i=r instanceof he?c:`TABLE ${c}`}let o=this.sql(e,"paramsStruct")||void 0;return this.func(t,[s,i,o])}predictSql(e){return this.mlSql(e,"PREDICT")}generateEmbeddingSql(e){let t=e.args.isText?"GENERATE_TEXT_EMBEDDING":"GENERATE_EMBEDDING";return this.mlSql(e,t)}mlTranslateSql(e){return this.mlSql(e,"TRANSLATE")}mlForecastSql(e){return this.mlSql(e,"FORECAST")}featuresAtTimeSql(e){let t=e.args.this,s=this.sql(e,"this");return t instanceof _&&(s=`TABLE ${s}`),this.func("FEATURES_AT_TIME",[s,e.args.time,e.args.numRows,e.args.ignoreFeatureNulls])}vectorSearchSql(e){let t=this.sql(e,"this");e.args.this instanceof _&&(t=`TABLE ${t}`);let s=e.args.queryTable,r=s?this.sql(s):void 0;return s instanceof _&&(r=`TABLE ${r}`),this.func("VECTOR_SEARCH",[t,e.args.columnToSearch,r,e.args.queryColumnToSearch,e.args.topK,e.args.distanceType,e.args.options])}forInSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return`FOR ${t} DO ${s}`}refreshSql(e){let t=this.sql(e,"this");return`REFRESH ${e.args.this instanceof N?"":`${e.args.kind||""} `}${t}`}toArraySql(e){let t=e.args.this;if(!t)return"";if(t.type||(t=Kt(t,{dialect:this.dialect})),t.isType("array"))return this.sql(t);let s=t.is(le());return this.sql(HA("IF",s,le(),UA(t,{copy:!1})))}tsOrDsToTimeSql(e){let t=e.args.this;if(!t)return"";let s=this.formatTime(e);return s?this.sql(X(new Is({this:t,format:e.args.format||s}),"time")):e.args.this instanceof Hb||t.isType("time")?this.sql(t):this.sql(X(t,"time"))}tsOrDsToTimestampSql(e){let t=e.args.this;return t?t instanceof _b||t.isType("timestamp")?this.sql(t):this.sql(X(t,"timestamp",{dialect:this.dialect})):""}tsOrDsToDatetimeSql(e){let t=e.args.this;return t?e.args.this instanceof Vb||t.isType("datetime")?this.sql(t):this.sql(X(t,"datetime",{dialect:this.dialect})):""}tsOrDsToDateSql(e){let t=e.args.this;if(!t)return"";let s=this.formatTime(e),r=e.args.safe;return s&&![this.dialect._constructor.TIME_FORMAT,this.dialect._constructor.DATE_FORMAT].includes(s)?this.sql(X(new Is({this:t,format:s,safe:r}),"date")):e.args.this instanceof os||t.isType("date")?this.sql(t):r?this.sql(new $t({this:t,to:new m({this:"date"})})):this.sql(X(t,"date"))}unixDateSql(e){let t=e.args.this;return this.sql(new _s({this:t instanceof d?t:void 0,expression:X(N.string("1970-01-01"),"date"),unit:Z("day")}))}lastDaySql(e){if(this._constructor.LAST_DAY_SUPPORTS_DATE_PART)return this.functionFallbackSql(e);let t=e.text("unit"),s=t?this.sql(t):"";return s&&s!=="MONTH"&&this.unsupported("Date parts are not supported in LAST_DAY."),this.func("LAST_DAY",[e.args.this])}dateAddSql(e){return this.func("DATE_ADD",[e.args.this,e.args.expression,DM(e)])}arrayAnySql(e){if(this._constructor.CAN_IMPLEMENT_ARRAY_ANY){let t=new Va({this:e.args.this,expression:e.args.expression}),s=new Rr({this:t}).neq(0),r=new Rr({this:e.args.this}).eq(0);return this.sql(zs(r.or(s)))}return this.dialect._constructor!==ae&&this.unsupported("ARRAY_ANY is unsupported"),this.functionFallbackSql(e)}structSql(e){return e.setArgKey("expressions",(e.args.expressions??[]).map(t=>{if(t instanceof ot){let s=t.args.this,r=GY(s,o=>o instanceof v?o:o.name),i=t.args.expression;return Be(i instanceof d||typeof i=="string"?i:"",r)}return t})),this.functionFallbackSql(e)}partitionRangeSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return`${t} TO ${s}`}truncateTableSql(e){let t=e.args.isDatabase?"DATABASE":"TABLE",s=` ${this.expressions(e)}`,r=e.args.exists?" IF EXISTS":"",i=this.sql(e,"cluster");i=i?` ${i}`:"";let o=this.sql(e,"identity");o=o?` ${o} IDENTITY`:"";let c=this.sql(e,"option");c=c?` ${c}`:"";let p=this.sql(e,"partition");return p=p?` ${p}`:"",`TRUNCATE ${t}${r}${s}${i}${o}${c}${p}`}convertSql(e){let t=e.args.this,s=e.args.expression,r=e.args.style,i=e.args.safe,o=e.getArgKey("strict");if(!t||!s)return"";re(t,m);let c=t;!D(t.args.expressions??[],0)&&this._constructor.PARAMETERIZABLE_TEXT_TYPES.has(t.args.this)&&(c=m.build(t.args.this,{expressions:[N.number(30)],nested:!1})??c);let p,u=o?z:$t;if(r instanceof N&&r.isInteger){let h=r.name,f=ae.get("tsql")?.CONVERT_FORMAT_MAPPING?.[h]??"";f||this.unsupported(`Unsupported T-SQL 'style' value: ${h}`);let x=N.string(f);c.args.this==="date"?p=new oi({this:s,format:x}):c.args.this==="datetime"||c.args.this==="datetime2"?p=new Is({this:s,format:x}):this._constructor.PARAMETERIZABLE_TEXT_TYPES.has(c.args.this)?p=new u({this:new Or({this:s,format:x}),to:c,safe:i}):c.args.this==="text"&&(p=new Or({this:s,format:x}))}return p||(p=new u({this:s,to:c,safe:i})),this.sql(p)}jsonPathKeySql(e){let t=e.args.this;if(t instanceof Dt){let r=this.jsonPathPart(t);return r?`.${r}`:""}if(typeof t=="string"&&this._constructor.SAFE_JSON_PATH_KEY_RE.test(t))return`.${t}`;let s=this.jsonPathPart(typeof t=="string"?t:t instanceof d?t.name??"":"");return this.quoteJsonPathKeyUsingBrackets&&this._constructor.JSON_PATH_BRACKETED_KEY_SUPPORTED?`[${s}]`:`.${s}`}jsonPathSubscriptSql(e){let t=e.args.this,s=this.jsonPathPart(t);return s?`[${s}]`:""}simplifyUnlessLiteral(e){return e instanceof N||(e=IM(e,{dialect:this.dialect})),e}embedIgnoreNulls(e,t){let s=e.args.this;if(this._constructor.RESPECT_IGNORE_NULLS_UNSUPPORTED_EXPRESSIONS.some(r=>s instanceof r))return this.unsupported(`RESPECT/IGNORE NULLS is not supported for ${s?._constructor.key} in ${this.dialect.constructor.name}`),this.sql(s);if(this._constructor.IGNORE_NULLS_IN_FUNC&&!e.meta?.inline){if(this._constructor.IGNORE_NULLS_BEFORE_ORDER){let i=[...e.findAll([gr,Ie,kt])].sort((o,c)=>{let p=n(u=>u instanceof gr?0:u instanceof Ie?1:2,"getPriority");return p(o)-p(c)});if(0<i.length){let o=i[0],c=new e._constructor({this:o.args.this?.copy()});return c.meta={...c.meta,inline:!0},o.args.this?.replace(c),this.sql(e.args.this)}}let r=e.find(q);if(r){let i=this.sql(r,void 0,{comment:!1}).slice(0,-1)+` ${t})`;return this.maybeComment(i,void 0,r.comments)}}return`${this.sql(e,"this")} ${t}`}replaceLineBreaks(e){return this.pretty?e.replace(/\n/g,this._constructor.SENTINEL_LINE_BREAK):e}copyParameterSql(e){let t=this.sql(e,"this");if(e.args.expressions&&0<e.args.expressions.length){let i=t.toUpperCase(),o=i==="FILE_FORMAT"?" ":", ",c=i==="COPY_OPTIONS"||i==="FORMAT_OPTIONS"?" ":" = ",p=this.expressions(e,{flat:!0,sep:o});return`${t}${c}(${p})`}let s=this.sql(e,"expression");if(!s)return t;let r=this._constructor.COPY_PARAMS_EQ_REQUIRED?" = ":" ";return`${t}${r}${s}`}credentialsSql(e){let t=e.args.credentials,s="";if(t instanceof N){let f=this.sql(e,"credentials");s=f?`CREDENTIALS ${f}`:""}else{let f=this.expressions(e,{key:"credentials",flat:!0,sep:" "});s=t!=null?`CREDENTIALS = (${f})`:""}let r=this.sql(e,"storage"),i=r?`STORAGE_INTEGRATION = ${r}`:"",o=this.expressions(e,{key:"encryption",flat:!0,sep:" "}),c=o?` ENCRYPTION = (${o})`:"",p=this.sql(e,"iamRole"),u=p?`IAM_ROLE ${p}`:"",h=this.sql(e,"region"),g=h?` REGION ${h}`:"";return`${s}${i}${c}${u}${g}`}copySql(e){let t=this._constructor,s=this.sql(e,"this");s=t.COPY_HAS_INTO_KEYWORD?` INTO ${s}`:` ${s}`;let r=this.sql(e,"credentials");r=r?this.seg(r):"";let i=this.expressions(e,{key:"files",flat:!0}),o=i&&e.args.kind?this.seg("FROM"):i?this.seg("TO"):"",p=this.dialect._constructor.COPY_PARAMS_ARE_CSV||!1?", ":" ",u=this.expressions(e,{key:"params",sep:p,newLine:!0,skipLast:!0,skipFirst:!0,indent:t.COPY_PARAMS_ARE_WRAPPED});return u&&(t.COPY_PARAMS_ARE_WRAPPED?u=` WITH (${u})`:!this.pretty&&(i||r)&&(u=` ${u}`)),`COPY${s}${o} ${i}${r}${u}`}semicolonSql(e){return""}dataDeletionPropertySql(e){let t=e.args.on?"ON":"OFF",s=this.sql(e,"filterColumn"),r=s?`FILTER_COLUMN=${s}`:void 0,i=this.sql(e,"retentionPeriod"),o=i?`RETENTION_PERIOD=${i}`:void 0;return r||o?`DATA_DELETION=${this.func("ON",[r,o])}`:`DATA_DELETION=${t}`}gapFillSql(e){let t=this.sql(e,"this");t=`TABLE ${t}`;let s=Object.entries(e.args).filter(([r])=>r!=="this").map(([r,i])=>i);return this.func("GAP_FILL",[t,...s])}scopeResolution(e,t){return this.func("SCOPE_RESOLUTION",[t||void 0,e])}scopeResolutionSql(e){let t=this.sql(e,"this"),s=e.args.expression,r;if(s instanceof E){let i=this.sql(s,"this"),o=this.formatArgs(s.args.expressions||[]);r=`${i}(${o})`}else r=this.sql(e,"expression");return this.scopeResolution(r,t)}parseJsonSql(e){let t=this._constructor.PARSE_JSON_NAME;return t==null?this.sql(e.args.this):this.func(t,[e.args.this,e.args.expression])}randSql(e){let t=this.sql(e,"lower"),s=this.sql(e,"upper");return t&&s?`(${s} - ${t}) * ${this.func("RAND",[e.args.this])} + ${t}`:this.func("RAND",[e.args.this])}changesSql(e){let s=`INFORMATION => ${this.sql(e,"information")}`,r=this.sql(e,"atBefore"),i=r?`${this.seg("")}${r}`:"",o=this.sql(e,"end"),c=o?`${this.seg("")}${o}`:"";return`CHANGES (${s})${i}${c}`}padSql(e){let t=e.args.isLeft?"L":"R",s=this.sql(e,"fillPattern");return!s&&this._constructor.PAD_FILL_PATTERN_IS_REQUIRED&&(s="' '"),this.func(`${t}PAD`,[e.args.this,e.args.expression,s])}summarizeSql(e){return`SUMMARIZE${e.args.table?" TABLE":""} ${this.sql(e.args.this)}`}explodingGenerateSeriesSql(e){let t=new As({...e.args}),s=e.parent;return(s instanceof Re||s instanceof pe)&&(s=s.parent),this._constructor.SUPPORTS_EXPLODING_PROJECTIONS&&!(s instanceof _)&&!(s instanceof Ee)?this.sql(new Ee({expressions:[t]})):(s instanceof se&&this.unsupported("GenerateSeries projection unnesting is not supported."),this.sql(t))}convertTimezoneSql(e){if(this._constructor.SUPPORTS_CONVERT_TIMEZONE)return this.functionFallbackSql(e);let t=e.args.sourceTz,s=e.args.targetTz,r=e.args.timestamp;t&&r&&(r=new gs({this:X(r,"timestampntz"),zone:t}));let i=new gs({this:r,zone:s});return this.sql(i)}jsonSql(e){let t=this.sql(e,"this"),s=t?` ${t}`:"",r=e.args.with,i="";r==null?i="":r?i=" WITH":i=" WITHOUT";let o=e.args.unique?" UNIQUE KEYS":"";return`JSON${s}${i}${o}`}jsonValueSql(e){let t=this.sql(e,"path"),s=this.sql(e,"returning");s=s?` RETURNING ${s}`:"";let r=this.sql(e,"onCondition");return r=r?` ${r}`:"",this.func("JSON_VALUE",[e.args.this,`${t}${s}${r}`])}skipJsonColumnSql(e){return`SKIP${e.args.regexp?" REGEXP":""} ${this.sql(e.args.expression)}`}conditionalInsertSql(e){let t=e.args.else?"ELSE ":"",s=this.sql(e,"expression"),r=s?`WHEN ${s} THEN `:t,i=this.sql(e,"this").substring(6).trim();return`${r}${i}`}multitableInsertsSql(e){let t=this.sql(e,"kind"),s=this.seg(this.expressions(e,{sep:" "}));return`INSERT ${t}${s}${this.seg(this.sql(e,"source"))}`}onConditionSql(e){let t=e.args.empty,s="";t instanceof d?s=`DEFAULT ${this.sql(t)} ON EMPTY`:s=this.sql(e,"empty");let r=e.args.error,i="";r instanceof d?i=`DEFAULT ${this.sql(r)} ON ERROR`:i=this.sql(e,"error"),i&&s&&(this._constructor.ON_CONDITION_EMPTY_BEFORE_ERROR?i=`${s} ${i}`:i=`${i} ${s}`,s="");let o=this.sql(e,"null");return`${s}${i}${o}`}jsonExtractSql(e){return this.functionFallbackSql(e)}jsonExtractScalarSql(e){return this.functionFallbackSql(e)}jsonbExtractSql(e){return this.functionFallbackSql(e)}jsonbExtractScalarSql(e){return this.functionFallbackSql(e)}jsonExtractQuoteSql(e){let t=e.args.scalar?" ON SCALAR STRING":"";return`${this.sql(e,"option")} QUOTES${t}`}jsonExistsSql(e){let t=this.sql(e,"this"),s=this.sql(e,"path"),r=this.expressions(e,{key:"passing"}),i=r?` PASSING ${r}`:"",o=this.sql(e,"onCondition");return o=o?` ${o}`:"",s=`${s}${i}${o}`,this.func("JSON_EXISTS",[t,s])}addArrayAggNullFilter(e,t,s){if(!(this.dialect._constructor.ARRAY_AGG_INCLUDES_NULLS&&t.args.nullsExcluded))return e;let r=t.parent;if(r instanceof Xr){let i=r.args.expression?.args.this;if(!i)return e;i.replace(i.and(s.is(le()).not()))}else if(s.find($)){let i=s instanceof et?this.expressions(s):this.sql(s);e=`${e} FILTER(WHERE ${i} IS NOT NULL)`}return e}arrayAggSql(e){let t=this.functionFallbackSql(e),s=e.args.this instanceof d?e.args.this:void 0;return s?this.addArrayAggNullFilter(t,e,s):t}sliceSql(e){let t=this.sql(e,"step"),s=this.sql(typeof e.args.expression=="number"?e.args.expression.toString():e.args.expression),r=this.sql(e.args.this),i=t?`${s}:${t}`:s;return i?`${r}:${i}`:`${r}:`}applySql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return`${t} APPLY(${s})`}grantOrRevokeSql(e,t={}){let{keyword:s,preposition:r,grantOptionPrefix:i="",grantOptionSuffix:o=""}=t,c=this.expressions(e,{key:"privileges",flat:!0}),p=this.sql(e,"kind"),u=p?` ${p}`:"",h=this.sql(e,"securable");h=h?` ${h}`:"";let g=this.expressions(e,{key:"principals",flat:!0}),f=i,x=o;e.args.grantOption||(f=x="");let T=this.sql(e,"cascade"),y=T?` ${T}`:"";return`${s} ${f}${c} ON${u}${h} ${r} ${g}${x}${y}`}grantSql(e){return this.grantOrRevokeSql(e,{keyword:"GRANT",preposition:"TO",grantOptionSuffix:" WITH GRANT OPTION"})}revokeSql(e){return this.grantOrRevokeSql(e,{keyword:"REVOKE",preposition:"FROM",grantOptionPrefix:"GRANT OPTION FOR "})}grantPrivilegeSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0}),r=s?`(${s})`:"";return`${t}${r}`}grantPrincipalSql(e){let t=this.sql(e,"this"),s=this.sql(e,"kind");return`${s?`${s} `:""}${t}`}columnsSql(e){let t=this.functionFallbackSql(e);return e.args.unpack?`*${t}`:t}overlaySql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=this.sql(e,"from"),i=this.sql(e,"for"),o=i?` FOR ${i}`:"";return`OVERLAY(${t} PLACING ${s} FROM ${r}${o})`}toDoubleSql(e){Cb.call(this,e,"format");let t=e.args.safe?$t:z;return this.sql(new t({this:e.args.this,to:new m({this:"double"})}))}stringSql(e){let t=e.args.this,s=e.args.zone;return s&&(t=new vn({sourceTz:new N({this:"UTC",isString:!0}),targetTz:s,timestamp:t})),this.sql(X(t,"VARCHAR",{dialect:this.dialect}))}medianSql(e){return this._constructor.SUPPORTS_MEDIAN?this.functionFallbackSql(e):this.sql(new gd({this:e.args.this,expression:N.number(.5)}))}overflowTruncateBehaviorSql(e){let t=this.sql(e,"this"),s=t?` ${t}`:"",r=e.args.withCount?"WITH COUNT":"WITHOUT COUNT";return`TRUNCATE${s} ${r}`}unixSecondsSql(e){if(this._constructor.SUPPORTS_UNIX_SECONDS)return this.functionFallbackSql(e);let t=X(N.string("1970-01-01 00:00:00+00"),"timestamptz");return this.sql(new Dh({this:e.args.this,expression:t,unit:new Ve({this:"SECONDS"})}))}arraySizeSql(e){let t=e.args.expression;return t&&this._constructor.ARRAY_SIZE_DIM_REQUIRED===void 0&&(t.isInteger&&t.name==="1"||this.unsupported("Cannot transpile dimension argument for ARRAY_LENGTH"),t=void 0),this._constructor.ARRAY_SIZE_DIM_REQUIRED&&!t&&(t=new N({this:"1",isString:!1})),this.func(this._constructor.ARRAY_SIZE_NAME,[e.args.this,t])}attachSql(e){let t=this.sql(e,"this"),s=e.args.exists?" IF NOT EXISTS":"",r=this.expressions(e);return r=r?` (${r})`:"",`ATTACH${s} ${t}${r}`}detachSql(e){let t=this.sql(e,"kind");t=t?` ${t}`:"";let s=e.args.exists?" IF EXISTS":"";s&&(t=t||" DATABASE");let r=this.sql(e,"this"),i=r?` ${r}`:"",o=this.sql(e,"cluster");o=o?` ${o}`:"";let c=e.args.permanent?" PERMANENTLY":"",p=e.args.sync?" SYNC":"";return`DETACH${t}${s}${i}${o}${c}${p}`}attachOptionSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return s=s?` ${s}`:"",`${t}${s}`}watermarkColumnConstraintSql(e){return`WATERMARK FOR ${this.sql(e,"this")} AS ${this.sql(e,"expression")}`}encodePropertySql(e){let s=`${e.args.key?"KEY ENCODE":"ENCODE"} ${this.sql(e,"this")}`,r=e.args.properties;return r&&(re(r,He),s=`${s} ${this.properties(r)}`),s}includePropertySql(e){let s=`INCLUDE ${this.sql(e,"this")}`,r=this.sql(e,"columnDef");r&&(s=`${s} ${r}`);let i=this.sql(e,"alias");return i&&(s=`${s} AS ${i}`),s}xmlElementSql(e){let s=`${e.args.evalname?"EVALNAME":"NAME"} ${this.sql(e,"this")}`;return this.func("XmlELEMENT",[s,...e.args.expressions||[]])}xmlKeyValueOptionSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=s?`(${s})`:"";return`${t}${r}`}partitionByRangePropertySql(e){let t=this.expressions(e,{key:"partitionExpressions"}),s=this.expressions(e,{key:"createExpressions"});return`PARTITION BY RANGE ${this.wrap(t)} ${this.wrap(s)}`}partitionByRangePropertyDynamicSql(e){let t=this.sql(e,"start"),s=this.sql(e,"end"),r=e.args.every;r instanceof qe&&r.args.this?.isString&&r.args.this.replace(N.number(r.name));let i=this.sql(r);return`START (${t}) END (${s}) EVERY (${i})`}unpivotColumnsSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});return`NAME ${t} VALUE ${s}`}analyzeSampleSql(e){let t=this.sql(e,"kind");return`SAMPLE ${this.sql(e,"sample")} ${t}`}analyzeStatisticsSql(e){let t=this.sql(e,"kind"),s=this.sql(e,"option");s=s?` ${s}`:"";let r=this.sql(e,"this");r=r?` ${r}`:"";let i=this.expressions(e);return i=i?` ${i}`:"",`${t}${s} STATISTICS${r}${i}`}analyzeHistogramSql(e){let t=this.sql(e,"this"),s=this.expressions(e),r=this.sql(e,"expression");r=r?` ${r}`:"";let i=this.sql(e,"updateOptions");return i=i?` ${i} UPDATE`:"",`${t} HISTOGRAM ON ${s}${r}${i}`}analyzeDeleteSql(e){let t=this.sql(e,"kind");return t=t?` ${t}`:"",`DELETE${t} STATISTICS`}analyzeListChainedRowsSql(e){return`LIST CHAINED ROWS${this.sql(e,"expression")}`}analyzeValidateSql(e){let t=this.sql(e,"kind"),s=this.sql(e,"this");s=s?` ${s}`:"";let r=this.sql(e,"expression");return`VALIDATE ${t}${s}${r}`}analyzeSql(e){let t=this.expressions(e,{key:"options",sep:" "});t=t?` ${t}`:"";let s=this.sql(e,"kind");s=s?` ${s}`:"";let r=this.sql(e,"this");r=r?` ${r}`:"";let i=this.sql(e,"mode");i=i?` ${i}`:"";let o=this.sql(e,"properties");o=o?` ${o}`:"";let c=this.sql(e,"partition");c=c?` ${c}`:"";let p=this.sql(e,"expression");return p=p?` ${p}`:"",`ANALYZE${t}${s}${r}${c}${i}${p}${o}`}xmlTableSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{key:"namespaces"}),r=s?`XMLNAMESPACES(${s}), `:"",i=this.expressions(e,{key:"passing"}),o=i?`${this.sep()}PASSING${this.seg(i)}`:"",c=this.expressions(e,{key:"columns"}),p=c?`${this.sep()}COLUMNS${this.seg(c)}`:"",u=e.args.byRef?`${this.sep()}RETURNING SEQUENCE BY REF`:"";return`XMLTABLE(${this.sep("")}${this.indent(r+t+o+u+p)}${this.seg(")","")}`}xmlNamespaceSql(e){let t=this.sql(e,"this");return e.args.this instanceof Re?t:`DEFAULT ${t}`}exportSql(e){let t=this.sql(e,"this"),s=this.sql(e,"connection"),r=s?`WITH CONNECTION ${s} `:"",i=this.sql(e,"options");return`EXPORT DATA ${r}${i} AS ${t}`}declareSql(e){return`DECLARE ${e.args.replace?"OR REPLACE ":""}${this.expressions(e,{flat:!0})}`}declareItemSql(e){let t=this.expressions(e,{key:"this"}),s=this.sql(e,"default"),r=this._constructor.DECLARE_DEFAULT_ASSIGNMENT,i=s?` ${r} ${s}`:"",o=this.sql(e,"kind");return e.args.kind instanceof Rt&&(o=`TABLE ${o}`),o=o?` ${o}`:"",`${t}${o}${i}`}recursiveWithSearchSql(e){let t=this.sql(e,"kind"),s=this.sql(e,"this"),r=this.sql(e,"expression"),i=this.sql(e,"using"),o=i?` USING ${i}`:"";return`${t==="CYCLE"?t:`SEARCH ${t} FIRST BY`} ${s} SET ${r}${o}`}parameterizedAggSql(e){let t=this.expressions(e,{key:"params",flat:!0}),s=e.name||"";return this.func(s,e.args.expressions||[])+`(${t})`}anonymousAggFuncSql(e){let t=e.name||"";return this.func(t,e.args.expressions||[])}combinedAggFuncSql(e){return this.anonymousAggFuncSql(e)}combinedParameterizedAggSql(e){return this.parameterizedAggSql(e)}showSql(e){return this.unsupported("Unsupported SHOW statement"),""}installSql(e){return this.unsupported("Unsupported INSTALL statement"),""}getPutSql(e){let t=e.args.properties;t&&re(t,He);let s=t?this.properties(t,{prefix:" ",sep:" ",wrapped:!1}):"",r=this.sql(e,"this"),i=this.sql(e,"target");return e instanceof jA?`PUT ${r} ${i}${s}`:`GET ${i} ${r}${s}`}translateCharactersSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=e.args.withError?" WITH ERROR":"";return`TRANSLATE(${t} USING ${s}${r})`}decodeCaseSql(e){if(this._constructor.SUPPORTS_DECODE_CASE)return this.func("DECODE",e.args.expressions??[]);let[t,...s]=e.args.expressions??[],r=[];for(let c=0;c<s.length-1;c+=2){let p=s[c],u=s[c+1];if(p instanceof N)r.push(new fe({this:t.eq(p),true:u}));else if(p instanceof Pt)r.push(new fe({this:t.is(le()),true:u}));else{let h=p;h instanceof U&&(h=zs(h));let g=Vt([t.eq(h),ve([t.is(le()),h.is(le())],{copy:!1})],{copy:!1});r.push(new fe({this:g,true:u}))}}let i=s.length%2===1?s[s.length-1]:void 0,o=new ut({ifs:r,default:i});return this.sql(o)}semanticViewSql(e){let t=this.sql(e,"this"),s=this.seg(t,""),r=this.expressions(e,{key:"dimensions",dynamic:!0,skipFirst:!0,skipLast:!0}),i=r?this.seg(`DIMENSIONS ${r}`):"",o=this.expressions(e,{key:"metrics",dynamic:!0,skipFirst:!0,skipLast:!0}),c=o?this.seg(`METRICS ${o}`):"",p=this.expressions(e,{key:"facts",dynamic:!0,skipFirst:!0,skipLast:!0}),u=p?this.seg(`FACTS ${p}`):"",h=this.sql(e,"where"),g=h?this.seg(`WHERE ${h}`):"";return`SEMANTIC_VIEW(${this.indent(s+c+i+u+g,{skipFirst:!0})}${this.seg(")","")}`}getExtractSql(e){let t=e.args.this,s=e.args.expression;return t?((!t.type||!e.type)&&(t=Kt(t,{dialect:this.dialect})),t.isType(["array","map"])?this.sql(new Lt({this:t,expressions:s?[s]:[]})):this.sql(new ms({this:t,expression:this.dialect.toJsonPath(s)}))):""}dateFromUnixDateSql(e){return this.sql(new xt({this:X(N.string("1970-01-01"),"date"),expression:e.args.this,unit:Z("DAY")}))}spaceSql(e){return this.func("REPEAT",[Hl(" "),e.args.this])}buildPropertySql(e){return`BUILD ${this.sql(e,"this")}`}refreshTriggerPropertySql(e){let t=this.sql(e,"method"),s=e.args.kind;if(!s)return`REFRESH ${t}`;let r=this.sql(e,"every"),i=this.sql(e,"unit"),o=r?` EVERY ${r} ${i}`:"",c=this.sql(e,"starts");return c=c?` STARTS ${c}`:"",`REFRESH ${t} ON ${s}${o}${c}`}modelAttributeSql(e){return this.unsupported("The model!attribute syntax is not supported"),""}directoryStageSql(e){return this.func("DIRECTORY",[e.args.this])}uuidSql(e){let t=this.func("UUID",[]);return e.args.isString&&!this.dialect._constructor.UUID_IS_STRING_TYPE?this.sql(X(Z(t),"varchar")):t}initcapSql(e){let t=e.args.expression;return t&&(this.dialect._constructor.INITCAP_SUPPORTS_CUSTOM_DELIMITERS?t.isString&&t.args.this===this.dialect._constructor.INITCAP_DEFAULT_DELIMITER_CHARS&&(t=void 0):t=void 0),this.func("INITCAP",[e.args.this,t])}localtimeSql(e){let t=e.args.this;return t?this.func("LOCALTIME",[t]):"LOCALTIME"}localtimestampSql(e){let t=e.args.this;return t?this.func("LOCALTIMESTAMP",[t]):"LOCALTIMESTAMP"}weekStartSql(e){let t=e.args.this,s=t?.name.toUpperCase();return this.dialect._constructor.WEEK_OFFSET===-1&&s==="SUNDAY"?"WEEK":this.func("WEEK",[t])}chrSql(e,t={}){let{name:s="CHR"}=t,r=this.expressions(e),i=this.sql(e,"charset"),o=i?` USING ${i}`:"";return this.func(s,[r+o])}blockSql(e){let t=this.expressions(e,{sep:"; ",flat:!0});return t?`${t}`:""}tableSampleSql(e,t={}){let{tablesampleKeyword:s}=t,r=this.sql(e,"method");r=r&&this._constructor.TABLESAMPLE_WITH_METHOD?`${r} `:"";let i=this.sql(e,"bucketNumerator"),o=this.sql(e,"bucketDenominator"),c=this.sql(e,"bucketField");c=c?` ON ${c}`:"";let p=i?`BUCKET ${i} OUT OF ${o}${c}`:"",u=this.sql(e,"seed");u=u?` ${this._constructor.TABLESAMPLE_SEED_KEYWORD} (${u})`:"";let h=this.sql(e,"size");h&&this._constructor.TABLESAMPLE_SIZE_IS_ROWS&&(h=`${h} ROWS`);let g=this.sql(e,"percent");g&&!this.dialect._constructor.TABLESAMPLE_SIZE_IS_PERCENT&&(g=`${g} PERCENT`);let f=`${p}${g}${h}`;return this._constructor.TABLESAMPLE_REQUIRES_PARENS&&(f=`(${f})`),` ${s||this._constructor.TABLESAMPLE_KEYWORDS} ${r}${f}${u}`}maskingPolicyColumnConstraintSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});return s=s?` USING (${s})`:"",`MASKING POLICY ${t}${s}`}uniqueKeyPropertySql(e,t={}){let{prefix:s="UNIQUE KEY"}=t;return`${s} (${this.expressions(e,{flat:!0})})`}formatTime(e,t,s){let r=this.dialect._constructor,i=t||r.INVERSE_TIME_MAPPING,o=s||r.INVERSE_TIME_TRIE;return Wl(this.sql(e,"format"),i,o)}ceilSql(e){return this.ceilFloor(e)}floorSql(e){return this.ceilFloor(e)}generateSeriesSql(e){if(e.args.isEndExclusive){let t=e.args.start,s=e.args.end,r=e.args.step,i=s instanceof d?new ye({this:s,expression:N.number(1)}):s;return this.func(e._constructor.sqlName(),[t,i,r])}return this.functionFallbackSql(e)}offsetLimitModifiers(e,t,s){let{fetch:r}=t;return[r?this.sql(e,"offset"):this.sql(s),r?this.sql(s):this.sql(e,"offset")]}storedProcedureSql(e){return this.unsupported("Unsupported Stored Procedure syntax"),""}ifBlockSql(e){return this.unsupported("Unsupported If block syntax"),""}whileBlockSql(e){return this.unsupported("Unsupported While block syntax"),""}executeSql(e){return this.unsupported("Unsupported Execute syntax"),""}executeSqlSql(e){return this.unsupported("Unsupported Execute syntax"),""}alterModifySqlSecuritySql(e){return`MODIFY ${this.expressions(e,{sep:" "})}`}};rs=vt(null),R(rs,10,"NULL_ORDERING_SUPPORTED",QH,L),R(rs,10,"SUPPORTED_JSON_PATH_PARTS",zH,L),R(rs,10,"UNWRAPPED_INTERVAL_VALUES",JH,L),R(rs,10,"WITH_SEPARATED_COMMENTS",XH,L),R(rs,10,"EXCLUDE_COMMENTS",jH,L),R(rs,10,"TYPE_MAPPING",WH,L),R(rs,10,"UNSUPPORTED_TYPES",_H,L),R(rs,10,"PARAMETERIZABLE_TEXT_TYPES",HH,L),R(rs,10,"TOKEN_MAPPING",VH,L),R(rs,10,"ORIGINAL_TRANSFORMS",YH,L),R(rs,10,"TRANSFORMS",GH,L),R(rs,10,"PROPERTIES_LOCATION",$H,L),Nt(rs,L),It(rs,3,L),n(L,"Generator"),L.WINDOW_FUNCS_WITH_NULL_ORDERING=[],L.IGNORE_NULLS_IN_FUNC=!1,L.IGNORE_NULLS_BEFORE_ORDER=!0,L.RESPECT_IGNORE_NULLS_UNSUPPORTED_EXPRESSIONS=[],L.LOCKING_READS_SUPPORTED=!1,L.EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE=!0,L.WRAP_DERIVED_VALUES=!0,L.CREATE_FUNCTION_RETURN_AS=!0,L.MATCHED_BY_SOURCE=!0,L.SINGLE_STRING_INTERVAL=!1,L.INTERVAL_ALLOWS_PLURAL_FORM=!0,L.LIMIT_FETCH="ALL",L.LIMIT_ONLY_LITERALS=!1,L.RENAME_TABLE_WITH_DB=!0,L.GROUPINGS_SEP=",",L.INDEX_ON="ON",L.INOUT_SEPARATOR=" ",L.JOIN_HINTS=!0,L.DIRECTED_JOINS=!1,L.TABLE_HINTS=!0,L.QUERY_HINTS=!0,L.QUERY_HINT_SEP=", ",L.IS_BOOL_ALLOWED=!0,L.DUPLICATE_KEY_UPDATE_WITH_SET=!0,L.LIMIT_IS_TOP=!1,L.RETURNING_END=!0,L.EXTRACT_ALLOWS_QUOTES=!0,L.TZ_TO_WITH_TIME_ZONE=!1,L.NVL2_SUPPORTED=!0,L.SELECT_KINDS=["STRUCT","VALUE"],L.VALUES_AS_TABLE=!0,L.ALTER_TABLE_INCLUDE_COLUMN_KEYWORD=!0,L.UNNEST_WITH_ORDINALITY=!0,L.AGGREGATE_FILTER_SUPPORTED=!0,L.SEMI_ANTI_JOIN_WITH_SIDE=!0,L.COMPUTED_COLUMN_WITH_TYPE=!0,L.SUPPORTS_TABLE_COPY=!0,L.TABLESAMPLE_REQUIRES_PARENS=!0,L.TABLESAMPLE_SIZE_IS_ROWS=!0,L.TABLESAMPLE_SIZE_IS_PERCENT=!1,L.TABLESAMPLE_KEYWORDS="TABLESAMPLE",L.TABLESAMPLE_WITH_METHOD=!0,L.TABLESAMPLE_SEED_KEYWORD="SEED",L.COLLATE_IS_FUNC=!1,L.DATA_TYPE_SPECIFIERS_ALLOWED=!1,L.ENSURE_BOOLS=!1,L.CTE_RECURSIVE_KEYWORD_REQUIRED=!0,L.SUPPORTS_SINGLE_ARG_CONCAT=!0,L.LAST_DAY_SUPPORTS_DATE_PART=!0,L.SUPPORTS_TABLE_ALIAS_COLUMNS=!0,L.UNPIVOT_ALIASES_ARE_IDENTIFIERS=!0,L.JSON_KEY_VALUE_PAIR_SEP=":",L.INSERT_OVERWRITE=" OVERWRITE TABLE",L.SUPPORTS_SELECT_INTO=!1,L.SUPPORTS_UNLOGGED_TABLES=!1,L.SUPPORTS_CREATE_TABLE_LIKE=!0,L.SUPPORTS_MODIFY_COLUMN=!1,L.LIKE_PROPERTY_INSIDE_SCHEMA=!1,L.MULTI_ARG_DISTINCT=!0,L.JSON_TYPE_REQUIRED_FOR_EXTRACTION=!1,L.JSON_PATH_BRACKETED_KEY_SUPPORTED=!0,L.JSON_PATH_SINGLE_QUOTE_ESCAPE=!1,L.CAN_IMPLEMENT_ARRAY_ANY=!1,L.SUPPORTS_TO_NUMBER=!0,L.SUPPORTS_WINDOW_EXCLUDE=!1,L.SET_OP_MODIFIERS=!0,L.COPY_PARAMS_ARE_WRAPPED=!0,L.COPY_PARAMS_EQ_REQUIRED=!1,L.COPY_HAS_INTO_KEYWORD=!0,L.TRY_SUPPORTED=!0,L.SUPPORTS_UESCAPE=!0,L.UNICODE_SUBSTITUTE=void 0,L.STAR_EXCEPT="EXCEPT",L.HEX_FUNC="HEX",L.WITH_PROPERTIES_PREFIX="WITH",L.QUOTE_JSON_PATH=!0,L.PAD_FILL_PATTERN_IS_REQUIRED=!1,L.SUPPORTS_EXPLODING_PROJECTIONS=!0,L.ARRAY_CONCAT_IS_VAR_LEN=!0,L.SUPPORTS_CONVERT_TIMEZONE=!1,L.SUPPORTS_MEDIAN=!0,L.SUPPORTS_UNIX_SECONDS=!1,L.ALTER_SET_WRAPPED=!1,L.NORMALIZE_EXTRACT_DATE_PARTS=!1,L.PARSE_JSON_NAME="PARSE_JSON",L.ARRAY_SIZE_NAME="ARRAY_LENGTH",L.ALTER_SET_TYPE="SET DATA TYPE",L.ARRAY_SIZE_DIM_REQUIRED=void 0,L.SUPPORTS_DECODE_CASE=!0,L.ON_CONDITION_EMPTY_BEFORE_ERROR=!0,L.SUPPORTS_BETWEEN_FLAGS=!1,L.SUPPORTS_LIKE_QUANTIFIERS=!0,L.MATCH_AGAINST_TABLE_PREFIX=void 0,L.SET_ASSIGNMENT_REQUIRES_VARIABLE_KEYWORD=!1,L.UPDATE_STATEMENT_SUPPORTS_FROM=!0,L.STAR_EXCLUDE_REQUIRES_DERIVED_TABLE=!0,L.SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY=!0,L.AFTER_HAVING_MODIFIER_TRANSFORMS=new Map([["cluster",function(e){return this.sql(e,"cluster")}],["distribute",function(e){return this.sql(e,"distribute")}],["sort",function(e){return this.sql(e,"sort")}],["windows",function(e){return e.getArgKey("windows")?this.seg("WINDOW ")+this.expressions(e,{key:"windows",flat:!0}):""}],["qualify",function(e){return this.sql(e,"qualify")}]]),L.SAFE_JSON_PATH_KEY_RE=/^[_a-zA-Z]\w*$/,L.SENTINEL_LINE_BREAK="__SQLGLOT__LB__",L.TIME_PART_SINGULARS={MICROSECONDS:"MICROSECOND",SECONDS:"SECOND",MINUTES:"MINUTE",HOURS:"HOUR",DAYS:"DAY",WEEKS:"WEEK",MONTHS:"MONTH",QUARTERS:"QUARTER",YEARS:"YEAR"},L.STRUCT_DELIMITER=["<",">"],L.PARAMETER_TOKEN="@",L.NAMED_PLACEHOLDER_TOKEN=":",L.RESERVED_KEYWORDS=new Set,L.EXPRESSIONS_WITHOUT_NESTED_CTES=new Set,L.EXPRESSION_PRECEDES_PROPERTIES_CREATABLES=new Set,L.DECLARE_DEFAULT_ASSIGNMENT="=";var cd=L;function dz(a,e){return new cd(e).generate(a)}n(dz,"generate");var e_,t_,qM;t_=[O],e_=[O];var Ha=class Ha{static get TIMESTAMP_EXPRESSIONS(){return new Set([ri,Is,Yh,Fh,UP,NL])}static get EXPRESSION_METADATA(){let e=new Map,t=n((s,r)=>{for(let i of s)e.set(i,r)},"extend");return t([ML,Rr,vL,Uh,yL,CL,bL],{returns:"BIGINT"}),t([_P,WP],{returns:"BINARY"}),t([cs,Tt,lP,Ts,at,SP,EL,Ys,lt,KP,ZP,BL,FL,Ga,Vl],{returns:"BOOLEAN"}),t([pr,pi,BP,$P,VP,_a,oi,xL,os],{returns:"DATE"}),t([OP,IP,Ds,Qs],{returns:"DATETIME"}),t([Xb,Jb,Wb,jb,wh,zb,Qb,DL,Ah,Kb,nP,Zb,iP,HP,XL,yh,ur,nL,Gh,Ad,oL,cL,vr,pL,eP,tP,Ch,VL,HL,_L,sP,rP,pP,WL,jL,JL],{returns:"DOUBLE"}),t([cP,eL,ti,yP,PP,CP,LP,zP,QP,Dh,FP,RL,YP,tL,$h,hL,Bs,SL,aL,OL],{returns:"INT"}),t([qe,fP,xP,TP,qP],{returns:"INTERVAL"}),e.set(ai,{returns:"Json"}),t([si,dh,dL,Bh,vP],{returns:"TIME"}),e.set(PL,{returns:"TIMESTAMPLTZ"}),t([mP,LL],{returns:"TIMESTAMPTZ"}),Ha.TIMESTAMP_EXPRESSIONS.forEach(s=>e.set(s,{returns:"TIMESTAMP"})),t([Nr,bP,rL,Ed,MP,wL,kP,DP],{returns:"TINYINT"}),t([AP,Bt,_t,gh,Mh,NP,RP,fh,wP,GP,Wt,sr,Th,Ar,sL,iL,lL,uL,Ns,dP,Or,fL,Ya,jP,XP,oP,TL,mL,IL,dr,Mn,kh,AL],{returns:"VARCHAR"}),t([aP,qL,kL,gP,EP,Xr,gr,UL,kt,Ie,gL,Ue],{annotator:n((s,r)=>s.annotateByArgs(r,["this"]),"annotator")}),t([hh,tt,ni,Ih,$L,GL],{annotator:n((s,r)=>s.annotateByArgs(r,["this","expressions"]),"annotator")}),t([uP,hP],{annotator:n((s,r)=>s.annotateByArrayElement(r),"annotator")}),t([xt,jt,ls],{annotator:n((s,r)=>s.annotateTimeunit(r),"annotator")}),t([z,$t],{annotator:n((s,r)=>s.setType(r,r.args.to),"annotator")}),t([mn,Ss],{annotator:n((s,r)=>s.annotateMap(r),"annotator")}),e.set(Qe,{annotator:n((s,r)=>s.setType(r,s.schema.getUdfType(r)),"annotator")}),e.set(ue,{annotator:n((s,r)=>s.annotateByArgs(r,["expressions"],{array:!0}),"annotator")}),e.set(Bn,{annotator:n((s,r)=>s.annotateByArgs(r,["this"],{array:!0}),"annotator")}),e.set(Lt,{annotator:n((s,r)=>s.annotateBracket(r),"annotator")}),e.set(ut,{annotator:n((s,r)=>s.annotateByArgs(r,[...Et(r.args.ifs??[],fe).flatMap(i=>i.args.true??[]),"default"]),"annotator")}),e.set(bh,{annotator:n((s,r)=>s.setType(r,r.args.bigInt?"bigint":"int"),"annotator")}),e.set(_s,{annotator:n((s,r)=>s.setType(r,r.args.bigInt?"bigint":"int"),"annotator")}),e.set(m,{annotator:n((s,r)=>s.setType(r,r.copy()),"annotator")}),e.set(wt,{annotator:n((s,r)=>s.annotateDiv(r),"annotator")}),e.set(et,{annotator:n((s,r)=>s.annotateByArgs(r,["expressions"]),"annotator")}),e.set(ge,{annotator:n((s,r)=>s.annotateDot(r),"annotator")}),e.set(Xt,{annotator:n((s,r)=>s.annotateExplode(r),"annotator")}),e.set(lr,{annotator:n((s,r)=>s.annotateExtract(r),"annotator")}),e.set(fu,{annotator:n((s,r)=>s.setType(r,r.args.isInteger?"bigint":"binary"),"annotator")}),e.set(As,{annotator:n((s,r)=>s.annotateByArgs(r,["start","end","step"],{array:!0}),"annotator")}),e.set(ii,{annotator:n((s,r)=>s.setType(r,m.build("ARRAY<DATE>")),"annotator")}),e.set(JP,{annotator:n((s,r)=>s.setType(r,m.build("ARRAY<TIMESTAMP>")),"annotator")}),e.set(fe,{annotator:n((s,r)=>s.annotateByArgs(r,["true","false"]),"annotator")}),e.set(N,{annotator:n((s,r)=>s.annotateLiteral(r),"annotator")}),e.set(Pt,{returns:"NULL"}),e.set(qh,{annotator:n((s,r)=>s.annotateByArgs(r,["this","expression"]),"annotator")}),e.set(ot,{annotator:n((s,r)=>s.annotateByArgs(r,["expression"]),"annotator")}),e.set(Es,{annotator:n((s,r)=>s.annotateStruct(r),"annotator")}),e.set(YL,{annotator:n((s,r)=>s.annotateByArgs(r,["this","expressions"],{promote:!0}),"annotator")}),e.set(Lh,{annotator:n((s,r)=>s.setType(r,r.args.withTz?"timestamptz":"timestamp"),"annotator")}),e.set(vh,{annotator:n((s,r)=>s.annotateToMap(r),"annotator")}),e.set(Ee,{annotator:n((s,r)=>s.annotateUnnest(r),"annotator")}),e.set(he,{annotator:n((s,r)=>s.annotateSubquery(r),"annotator")}),e.set(Le,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e.set(bt,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e.set(lh,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e.set(Se,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e.set(Re,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e}};qM=vt(null),R(qM,10,"TIMESTAMP_EXPRESSIONS",t_,Ha),R(qM,10,"EXPRESSION_METADATA",e_,Ha),Nt(qM,Ha),It(qM,3,Ha),n(Ha,"DialectTyping");var UM=Ha;var Tj={"\\a":"\x07","\\b":"\b","\\f":"\f","\\n":`
|
|
17
|
-
`,"\\r":"\r","\\t":" ","\\v":"\v","\\\\":"\\"};var kM=(ce=>(ce.DIALECT="",ce.ATHENA="athena",ce.BIGQUERY="bigquery",ce.CLICKHOUSE="clickhouse",ce.DATABRICKS="databricks",ce.DORIS="doris",ce.DREMIO="dremio",ce.DRILL="drill",ce.DRUID="druid",ce.DUCKDB="duckdb",ce.DUNE="dune",ce.FABRIC="fabric",ce.HIVE="hive",ce.MATERIALIZE="materialize",ce.MYSQL="mysql",ce.ORACLE="oracle",ce.POSTGRES="postgres",ce.PRESTO="presto",ce.PRQL="prql",ce.REDSHIFT="redshift",ce.RISINGWAVE="risingwave",ce.SINGLESTORE="singlestore",ce.SNOWFLAKE="snowflake",ce.SOLR="solr",ce.SPARK="spark",ce.SPARK2="spark2",ce.SQLITE="sqlite",ce.STARROCKS="starrocks",ce.TABLEAU="tableau",ce.TERADATA="teradata",ce.TRINO="trino",ce.TSQL="tsql",ce.EXASOL="exasol",ce))(kM||{}),b_=(i=>(i.LOWERCASE="lowercase",i.UPPERCASE="uppercase",i.CASE_SENSITIVE="caseSensitive",i.CASE_INSENSITIVE="caseInsensitive",i.CASE_INSENSITIVE_UPPERCASE="caseInsensitiveUppercase",i))(b_||{}),s_,r_,i_,n_,a_,o_,c_,p_,l_,u_,h_,g_,E_,A_,d_,f_,x_,T_,S_,R_,O_,m_,N_,I_,y_,C_,De;C_=[O],y_=[O],I_=[O],N_=[O],m_=[O],O_=[O],R_=[O],S_=[O],T_=[O],x_=[O],f_=[O],d_=[O],A_=[O],E_=[O],g_=[O],h_=[O],u_=[O],l_=[O],p_=[O],c_=[O],o_=[O],a_=[O],n_=[O],i_=[O],r_=[O],s_=[O];var M=class M{constructor(e={}){this.version=void 0;this.normalizationStrategy=void 0;this.settings=void 0;let{version:t=Number.MAX_SAFE_INTEGER,normalizationStrategy:s}=e,r=t.toString().split(".");for(;r.length<3;)r.push("0");this.version={major:parseInt(r[0]),minor:parseInt(r[1]),patch:parseInt(r[2])},this.normalizationStrategy=st(b_,s)??this._constructor.NORMALIZATION_STRATEGY,this.settings=e;for(let i of Object.keys(e))this._constructor.SUPPORTED_SETTINGS.has(i)||fD("setting",i,[...this._constructor.SUPPORTED_SETTINGS])}static get SUPPORTS_COLUMN_JOIN_MARKS(){return!!this.tokenizerClass.KEYWORDS["(+)"]}static get NULL_ORDERING(){return"nulls_are_small"}static get TIME_MAPPING(){return{}}static get FORMAT_MAPPING(){return{}}static get UNESCAPED_SEQUENCES(){let e={};return this.STRINGS_SUPPORT_ESCAPED_SEQUENCES||this.BYTE_STRINGS_SUPPORT_ESCAPED_SEQUENCES?e={...Tj,...this.ORIGINAL_UNESCAPED_SEQUENCES}:e=this.ORIGINAL_UNESCAPED_SEQUENCES,e}static get PSEUDOCOLUMNS(){return new Set}static get SET_OP_DISTINCT_BY_DEFAULT(){return{except:!0,intersect:!0,union:!0}}static get CREATABLE_KIND_MAPPING(){return{}}static get INITCAP_SUPPORTS_CUSTOM_DELIMITERS(){return["","bigquery","snowflake"].includes(this.DIALECT_NAME)}static get DEFAULT_FUNCTIONS_COLUMN_NAMES(){return new Map}static get DEFAULT_NULL_TYPE(){return"unknown"}static get UNMERGABLE_ARGS(){return new Set(Array.from(se.availableArgs).filter(e=>!["expressions","from","joins","where","order","hint"].includes(e)))}static get TRY_SUPPORTED(){return["","athena","presto","trino","duckdb"].includes(this.DIALECT_NAME)}static get SUPPORTS_UESCAPE(){return["","athena","presto","trino","duckdb"].includes(this.DIALECT_NAME)}static get tokenizerClass(){let e=this._tokenizerClassCache.get(this);if(e)return e;if(Object.prototype.hasOwnProperty.call(this,"Tokenizer"))return this.Tokenizer;let s=Object.getPrototypeOf(this)?.tokenizerClass;if(!s)return this._tokenizerClassCache.set(this,Fr),Fr;let i=class i extends s{};n(i,"DerivedTokenizer");let r=i;return this._tokenizerClassCache.set(this,r),r}static get jsonpathTokenizerClass(){let e=this._jsonpathTokenizerClassCache.get(this);if(e)return e;if(Object.prototype.hasOwnProperty.call(this,"JsonPathTokenizer"))return this.JsonPathTokenizer;let s=Object.getPrototypeOf(this)?.JsonPathTokenizer;if(!s)return this._jsonpathTokenizerClassCache.set(this,YA),YA;let i=class i extends s{};n(i,"DerivedJsonPathTokenizer");let r=i;return this._jsonpathTokenizerClassCache.set(this,r),r}static get parserClass(){let e=this._parserClassCache.get(this);if(e)return e;if(Object.prototype.hasOwnProperty.call(this,"Parser"))return this.Parser;let s=Object.getPrototypeOf(this)?.parserClass;if(!s)return this._parserClassCache.set(this,ry),ry;let i=class i extends s{};n(i,"DerivedParser");let r=i;return this._parserClassCache.set(this,r),r}static get generatorClass(){let e=this._generatorClassCache.get(this);if(e)return e;if(Object.prototype.hasOwnProperty.call(this,"Generator"))return this.Generator;let s=Object.getPrototypeOf(this)?.generatorClass;if(!s)return this._generatorClassCache.set(this,cd),cd;let i=class i extends s{};n(i,"DerivedGenerator");let r=i;return this._generatorClassCache.set(this,r),r}static get TIME_TRIE(){return Gt(Object.keys(this.TIME_MAPPING).map(e=>Array.from(e)))}static get FORMAT_TRIE(){let e=0<Object.keys(this.FORMAT_MAPPING).length?this.FORMAT_MAPPING:this.TIME_MAPPING;return Gt(Object.keys(e).map(t=>Array.from(t)))}static get INVERSE_TIME_MAPPING(){return Object.fromEntries(Object.entries(this.TIME_MAPPING).map(([e,t])=>[t,e]))}static get INVERSE_TIME_TRIE(){return Gt(Object.keys(this.INVERSE_TIME_MAPPING).map(e=>Array.from(e)))}static get INVERSE_FORMAT_MAPPING(){return Object.fromEntries(Object.entries(this.FORMAT_MAPPING).map(([e,t])=>[t,e]))}static get INVERSE_FORMAT_TRIE(){return Gt(Object.keys(this.INVERSE_FORMAT_MAPPING).map(e=>Array.from(e)))}static get INVERSE_CREATABLE_KIND_MAPPING(){return Object.fromEntries(Object.entries(this.CREATABLE_KIND_MAPPING).map(([e,t])=>[t,e]))}static get ESCAPED_SEQUENCES(){return Object.fromEntries(Object.entries(this.UNESCAPED_SEQUENCES).map(([e,t])=>[t,e]))}static get QUOTE_START(){return Object.entries(this.tokenizerClass._QUOTES)[0]?.[0]}static get QUOTE_END(){return Object.entries(this.tokenizerClass._QUOTES)[0]?.[1]}static get IDENTIFIER_START(){return Object.entries(this.tokenizerClass._IDENTIFIERS)[0]?.[0]}static get IDENTIFIER_END(){return Object.entries(this.tokenizerClass._IDENTIFIERS)[0]?.[1]}static getStartEnd(e){let t=Object.entries(this.tokenizerClass._FORMAT_STRINGS).find(([s,[r,i]])=>i===e);if(t){let[s,[r]]=t;return[s,r]}return[void 0,void 0]}static get BIT_START(){return this.getStartEnd("bitString")[0]}static get BIT_END(){return this.getStartEnd("bitString")[1]}static get HEX_START(){return this.getStartEnd("hexString")[0]}static get HEX_END(){return this.getStartEnd("hexString")[1]}static get BYTE_START(){return this.getStartEnd("byteString")[0]}static get BYTE_END(){return this.getStartEnd("byteString")[1]}static get UNICODE_START(){return this.getStartEnd("unicodeString")[0]}static get UNICODE_END(){return this.getStartEnd("unicodeString")[1]}static get DATE_PART_MAPPING(){return{Y:"YEAR",YY:"YEAR",YYY:"YEAR",YYYY:"YEAR",YR:"YEAR",YEARS:"YEAR",YRS:"YEAR",MM:"MONTH",MON:"MONTH",MONS:"MONTH",MONTHS:"MONTH",D:"DAY",DD:"DAY",DAYS:"DAY",DAYOFMONTH:"DAY","DAY OF WEEK":"DAYOFWEEK",WEEKDAY:"DAYOFWEEK",DOW:"DAYOFWEEK",DW:"DAYOFWEEK",WEEKDAY_ISO:"DAYOFWEEKISO",DOW_ISO:"DAYOFWEEKISO",DW_ISO:"DAYOFWEEKISO",DAYOFWEEK_ISO:"DAYOFWEEKISO","DAY OF YEAR":"DAYOFYEAR",DOY:"DAYOFYEAR",DY:"DAYOFYEAR",W:"WEEK",WK:"WEEK",WEEKOFYEAR:"WEEK",WOY:"WEEK",WY:"WEEK",WEEK_ISO:"WEEKISO",WEEKOFYEARISO:"WEEKISO",WEEKOFYEAR_ISO:"WEEKISO",Q:"QUARTER",QTR:"QUARTER",QTRS:"QUARTER",QUARTERS:"QUARTER",H:"HOUR",HH:"HOUR",HR:"HOUR",HOURS:"HOUR",HRS:"HOUR",M:"MINUTE",MI:"MINUTE",MIN:"MINUTE",MINUTES:"MINUTE",MINS:"MINUTE",S:"SECOND",SEC:"SECOND",SECONDS:"SECOND",SECS:"SECOND",MS:"MILLISECOND",MSEC:"MILLISECOND",MSECS:"MILLISECOND",MSECOND:"MILLISECOND",MSECONDS:"MILLISECOND",MILLISEC:"MILLISECOND",MILLISECS:"MILLISECOND",MILLISECON:"MILLISECOND",MILLISECONDS:"MILLISECOND",US:"MICROSECOND",USEC:"MICROSECOND",USECS:"MICROSECOND",MICROSEC:"MICROSECOND",MICROSECS:"MICROSECOND",USECOND:"MICROSECOND",USECONDS:"MICROSECOND",MICROSECONDS:"MICROSECOND",NS:"NANOSECOND",NSEC:"NANOSECOND",NANOSEC:"NANOSECOND",NSECOND:"NANOSECOND",NSECONDS:"NANOSECOND",NANOSECS:"NANOSECOND",EPOCH_SECOND:"EPOCH",EPOCH_SECONDS:"EPOCH",EPOCH_MILLISECONDS:"EPOCH_MILLISECOND",EPOCH_MICROSECONDS:"EPOCH_MICROSECOND",EPOCH_NANOSECONDS:"EPOCH_NANOSECOND",TZH:"TIMEZONE_HOUR",TZM:"TIMEZONE_MINUTE",DEC:"DECADE",DECS:"DECADE",DECADES:"DECADE",MIL:"MILLENNIUM",MILS:"MILLENNIUM",MILLENIA:"MILLENNIUM",C:"CENTURY",CENT:"CENTURY",CENTS:"CENTURY",CENTURIES:"CENTURY"}}static get COERCES_TO(){return new Map}static get EXPRESSION_METADATA(){return UM.EXPRESSION_METADATA}static get SUPPORTED_SETTINGS(){return new Set(["normalizationStrategy","version"])}static get QUOTE_DELIMITERS(){return Object.entries(this.tokenizerClass.QUOTES)[0]}static get IDENTIFIER_DELIMITERS(){return Object.entries(this.tokenizerClass.IDENTIFIERS)[0]}static get BASE_VALID_INTERVAL_UNITS(){return new Set}static get VALID_INTERVAL_UNITS(){let e=this.DATE_PART_MAPPING;return new Set([...this.BASE_VALID_INTERVAL_UNITS,...Object.keys(e),...Object.values(e)])}static get STRINGS_SUPPORT_ESCAPED_SEQUENCES(){return this.tokenizerClass.STRING_ESCAPES.includes("\\")}static get BYTE_STRINGS_SUPPORT_ESCAPED_SEQUENCES(){return this.tokenizerClass.BYTE_STRING_ESCAPES.includes("\\")}static equals(e){return this===e?!0:typeof e=="string"?this===this.get(e):e instanceof M?this===e.constructor:!1}static register(...e){for(let t of e){this.registry.set(t.DIALECT_NAME,t);for(let s of t.DIALECT_ALIASES??[])this.registry.set(s,t)}}static get(e,t){return this.registry.get(e)||t}static getOrRaise(e){if(!e)return new this;if(typeof e=="function"&&(e===M||e.prototype instanceof M))return new e;if(e instanceof M)return e;if(typeof e=="string"){let t,s={};try{let[i,...o]=e.split(",");t=i.trim();for(let c of o){let p=c.split("="),u=p[0].trim(),h=!0;p.length===2&&(h=p[1].trim()),s[yM(u)]=$Y(h)??h}}catch{throw new Error(`Invalid dialect format: '${e}'. Please use the correct format: 'dialect [, k1 = v2 [, ...]]'.`)}let r=this.get(t);if(!r){let i=new Set(Object.keys(kM));fD("dialect",t,Array.from(i))}return new r(s)}throw new Error(`Invalid dialect type for '${e}': '${typeof e}'.`)}static formatTime(e){return typeof e=="string"?N.string(Wl(e.slice(1,-1),this.TIME_MAPPING,this.TIME_TRIE)??""):e instanceof d&&e.isString?N.string(Wl(e.args.this,this.TIME_MAPPING,this.TIME_TRIE)??""):e}equals(e){return this===e?!0:e instanceof M?this.constructor===e.constructor:!1}hash(){return this.constructor.name.toLowerCase()}normalizeIdentifier(e){if(e instanceof v&&this.normalizationStrategy!=="caseSensitive"&&(!e.args.quoted||this.normalizationStrategy==="caseInsensitive"||this.normalizationStrategy==="caseInsensitiveUppercase")){let t=this.normalizationStrategy==="uppercase"||this.normalizationStrategy==="caseInsensitiveUppercase",s=e.args.this;if(typeof s=="string"){let r=t?s.toUpperCase():s.toLowerCase();e.setArgKey("this",r)}}return e}caseSensitive(e){if(this.normalizationStrategy==="caseInsensitive")return!1;let t=this.normalizationStrategy==="uppercase"?s=>s===s.toLowerCase()&&s!==s.toUpperCase():s=>s===s.toUpperCase()&&s!==s.toLowerCase();return Array.from(e).some(t)}canQuote(e,t={}){let{identify:s="safe"}=t;if(e.args.quoted)return!0;if(!s)return!1;if(s===!0)return!0;let r=e.name??"",i=!this.caseSensitive(r)&&tw.test(r);if(s==="safe")return i;if(s==="unsafe")return!i;throw new Error(`Unexpected argument for identify: '${s}'`)}quoteIdentifier(e,t={}){let{identify:s=!0}=t;return e instanceof v&&e.setArgKey("quoted",this.canQuote(e,{identify:s||"unsafe"})),e}toJsonPath(e){if(e instanceof N){let t=e.name;e.isNumber&&(t=`[${t}]`);try{return PD(t,{dialect:this})}catch(s){let r=this._constructor.STRICT_JSON_PATH_SYNTAX,i=t.trimStart(),o=i.startsWith("lax")||i.startsWith("strict");r&&!o&&console.warn(`Invalid JSON path syntax. ${s instanceof Error?s.message:String(s)}`)}}return e}parse(e,t){return this.parser(t).parse(this.tokenize(e),e)}parser(e){return new this._constructor.parserClass({dialect:this,...e})}parseIntoTypes(e,t,s){return this.parser(s).parseIntoTypes(e,this.tokenize(t),t)}generate(e,t={}){let{copy:s=!0,...r}=t;return this.generator(r).generate(e,{copy:s})}generator(e={}){return new this._constructor.generatorClass({dialect:this,...e})}tokenize(e,t={}){return this.tokenizer(t).tokenize(e)}tokenizer(e={}){return new this._constructor.tokenizerClass({dialect:this,...e})}jsonpathTokenizer(e={}){return new this._constructor.jsonpathTokenizerClass({dialect:this,...e})}transpile(e,t={}){return this.parse(e,t).map(s=>s?this.generate(s,{copy:!1,...t}):"")}generateValuesAliases(e){let t=e.args.expressions?.[0];return t instanceof d?(t.args.expressions??[]).map((r,i)=>K(`_col_${i}`)):[]}get _constructor(){return this.constructor}isKind(e){let t=st(kM,e);return t!==void 0?this._constructor.DIALECT_NAME===t:this._constructor.DIALECT_NAME.toLowerCase()===e.toLowerCase()}};De=vt(null),R(De,10,"NULL_ORDERING",C_,M),R(De,10,"TIME_MAPPING",y_,M),R(De,10,"FORMAT_MAPPING",I_,M),R(De,10,"UNESCAPED_SEQUENCES",N_,M),R(De,10,"PSEUDOCOLUMNS",m_,M),R(De,10,"SET_OP_DISTINCT_BY_DEFAULT",O_,M),R(De,10,"CREATABLE_KIND_MAPPING",R_,M),R(De,10,"DEFAULT_FUNCTIONS_COLUMN_NAMES",S_,M),R(De,10,"DEFAULT_NULL_TYPE",T_,M),R(De,10,"UNMERGABLE_ARGS",x_,M),R(De,10,"TIME_TRIE",f_,M),R(De,10,"FORMAT_TRIE",d_,M),R(De,10,"INVERSE_TIME_MAPPING",A_,M),R(De,10,"INVERSE_TIME_TRIE",E_,M),R(De,10,"INVERSE_FORMAT_MAPPING",g_,M),R(De,10,"INVERSE_FORMAT_TRIE",h_,M),R(De,10,"INVERSE_CREATABLE_KIND_MAPPING",u_,M),R(De,10,"ESCAPED_SEQUENCES",l_,M),R(De,10,"DATE_PART_MAPPING",p_,M),R(De,10,"COERCES_TO",c_,M),R(De,10,"EXPRESSION_METADATA",o_,M),R(De,10,"SUPPORTED_SETTINGS",a_,M),R(De,10,"QUOTE_DELIMITERS",n_,M),R(De,10,"IDENTIFIER_DELIMITERS",i_,M),R(De,10,"BASE_VALID_INTERVAL_UNITS",r_,M),R(De,10,"VALID_INTERVAL_UNITS",s_,M),Nt(De,M),It(De,3,M),n(M,"Dialect"),M.DIALECT_NAME="",M.DIALECT_ALIASES=void 0,M.INDEX_OFFSET=0,M.WEEK_OFFSET=0,M.UNNEST_COLUMN_ONLY=!1,M.ALIAS_POST_TABLESAMPLE=!1,M.ALIAS_POST_VERSION=!0,M.TABLESAMPLE_SIZE_IS_PERCENT=!1,M.NORMALIZATION_STRATEGY="lowercase",M.IDENTIFIERS_CAN_START_WITH_DIGIT=!1,M.DPIPE_IS_STRING_CONCAT=!0,M.STRICT_STRING_CONCAT=!1,M.SUPPORTS_USER_DEFINED_TYPES=!0,M.SUPPORTS_SEMI_ANTI_JOIN=!0,M.COPY_PARAMS_ARE_CSV=!0,M.NORMALIZE_FUNCTIONS="upper",M.PRESERVE_ORIGINAL_NAMES=!1,M.LOG_BASE_FIRST=!0,M.TYPED_DIVISION=!1,M.SAFE_DIVISION=!1,M.CONCAT_COALESCE=!1,M.HEX_LOWERCASE=!1,M.DATE_FORMAT="'%Y-%m-%d'",M.DATEINT_FORMAT="'%Y%m%d'",M.TIME_FORMAT="'%Y-%m-%d %H:%M:%S'",M.ORIGINAL_UNESCAPED_SEQUENCES={},M.PREFER_CTE_ALIAS_COLUMN=!1,M.FORCE_EARLY_ALIAS_REF_EXPANSION=!1,M.EXPAND_ONLY_GROUP_ALIAS_REF=!1,M.ANNOTATE_ALL_SCOPES=!1,M.DISABLES_ALIAS_REF_EXPANSION=!1,M.SUPPORTS_ALIAS_REFS_IN_JOIN_CONDITIONS=!1,M.SUPPORTS_ORDER_BY_ALL=!1,M.PROJECTION_ALIASES_SHADOW_SOURCE_NAMES=!1,M.TABLES_REFERENCEABLE_AS_COLUMNS=!1,M.SUPPORTS_STRUCT_STAR_EXPANSION=!1,M.EXCLUDES_PSEUDOCOLUMNS_FROM_STAR=!1,M.QUERY_RESULTS_ARE_STRUCTS=!1,M.REQUIRES_PARENTHESIZED_STRUCT_ACCESS=!1,M.SUPPORTS_NULL_TYPE=!1,M.COALESCE_COMPARISON_NON_STANDARD=!1,M.HAS_DISTINCT_ARRAY_CONSTRUCTORS=!1,M.SUPPORTS_FIXED_SIZE_ARRAYS=!1,M.STRICT_JSON_PATH_SYNTAX=!0,M.ON_CONDITION_EMPTY_BEFORE_ERROR=!0,M.ARRAY_AGG_INCLUDES_NULLS=!0,M.ARRAY_FUNCS_PROPAGATES_NULLS=!1,M.PROMOTE_TO_INFERRED_DATETIME_TYPE=!1,M.SUPPORTS_VALUES_DEFAULT=!0,M.NUMBERS_CAN_BE_UNDERSCORE_SEPARATED=!1,M.HEX_STRING_IS_INTEGER_TYPE=!1,M.REGEXP_EXTRACT_DEFAULT_GROUP=0,M.REGEXP_EXTRACT_POSITION_OVERFLOW_RETURNS_NULL=!0,M.ALTER_TABLE_SUPPORTS_CASCADE=!1,M.ALTER_TABLE_ADD_REQUIRED_FOR_EACH_COLUMN=!0,M.TRY_CAST_REQUIRES_STRING=void 0,M.SAFE_TO_ELIMINATE_DOUBLE_NEGATION=!0,M.INITCAP_DEFAULT_DELIMITER_CHARS=`
|
|
18
|
-
\r\f\v!"#$%&'()*+,\\-./:;<=>?@\\[\\]^_\`{|}~`,M.BYTE_STRING_IS_BYTES_TYPE=!1,M.UUID_IS_STRING_TYPE=!1,M.JSON_EXTRACT_SCALAR_SCALAR_ONLY=!1,M.LEAST_GREATEST_IGNORES_NULLS=!0,M.UNNEST_REQUIRES_CROSS_JOIN=!1,M.PRIORITIZE_NON_LITERAL_TYPES=!1,M._tokenizerClassCache=new WeakMap,M._jsonpathTokenizerClassCache=new WeakMap,M._parserClassCache=new WeakMap,M._generatorClassCache=new WeakMap,M.registry=new Map;var ae=M;function vz(a){let e=D(dA(a.args.this,a.args.expressions??[],1-(a.args.offset??0),{dialect:this.dialect}),0);return this.func("ELEMENT_AT",[a.args.this,e])}n(vz,"bracketToElementAtSql");function Fz(a){return function(e){let t=e.args.this,s=e.args.expression;return e.args.caseInsensitive&&(t=t?new dr({this:t}):void 0,s=s?new dr({this:s}):void 0),this.func(a,[t,s])}}n(Fz,"jarowinklerSimilarity");function UD(a){return function(e){let t=[];for(let s of Object.values(e.args))Array.isArray(s)?t.push(...s):t.push(s);return this.func(a,t)}}n(UD,"renameFunc");function Bz(a){return Cb.call(this,a,"accuracy"),this.func("APPROX_COUNT_DISTINCT",[a.args.this])}n(Bz,"approxCountDistinctSql");function $z(a="IF",e){return function(t){return t.parent instanceof ut?`WHEN ${this.sql(t,"this")} THEN ${this.sql(t,"true")}`:this.func(a,[t.args.this,t.args.true,t.args.false||e])}}n($z,"ifSql");function Gz(a){let e=a.args.this;if(this._constructor.JSON_TYPE_REQUIRED_FOR_EXTRACTION&&e instanceof N&&e.isString){let s=new m({this:"json"});e.replace(X(e.copy(),s))}let t=a instanceof ms?"->":"->>";return this.binary(a,t)}n(Gz,"arrowJsonExtractSql");function Sj(a){return`[${this.expressions(a,{dynamic:!0,newLine:!0,skipFirst:!0,skipLast:!0})}]`}n(Sj,"inlineArraySql");function Yz(a){let e=D(a.args.expressions??[],0);return e instanceof d&&e?.find?.(ee)?this.func("ARRAY",[e]):Sj.call(this,a)}n(Yz,"inlineArrayUnlessQuery");function Vz(a){let e=new Qt({this:new Ar({this:a.args.this}),expression:new Ar({this:a.args.expression})});return this.likeSql(e)}n(Vz,"noIlikeSql");function Hz(a){let e=this.sql(a,"this");return e?`CURRENT_DATE AT TIME ZONE ${e}`:"CURRENT_DATE"}n(Hz,"noParenCurrentDateSql");function _z(a){return a.args.recursive&&(this.unsupported("Recursive CTEs are unsupported"),a.setArgKey("recursive",!1)),this.withSql(a)}n(_z,"noRecursiveCteSql");function Wz(a){return this.unsupported("TABLESAMPLE unsupported"),this.sql(a.args.this)}n(Wz,"noTablesampleSql");function jz(a){return this.unsupported("PIVOT unsupported"),""}n(jz,"noPivotSql");function Xz(a){return this.castSql(a)}n(Xz,"noTrycastSql");function Jz(a){return this.unsupported("CommentColumnConstraint unsupported"),""}n(Jz,"noCommentColumnConstraintSql");function zz(a){return this.unsupported("MAP_FROM_ENTRIES unsupported"),""}n(zz,"noMapFromEntriesSql");function Qz(a){return`${this.propertyName(a,{stringKey:!0})}=${this.sql(a,"value")}`}n(Qz,"propertySql");function Zz(a,e={}){let{funcName:t="STRPOS",supportsPosition:s=!1,supportsOccurrence:r=!1,useAnsiPosition:i=!0}=e,o=a.args.this,c=a.args.substr,p=a.args.position,u=a.args.occurrence,h=N.number(0),g=N.number(1);r&&u&&s&&!p&&(p=g);let f=p&&!s;f&&(o=new Ns({this:o,start:p}));let x;if(t==="POSITION"&&i)x=new Qe({this:t,expressions:[new lt({this:c,field:o})]});else{let T=t==="LOCATE"||t==="CHARINDEX"?[c,o]:[o,c];s&&p!==void 0&&T.push(p),u&&(r?T.push(u):this.unsupported(`${t} does not support the occurrence parameter.`)),x=new Qe({this:t,expressions:T.filter(y=>y!==void 0)})}if(f){let T=new ye({this:new we({this:x,expression:p}),expression:g}),y=new fe({this:x.eq(h),true:h,false:T});return this.sql(y)}return this.sql(x)}n(Zz,"strPositionSql");function Kz(a){return`${this.sql(a,"this")}.${this.sql(K(a.args.expression?.name??""))}`}n(Kz,"structExtractSql");function e1(a,e={}){let{swapParams:t=!1}=e;return function(s){let r=s.args.this,i=s.args.expression,o=t?[i,r]:[r,i],c=this.func(a,o),p=!!s.args.nullPropagation,u=this.dialect._constructor.ARRAY_FUNCS_PROPAGATES_NULLS;if(p===u)return c;if(p)return this.sql(new fe({this:new ze({this:r,expression:le()}),true:le(),false:c}));let h=r??new ue({expressions:[]});return r=new tt({expressions:[h,new ue({expressions:[]})]}),o=t?[i,r]:[r,i],this.func(a,o)}}n(e1,"arrayAppendSql");function t1(a,e={}){let{exclusiveFuncName:t}=e;return function(s){let r=s.args.start,i=s.args.end,o=s.args.step;if(s.args.isEndExclusive){if(t)return this.func(t,[r,i,o]);let c=i instanceof d?new ye({this:i,expression:N.number(1)}):i;return this.func(a,[r,c,o])}return this.func(a,[r,i,o])}}n(t1,"generateSeriesSql");function s1(a){function e(t,s){if(this._constructor.ARRAY_CONCAT_IS_VAR_LEN)return this.func(t,s);if(s.length===1)return this.func(t,[s[0],new ue({expressions:[]})]);let r=this.func(t,[s[s.length-2],s[s.length-1]]);for(let i=s.length-3;0<=i;i--)r=`${t}(${this.sql(s[i])}, ${r})`;return r}return n(e,"buildFuncCall"),function(t){let s=t.args.this,r=t.args.expressions||[],i=[...s?[s]:[],...r],o=!!t.args.nullPropagation,c=this.dialect._constructor.ARRAY_FUNCS_PROPAGATES_NULLS;if(o===c||s instanceof ue||r.length===0)return e.call(this,a,i);if(o){let h=i.map(g=>new ze({this:g.copy(),expression:le()})).reduce((g,f)=>new pt({this:g,expression:f}));return this.sql(new fe({this:h,true:le(),false:e.call(this,a,i)}))}let p=i.map(u=>new tt({expressions:[u.copy(),new ue({expressions:[]})]}));return e.call(this,a,p)}}n(s1,"arrayConcatSql");function r1(a,e="MAP"){let t=a.args.keys,s=a.args.values;if(!(t instanceof ue)||!(s instanceof ue))return this.unsupported("Cannot convert array columns into map."),this.func(e,[...J(t),...J(s)]);let r=[],i=t.args.expressions,o=s.args.expressions;for(let c=0;c<Math.min(i?.length||0,o?.length||0);c++)r.push(this.sql(i?.[c])),r.push(this.sql(o?.[c]));return this.func(e,r)}n(r1,"varMapSql");function i1(a){let e=a.args.this,t=a.args.expression,s=X(e,"date"),r=X(t,"date"),i=new _s({this:s,expression:r,unit:Z("month")}),o=new Nr({this:s.copy()}),c=new Nr({this:r.copy()}),p=new _a({this:s.copy()}),u=new _a({this:r.copy()}),h=new Nr({this:p}),g=new Nr({this:u}),f=new Me({this:o.copy(),expression:h}),x=new Me({this:c.copy(),expression:g}),T=new Te({this:f,expression:x}),y=new wt({this:new Se({this:new ye({this:o.copy(),expression:c.copy()})}),expression:N.number("31.0")}),C=new fe({this:T,true:N.number("0"),false:y});return this.sql(new we({this:i,expression:C}))}n(i1,"monthsBetweenSql");function Rj(a,e){let{dialect:t,defaultValue:s}=e;return r=>new a({this:D(r,0),format:ae.get(t)?.formatTime(D(r,1)||(s===!0?ae.get(t)?.TIME_FORMAT:void 0))})}n(Rj,"buildFormattedTime");function n1(a){return function(e){let t=this.formatTime(e);return t!==ae.getOrRaise(a)?._constructor.TIME_FORMAT?t:void 0}}n(n1,"timeFormat");function OD(a,e,t={}){let{defaultUnit:s,supportsTimezone:r=!1}=t;return i=>{let o=3<=i.length,c=i.length===4,p=o?i[2]:D(i,0),u;if(o||s){u=o?i[0]:N.string(s);let g=u.name?.toLowerCase();if(e&&g&&e[g]&&(u=Z(e[g])),(u instanceof Ve||u instanceof $||u instanceof N)&&!(u instanceof $&&u.parts.length!==1)){let f={D:"DAY",H:"HOUR",M:"MINUTE",MS:"MILLISECOND",NS:"NANOSECOND",Q:"QUARTER",S:"SECOND",US:"MICROSECOND",W:"WEEK",Y:"YEAR"};u=new Ve({this:(f[u.name]||u.name).toUpperCase()})}}let h=new a({this:p,expression:D(i,1),unit:u});return r&&c&&h.setArgKey("zone",i[i.length-1]),h}}n(OD,"buildDateDelta");function a1(a){return e=>{if(e.length<2)throw new Ke(`Expected at least 2 arguments but got ${e.length}`);let t=e[1];if(!(t instanceof qe))throw new Ke(`INTERVAL expression expected but got '${t}'`);return new a({this:e[0],expression:t.args.this,unit:DM(t)})}}n(a1,"buildDateDeltaWithInterval");function o1(a){let e=D(a,0),t=D(a,1);return t instanceof z&&t.isType("date")?new ls({unit:e,this:t}):new Sn({this:t,unit:e})}n(o1,"dateTruncToTime");function c1(a,e){return function(t){let s=this.sql(t,"this"),r=new qe({this:t.args.expression,unit:vD(t)});return`${a}_${e}(${s}, ${this.sql(r)})`}}n(c1,"dateAddIntervalSql");function p1(a={}){let{func:e="DATE_TRUNC",zone:t=!1}=a;return function(s){let r=[DM(s),s.args.this];return t&&r.push(s.args.zone),this.func(e,r)}}n(p1,"timestampTruncSql");function l1(a){let e=a.args.zone;if(!e){let t=Kt(a,{dialect:this.dialect}).type,s=Y(t,m)?t:"timestamp";return this.sql(X(a.args.this||"",s))}return SD.has(e.name?.toLowerCase())?this.sql(new gs({this:X(a.args.this||"","timestamp"),zone:e})):this.func("TIMESTAMP",[a.args.this,e])}n(l1,"noTimestampSql");function u1(a){let e=X(a.args.this||"","timestamptz"),t=X(new gs({this:e,zone:a.args.zone}),"time");return this.sql(t)}n(u1,"noTimeSql");function h1(a){let e=a.args.this,t=a.args.expression;if(t&&SD.has(t.name?.toLowerCase()||"")){let i=X(e,"timestamptz"),o=X(new gs({this:i,zone:t}),"timestamp");return this.sql(o)}let s=X(e,"date"),r=X(t||"","time");return this.sql(X(new we({this:s,expression:r}),"timestamp"))}n(h1,"noDatetimeSql");function g1(a){return this.sql(new Ns({this:a.args.this,start:N.number(1),length:a.args.expression}))}n(g1,"leftToSubstringSql");function E1(a){return this.sql(new Ns({this:a.args.this,start:new ye({this:new $h({this:a.args.this}),expression:new Se({this:new ye({this:a.args.expression,expression:N.number(1)})})})}))}n(E1,"rightToSubstringSql");function A1(a,e={}){let{includePrecision:t=!1}=e,s=m.build(a.args.zone?"timestamptz":"timestamp");if(a.args.this instanceof N&&t){let r=rV(a.args.this.name);0<r&&s&&(s=m.build(s.args.this,{expressions:new Jr({this:N.number(r)})}))}return this.sql(X(a.args.this,s,{dialect:this.dialect}))}n(A1,"timeStrToTimeSql");function d1(a){let e=a.args.this,t=e instanceof d||typeof e=="string"?e:"";return this.sql(X(t,"date"))}n(d1,"dateStrToDateSql");function f1(a,e,t={}){let{replace:s=!0}=t,r=a.args.charset;return r&&!["utf-8","utf8"].includes(r.name?.toLowerCase())&&this.unsupported(`Expected utf-8 character set, got ${r}.`),this.func(e,[a.args.this,s?a.getArgKey("replace"):void 0])}n(f1,"encodeDecodeSql");function x1(a){let e=0<(a.args.expressions?.length??0)?"LEAST":"MIN";return UD(e).call(this,a)}n(x1,"minOrLeast");function T1(a){let e=0<(a.args.expressions?.length??0)?"GREATEST":"MAX";return UD(e).call(this,a)}n(T1,"maxOrGreatest");function S1(a){let e=a.args.this;return e instanceof et&&(e=e.args.expressions?.[0],this.unsupported("DISTINCT is not supported when converting COUNT_IF to SUM")),this.func("sum",e?[new fe({this:e,true:N.number(1),false:N.number(0)})]:[])}n(S1,"countIfToSum");function R1(a,e={}){let{defaultTrimType:t=""}=e,s=this.sql(a,"this"),r=this.sql(a,"position")||t,i=this.sql(a,"expression"),o=this.sql(a,"collation");if(!i)return this.trimSql(a);let c=r?`${r} `:"",p=i?`${i} `:"",u=c||p?"FROM ":"",h=o?` COLLATE ${o}`:"";return`TRIM(${c}${p}${u}${s}${h})`}n(R1,"trimSql");function O1(a){return this.func("STRPTIME",[a.args.this,this.formatTime(a)])}n(O1,"strToTimeSql");function ZH(a){return this.sql((a.args.expressions??[]).reduce((e,t)=>new Wt({this:e,expression:t})))}n(ZH,"concatToDPipeSql");function m1(a){let[e,...t]=a.args.expressions??[];return this.sql(t.reduce((s,r)=>new Wt({this:s,expression:new Wt({this:e,expression:r})})))}n(m1,"concatWsToDPipeSql");function N1(a){let e=a.args.group;return e&&e.name===String(this.dialect._constructor.REGEXP_EXTRACT_DEFAULT_GROUP)&&(e=void 0),this.func(a._constructor.sqlName(),[a.args.this,a.args.expression,e])}n(N1,"regexpExtractSql");function I1(a){return this.func("REGEXP_REPLACE",[a.args.this,a.args.expression,a.args.replacement])}n(I1,"regexpReplaceSql");function y1(a,e){let{dialect:t}=e,s=[];for(let r of a)if(r instanceof Re)s.push(r.alias);else{let i=r.transform(o=>o instanceof v?new v({this:o.name,quoted:!1}):o);s.push(i.sql({dialect:t,normalizeFunctions:"lower"}))}return s}n(y1,"pivotColumnNames");function C1(a){return e=>new a({this:D(e,0),expression:D(e,1)})}n(C1,"binaryFromFunction");function b1(a){return new Sn({this:D(a,1),unit:D(a,0)})}n(b1,"buildTimestampTrunc");function P1(a,e){let{dialect:t,dateTruncUnabbreviate:s=!0,defaultDateTruncUnit:r,dateTruncRequiresPart:i=!0}=e,o=D(a,0),c=D(a,1);o&&!o.type&&(o=Kt(o,{dialect:t})),c&&!c.type&&(c=Kt(c,{dialect:t}));let p=o?.isType(m.TEMPORAL_TYPES),u=c?.isType(m.TEXT_TYPES),h=o?.isType(m.NUMERIC_TYPES),g=c?.isType(m.NUMERIC_TYPES);if(o&&p&&(c||r)||c&&u){let f=c||N.string(r??"");return new ls({this:o,unit:f,unabbreviate:s})}return o&&h||c&&g||!i&&!c?new ew({this:o,decimals:c}):new Qe({this:"TRUNC",expressions:a})}n(P1,"buildTrunc");function L1(a){return this.func("MAX",[a.args.this])}n(L1,"anyValueToMaxSql");function w1(a){let e=this.sql(a.left),t=this.sql(a.right);return`(${e} AND (NOT ${t})) OR ((NOT ${e}) AND ${t})`}n(w1,"boolXorSql");function M1(a){return a instanceof ai||a instanceof z&&a.isType("json")}n(M1,"isParseJson");function k1(a){return new Se({this:new ze({this:D(a,0),expression:le()})})}n(k1,"isnullToIsNull");function D1(a){let e=this.sql(a,"start")||"1",t=this.sql(a,"increment")||"1";return`IDENTITY(${e}, ${t})`}n(D1,"generatedAsIdentityColumnConstraintSql");function q1(a){return function(e){return this.func(a,[e.args.this,e.args.expression])}}n(q1,"argMaxOrMinNoCount");function Oj(a){if(!a.args.this)return a;let e=a.args.this.copy(),t=a.returnType;return re(t,m),t.isType("date")&&(e=X(e,"timestamp")),a.args.this?.replace(X(e,t)),a}n(Oj,"tsOrDsAddCast");function U1(a,e={}){let{cast:t=!1}=e;return function(s){let r=s;return t&&s instanceof Vh&&(r=Oj(s)),this.func(a,[vD(r),r.args.expression,r.args.this])}}n(U1,"dateDeltaSql");function v1(a={}){let{cast:e=!0}=a;return function(t){let s=t.args.this,r=vD(t),i=t instanceof xt||t instanceof Bh||t instanceof Fh||t instanceof Ds||t instanceof Vh?"+":"-",o;if(e)if(t instanceof Vh){let u=t.returnType;re(u,m),o=u}else s?.isString&&(o=t instanceof Ds||t instanceof Qs?"datetime":"date");s=o?X(s,o):s;let c=t.args.expression,p=c instanceof qe?c:new qe({this:c,unit:r});return`${this.sql(s)} ${i} ${this.sql(p)}`}}n(v1,"dateDeltaToBinaryIntervalOp");function DM(a,e={}){let{defaultValue:t="DAY"}=e,s=a.args.unit;return s instanceof N,s?s instanceof ar||!(s instanceof Ve||s instanceof N||s instanceof v||s instanceof $)?s:N.string(s.name.toUpperCase()):t?N.string(t):void 0}n(DM,"unitToStr");function vD(a,e={}){let{defaultValue:t="DAY"}=e,s=a.args.unit;if(s instanceof Ve||s instanceof ar||s instanceof $||s instanceof zL)return s;let r=s?.name.toUpperCase()||t;return r?Z(r):void 0}n(vD,"unitToVar");function KH(a,e={}){let{dialect:t=ae}=e;if(a===void 0)return a;let s=a instanceof d?a.name:a,r=a instanceof d&&!(a instanceof $&&a.parts?.length!==1)?ae.getOrRaise(t)._constructor.DATE_PART_MAPPING[s.toUpperCase()]:void 0;return r?a instanceof d&&a.isString?N.string(r):typeof a=="string"?N.string(a):Z(r):a instanceof d?a:N.string(a)}n(KH,"mapDatePart");function F1(a){let e=new ls({this:a.args.this,unit:Z("MONTH")}),t=new xt({this:e,expression:N.number(1),unit:Z("MONTH")}),s=new jt({this:t,expression:N.number(1),unit:Z("DAY")});return this.sql(X(s,"date"))}n(F1,"noLastDaySql");function B1(a){let e=a.args.this?.args.alias,t=n(i=>i?this.dialect.normalizeIdentifier(i).name:void 0,"normalize"),s=a.args.this?.args.this,r=new Set([t(Y(s,d)?s:void 0)]);Y(e,d)&&r.add(typeof e.args.this=="string"?e.args.this:t(Y(e.args.this,d)?e.args.this:void 0));for(let i of a.args.whens?.args.expressions||[]){if(!Y(i,_n))continue;let o=i.args.then;if(o instanceof us)for(let c of o.findAll(Me)){let p=c.args.this;p instanceof $&&r.has(t(typeof p.args.table=="string"?K(p.args.table):p.args.table))&&p.replace(new $({this:p.args.this}))}else if(o instanceof es){let c=o.args.this;if(c instanceof Ze)for(let p of c.args.expressions||[]){if(!(p instanceof d))continue;let u=p,h=u.getArgKey("table");(u.args.this instanceof v||u.args.this instanceof Ne)&&h&&r.has(h instanceof d?t(h):h.toString())&&u.replace(new $({this:u.args.this}))}}}return this.mergeSql(a)}n(B1,"mergeWithoutTargetSql");function $1(a,e={}){let{zeroBasedIndexing:t=!0,arrowReqJsonType:s=!1,jsonType:r}=e;return i=>{let o=[new zt({})];for(let p of i.slice(1)){if(!(p instanceof N))return a.fromArgList(i);let u=p.name;if(FY(u)&&(!s||!p.isString)){let h=parseInt(u);o.push(new ts({this:t?h:h-1}))}else o.push(new Mt({this:u}))}i.splice(2);let c={this:D(i,0),expression:new Er({expressions:o})};return a.prototype instanceof Nh||(c.onlyJsonTypes=s),r!==void 0&&(c.jsonType=r),new a(c)}}n($1,"buildJsonExtractPath");function G1(a,e={}){let{quotedIndex:t=!0,op:s}=e;return function(r){let i=r.args.expression;if(!(i instanceof Er))return UD(a).call(this,r);let o=[];for(let c of i.args.expressions??[]){let p=this.sql(c);p&&(c instanceof qt&&(t||!(c instanceof ts))&&(i.args.escape&&(p=this.escapeStr(p)),p=`${this.dialect._constructor.QUOTE_START}${p}${this.dialect._constructor.QUOTE_END}`),o.push(p))}return s?[this.sql(r.args.this),...o].join(` ${s} `):this.func(a,[r.args.this,...o])}}n(G1,"jsonExtractSegments");function Y1(a){return a.args.this instanceof Dt&&this.unsupported("Unsupported wildcard in JsonPathKey expression"),a.name}n(Y1,"jsonPathKeyOnlyName");function V1(a){let e=a.args.expression,t=N.string("_u");if(e instanceof ps&&(e.args.expressions?.length??0)===1){let i=e.args.expressions?.[0];i&&(t=i),e=e.args.this}else a instanceof uh&&(e=new ft({this:t,expression:a.args.expression}));let s=new Ee({expressions:[...a.args.this?[a.args.this]:[]]}),r=Ye(t).from(Be(s,void 0,{table:[t]})).where(e);return this.sql(new ue({expressions:[r]}))}n(V1,"filterArrayUsingUnnest");function H1(a){let e=new v({this:"_u",quoted:!1}),t=new ze({this:e,expression:le()}).not();return this.sql(new Va({this:a.args.this,expression:new ps({this:t,expressions:[e]})}))}n(H1,"arrayCompactSql");function _1(a){let e=new v({this:"_u",quoted:!1}),t=new ft({this:e,expression:a.args.expression}),s=this.sql(new Va({this:a.args.this,expression:new ps({this:t,expressions:[e]})}));if(a.args.nullPropagation&&!this.dialect._constructor.ARRAY_FUNCS_PROPAGATES_NULLS){let r=a.args.expression;return r instanceof N&&!(r instanceof Pt)||r instanceof ue?s:this.sql(new fe({this:new ze({this:r,expression:le()}),true:le(),false:s}))}return s}n(_1,"removeFromArrayUsingFilter");function W1(a){return this.func("TO_NUMBER",[a.args.this,a.args.format,a.args.nlsparam])}n(W1,"toNumberWithNlsParam");function j1(a,e){return t=>{if(0<(t.args.expressions?.length??0)||a===void 0)return t;let s=e!==void 0?`${a}, ${e}`:`${a}`;return m.build(`DECIMAL(${s})`)??t}}n(j1,"buildDefaultDecimalType");function X1(a){return this.func(`SHA${a.text("length")||"256"}`,[a.args.this])}n(X1,"sha256Sql");function J1(a){return this.func(`SHA${a.text("length")||"256"}`,[a.args.this])}n(J1,"sha2DigestSql");function z1(a){let e=a,t=e.args.start,s=e.args.end,r=e.args.step,i=t instanceof z?t.args.to:s instanceof z?s.args.to:void 0;if(t!==void 0&&s!==void 0&&(Rn(i,["date","timestamp"])&&(re(i,m),t instanceof z&&i===t.to?s=X(s,i):t=X(t,i)),Y(e,As)&&e.args.isEndExclusive)){let o=r||N.number(1),c=new ye({this:s,expression:o});s=new Se({this:c});let p=new Qe({this:"SEQUENCE",expressions:[t,s,...r?[r]:[]]}),u=N.number(0),h=Vt([new Me({this:o.copy(),expression:u.copy()}),ve([new je({this:o.copy(),expression:u.copy()}),new je({this:t.copy(),expression:s.copy()})]),ve([new Fe({this:o.copy(),expression:u.copy()}),new Fe({this:t.copy(),expression:s.copy()})])]),g=new fe({this:h,true:new ue({expressions:[]}),false:p});return this.sql(this.simplifyUnlessLiteral(g))}return this.func("SEQUENCE",[t,s,r])}n(z1,"sequenceSql");function Q1(a,e={}){let{notLike:t=!1}=e;return s=>{let r=new a({this:D(s,0),expression:D(s,1)}),i=D(s,2);return i&&(r=new Ba({this:r,expression:i})),t?new Le({this:r}):r}}n(Q1,"buildLike");function Z1(a){return(e,{dialect:t})=>{let s={this:D(e,0),expression:D(e,1),group:D(e,2)||N.number(t._constructor.REGEXP_EXTRACT_DEFAULT_GROUP),parameters:D(e,3)};return a===ZL&&(s.nullIfPosOverflow=t._constructor.REGEXP_EXTRACT_POSITION_OVERFLOW_RETURNS_NULL),new a(s)}}n(Z1,"buildRegexpExtract");function K1(a){let e=a.args.this,t=a.args.alias,s;if(e instanceof li&&t){re(t,pe);let[r,...i]=t.args.columns||[];re(r,v);let o=i.filter(p=>p instanceof d),c=Ye([Be(r.sub(1),r),...o]).from(new Ee({expressions:[...e.args.this?[e.args.this]:[]],offset:!0,alias:new pe({this:t.args.this,columns:[...o,r]})}));s=new Ct({this:c.subquery()})}else e instanceof Xt&&(s=new Ee({expressions:[...e.args.this?[e.args.this]:[]],alias:t}));return s?this.sql(new xe({this:s,kind:"cross"})):this.lateralSql(a)}n(K1,"explodeToUnnestSql");function eQ(a){return this.func("TIMESTAMPDIFF",[a.unit,a.args.expression,a.args.this])}n(eQ,"timestampDiffSql");function tQ(a,e={}){let{sep:t=", "}=e;return`INTERVAL '${Object.entries(a.args).map(([r,i])=>`${i instanceof oh?i.args.expression:i} ${r}`).join(t)}'`}n(tQ,"noMakeIntervalSql");function sQ(a){return this.func(a.args.binary?"LENGTH":"CHAR_LENGTH",[a.args.this])}n(sQ,"lengthOrCharLengthSql");function rQ(a,e={}){let{funcName:t="LISTAGG",sep:s,withinGroup:r=!0,onOverflow:i=!1}=e,o=s===void 0?",":s,c=a.args.this,p=this.sql(a.args.separator||(o?N.string(o):void 0)),u=i&&this.sql(a,"onOverflow")?` ON OVERFLOW ${this.sql(a,"onOverflow")}`:"",h;c instanceof kt&&(h=c,c=h.args.this?.pop());let g=c?.find(Ie);g?.args.this&&(c=g.args.this.pop());let f=[c?this.sql(c):void 0,p?`${p}${u}`:u||void 0].filter(Boolean).join(", "),x=new Qe({this:t,expressions:[f]}),T=this.sql(h);return g&&(r?x=new ns({this:x,expression:g}):T=`${this.sql(g)}${T}`),T&&x.setArgKey("expressions",[`${f}${T}`]),this.sql(x)}n(rQ,"groupConcatSql");function iQ(a,{dialect:e}){if(a.length===2){let t=a[0];if(t.type||Kt(t,{dialect:e}),t.isType(m.TEMPORAL_TYPES)){let s;return typeof e=="string"?s=e:typeof e=="function"?s=e.name.toLowerCase():s=e.constructor.name.toLowerCase(),Rj(Or,{dialect:s,defaultValue:!0})(a)}}return QL.fromArgList(a)}n(iQ,"buildTimeToStrOrToChar");function nQ(a){return new KL({this:D(a,0),expression:D(a,1),replacement:D(a,2)||N.string("")})}n(nQ,"buildReplaceWithOptionalReplacement");function aQ(a){let e=a.args.modifiers;return!a.args.singleReplace&&(!a.args.occurrence||a.args.occurrence.isInteger&&a.args.occurrence.toValue()===0)&&(!e||e.isString)?N.string((e?.name||"")+"g"):e}n(aQ,"regexpReplaceGlobalModifier");function oQ(a){let e=a.args.this,t=a.args.expression;if(!a.args.zeroIsMsb&&a.isType([...m.SIGNED_INTEGER_TYPES,...m.UNSIGNED_INTEGER_TYPES])){let s=new ih({this:e,expression:t}),r=new rh({this:s,expression:N.number(1)});return this.sql(r)}return this.func("GET_BIT",[e,t])}n(oQ,"getBitSql");var L_="i",w_="k",M_="a",FD="c",sw="t",BD="o",$D="m",FM="v",k_="DataType.Type";function GD(a){let e=0,t=[],s=[[a,void 0,void 0,!1]];for(;0<s.length;){let[r,i,o,c]=s.pop(),p={};if(i!==void 0&&(p[L_]=i),o!==void 0&&(p[w_]=o),c&&(p[M_]=c),t.push(p),r instanceof d){if(p[FD]=r.constructor.name,r.type&&(typeof r=="string"?p[sw]=[r]:typeof r.type=="string"?p[sw]=[r.type]:p[sw]=GD(r.type)),r.comments&&0<r.comments.length&&(p[BD]=r.comments),r.meta&&(p[$D]=r.meta),r.args){let u=Object.entries(r.args).reverse();for(let[h,g]of u)if(Array.isArray(g))for(let f=g.length-1;0<=f;f--)s.push([g[f],e,h,!0]);else g!==void 0&&s.push([g,e,h,!1])}}else r&&typeof r=="object"&&"value"in r?(p[FD]=k_,p[FM]=r.value):p[FM]=r;e++}return t}n(GD,"dump");function YD(a,e){let t={...VD,...e};if(!a||a.length===0)return;let[s,...r]=a,i=P_(s,t);if(!(i instanceof d))return;let o=[i];for(let c of r){let p=P_(c,t);o.push(p);let u=o[c[L_]],h=c[w_];c[M_]?u.append(h,p):u.setArgKey(h,p)}return i}n(YD,"load");function P_(a,e){let t=a[FD];if(!t)return a[FM];if(t===k_)return st(At,a[FM]);let s=e[t];if(!s)throw new Error(`Expression class does not exist: ${t}`);let r=new s({});return a[sw]&&(r.type=YD(a[sw])),a[BD]&&(r.comments=a[BD]),a[$D]&&(r.meta=a[$D]),r}n(P_,"_load");function HD(a){switch(String(a)){case"__proto__":case"prototype":case"constructor":throw new Error("Error: Block an attempty to pollute an object prototype");default:return}}n(HD,"requireSafeDynamicObjectKey");var q_="sqlglot.meta",ND="sqlglot.anonymous",X$=["this","db","catalog"],U_=["this","table","db","catalog"],v_=["line","col","start","end"];function mj(a){if(typeof a=="boolean")return a;if(typeof a=="string"){let e=a.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"}return!!a}n(mj,"toBool");var _e=class _e{constructor(e={}){this.args={};this.meta={};this.args=e;for(let[t,s]of Object.entries(e))this.setParent(t,s);Object.defineProperty(this,"meta",{value:{},writable:!0,configurable:!0,enumerable:!1}),Object.defineProperty(this,"comments",{value:void 0,writable:!0,configurable:!0,enumerable:!1})}*[Symbol.iterator](){if(this.constructor.availableArgs.has("expressions")){if(Array.isArray(this.args.expressions))for(let e of this.args.expressions)yield e;return}}text(e){let t=this.getArgKey(e);return typeof t=="string"?t:t instanceof v||t instanceof N||t instanceof Ve?t.args.this?.toString()??"":t instanceof Ne||t instanceof Pt?t.name:""}get isString(){return this instanceof N&&this.args.isString===!0}get isNumber(){return this instanceof N&&!this.args.isString||this instanceof bt&&this.args.this.isNumber}toValue(){if(this instanceof N){let e=this.args.this;return this.isString?e:typeof e=="string"?Number(e):e}if(this instanceof bt){let e=this.args.this.toValue();return typeof e=="number"?-e:e!==void 0?-Number(e):void 0}throw new Error(`${this.constructor.name} cannot be converted to a JavaScript value.`)}get isInteger(){if(!this.isNumber)return!1;if(this instanceof N){let e=String(this.args.this);return!e.includes(".")&&!e.toLowerCase().includes("e")}try{return this.args.this.isInteger}catch{return!1}}get isStar(){return this instanceof Ne||this instanceof $&&this.args.this instanceof Ne}get alias(){return this.args.alias instanceof _e?this.args.alias.name:this.text("alias")}get aliasColumnNames(){let e=this.args.alias;if(!(e instanceof pe))return[];let t=e.args.columns;return Array.isArray(t)?t.map(s=>s instanceof _e?s.name:""):[]}get name(){return this.text("this")}get aliasOrName(){return this.alias||this.name}get sqlKey(){return this.sql()}get outputName(){return""}get type(){return this instanceof z?this._type||this.args.to:this._type}set type(e){e!==void 0&&!(e instanceof m)&&(e=m.build(e)),this._type=e}isType(e,t){return this._type?this._type.isType(J(e)):!1}get isLeaf(){return!Object.values(this.args).some(e=>(e instanceof _e||Array.isArray(e))&&e)}copy(){let e=new this.constructor,t=[[this,e]];for(;0<t.length;){let[s,r]=t.pop();s.comments&&(r.comments=[...s.comments]),s._type&&(r._type=s._type.copy()),s.meta&&(r.meta={...s.meta}),s._hash&&(r._hash=s._hash);for(let[i,o]of Object.entries(s.args))if(o instanceof _e){let c=new o.constructor;t.push([o,c]),r.setArgKey(i,c)}else if(Array.isArray(o)){r.args[i]=[];for(let c of o)if(c instanceof _e){let p=new c.constructor;t.push([c,p]),r.append(i,p)}else r.append(i,c)}else r.args[i]=o}return e}addComments(e,t={}){let{prepend:s=!1}=t;if(this.comments||(this.comments=[]),e){for(let r of e){let[i,...o]=r.split(q_);if(0<o.length)for(let c of o.join("").split(",")){let[p,...u]=c.split("="),h=0<u.length?u[0].trim():void 0,g=yM(p.trim());h===void 0?this.meta[g]=!0:/^(true|false|1|0)$/i.test(h)?this.meta[g]=mj(h):this.meta[g]=h}s||this.comments.push(r)}s&&(this.comments=[...e,...this.comments])}}popComments(){let e=this.comments||[];return this.comments=void 0,e}append(e,t){let s=this.args;Array.isArray(s[e])||(s[e]=[]),this.setParent(e,t);let r=s[e];t instanceof _e&&(t.index=r.length),r.push(t)}setArgKey(e,t,s,r){HD(e),HD(s);let i=r?.overwrite??!0,o=this;for(;o&&o._hash!==void 0;)o._hash=void 0,o=o.parent;let c=this.args;if(s!==void 0){let p=c[e]||[];if(p[s]===void 0)return;if(t===void 0){p.splice(s,1);for(let u=s;u<p.length;u++){let h=p[u];h instanceof _e&&h.index!==void 0&&(h.index=h.index-1)}return}Array.isArray(t)?(p.splice(s,1),p.splice(s,0,...t)):i?p[s]=t:p.splice(s,0,t),t=p}else if(t===void 0){delete c[e];return}c[e]=t,this.setParent(e,t,s)}getArgKey(e){if(e!==void 0)return this.args[e]??void 0}setParent(e,t,s){t instanceof _e?(t.parent=this,t.argKey=e,t.index=s):Array.isArray(t)&&t.forEach((r,i)=>{r instanceof _e&&(r.parent=this,r.argKey=e,r.index=i)})}get depth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}*iterExpressions(e){let t=e?.reverse??!1,s=t?Object.values(this.args).reverse():Object.values(this.args);for(let r of s)if(r instanceof _e)yield r;else if(Array.isArray(r)){let i=t?[...r].reverse():r;for(let o of i)o instanceof _e&&(yield o)}}find(e,t){for(let s of this.findAll(e,t))return s}*findAll(e,t){let s=Array.from(J(e)),r=t?.bfs??!0;for(let i of this.walk({bfs:r}))s.some(o=>i instanceof o)&&(yield i)}findAncestor(...e){let t=this.parent;for(;t;){if(e.some(s=>t instanceof s))return t;t=t.parent}}get parentSelect(){return this.findAncestor(se)}get sameParent(){return this.parent?.constructor===this.constructor}sameParentAs(e){return this.parent===e.parent}root(){let e=this;for(;e.parent;)e=e.parent;return e}*walk(e){let t=e?.bfs??!0,s=e?.prune;t?yield*this.bfs({prune:s}):yield*this.dfs({prune:s})}*dfs(e){let t=e?.prune,s=[this];for(;0<s.length;){let r=s.pop();if(yield r,!t?.(r))for(let i of r.iterExpressions({reverse:!0}))s.push(i)}}*bfs(e){let t=e?.prune,s=[this];for(;0<s.length;){let r=s.shift();if(yield r,!t?.(r))for(let i of r.iterExpressions())s.push(i)}}unnest(){let e=this;for(;e instanceof Se;){let t=e.args.this;if(t instanceof _e)e=t;else break}return e}unalias(){if(this instanceof Re){let e=this.args.this;if(e instanceof _e)return e}return this}unnestOperands(){return Array.from(this.iterExpressions()).map(e=>e.unnest())}*flatten(e){let t=e?.unnest??!0;for(let s of this.dfs({prune:n(r=>r.parent!==void 0&&r.constructor!==this.constructor,"prune")}))s.constructor!==this.constructor&&(t&&!(s instanceof he)?yield s.unnest():yield s)}sql(e={}){let{dialect:t,...s}=e;return ae.getOrRaise(t).generate(this,s)}transform(e,t={}){let{copy:s=!0,...r}=t,i,o,c=s?this.copy():this;for(let p of c.dfs({prune:n(u=>u!==o,"prune")})){let u=p.parent,h=p.argKey,g=p.index;o=e(p,{...r,copy:s}),i?u&&h&&o!==p&&u.setArgKey(h,o,g):i=o}if(!i)throw new Error("Transform failed: no root node");if(!(i instanceof _e))throw new Error("Expected final root to be an Expression");return i}replace(e){let t=this.parent;if(!t||t===e)return e;let s=this.argKey;if(!s)return e;let r=t.getArgKey(s);return Array.isArray(e)&&r instanceof _e?r.parent?.replace(e):t.setArgKey(s,e,this.index),e!==this&&(this.parent=void 0,this.argKey=void 0,this.index=void 0),e}pop(){return this.replace(void 0),this}assertIs(e){if(!(this instanceof e))throw new Error(`${this.constructor.name} is not ${e.name}.`);return this}errorMessages(e){let t=[],s=this._constructor;for(let r of s.requiredArgs){let i=this.getArgKey(r);(i===void 0||Array.isArray(i)&&i.length===0)&&t.push(`Required keyword: '${r}' missing for ${this.constructor.name}`)}if(e&&this instanceof E){let r=s.availableArgs.size,i=s.isVarLenArgs||!1;r<e.length&&!i&&t.push(`The number of provided arguments (${e.length}) is greater than the maximum number of supported arguments (${r})`)}return t}dump(){return GD(this)}static load(e){return YD(e)}and(e,t={}){let{copy:s=!0,wrap:r=!0,...i}=t,o=Array.from(J(e));return ve([this,...o],{...i,copy:s,wrap:r})}or(e,t={}){let{copy:s=!0,wrap:r=!0,...i}=t,o=Array.from(J(e));return Vt([this,...o],{...i,copy:s,wrap:r})}not(e={}){let{copy:t=!0,...s}=e;return ks(this,{...s,copy:t})}updatePositions(e,t){if(!e)this.meta.line=t?.line,this.meta.col=t?.col,this.meta.start=t?.start,this.meta.end=t?.end;else if(e instanceof _e)for(let s of v_)s in e.meta&&(this.meta[s]=e.meta[s]);else this.meta.line=e.line,this.meta.col=e.col,this.meta.start=e.start,this.meta.end=e.end;return this}as(e,t={}){let{copy:s=!0,...r}=t,i=e instanceof _e?e.name:e.toString();return Be(this,i,{...r,copy:s})}binop(e,t,s){let r=s?.reverse??!1,i=this.copy(),o=ht(t,{copy:!0});if(!(i instanceof e)&&!(t instanceof e)){let c=mr(i,U),p=mr(o,U);c&&(i=c),p&&(o=p)}return r?new e({this:o,expression:i}):new e({this:i,expression:o})}resetHash(){this._hash=void 0}computeHash(){return this.hash()}hash(){if(this._hash!==void 0)return this._hash;let e=[],t=[this];for(;0<t.length;){let s=t.shift();e.push(s);for(let r of s.iterExpressions())r._hash===void 0&&t.push(r)}for(let s=e.length-1;0<=s;s--){let r=e[s],i=this.hashString(r._constructor.key);if(r instanceof N||r instanceof v){let o=Object.entries(r.args).sort();for(let[c,p]of o)p&&(i=this.hashString(i+c+p.toString()))}else{let o=Object.entries(r.args);for(let[c,p]of o)if(Array.isArray(p))for(let u of p)if(u!==void 0&&u!==!1){let h=typeof u=="string"?u.toLowerCase():u;i=this.hashString(i+c+h)}else i=this.hashString(i+c);else if(p!==void 0&&p!==!1){let u=typeof p=="string"?p.toLowerCase():p;i=this.hashString(i+c+u)}}r._hash=i}return this._hash||""}equals(e){return this===e?!0:!(e instanceof _e)||this.constructor!==e.constructor?!1:this.hash()===e.hash()}hashString(e){return e.split("").reduce((t,s)=>(t=(t<<5)-t+s.charCodeAt(0),t&t),0).toString()}toString(){return this.sql()}in(e,t,s={}){let{copy:r=!0,unnest:i,...o}=s,c=t?W(t):void 0;return!(c instanceof he)&&c instanceof ee&&(c=c.subquery(void 0,{copy:!1})),new lt({this:$e(this,r),expressions:e?.map(p=>ht(p,{copy:r})),query:c,unnest:i?new Ee({expressions:Array.from(J(i)).map(p=>W(p,{...o,copy:r}))}):void 0})}between(e,t,s={}){let{copy:r=!0,symmetric:i}=s,o=new Ts({this:$e(this,r),low:ht(e,{copy:r}),high:ht(t,{copy:r})});return i!==void 0&&o.setArgKey("symmetric",i),o}is(e){return this.binop(ze,e)}like(e){return this.binop(Qt,e)}ilike(e){return this.binop(Gs,e)}eq(e){return this.binop(Me,e)}neq(e){return this.binop(ft,e)}rlike(e){return this.binop(Ga,e)}div(e,t){let s=this.binop(wt,e);return s.setArgKey("typed",t?.typed??!1),s.setArgKey("safe",t?.safe??!1),s}asc(e={}){let{nullsFirst:t=!0}=e;return new hs({this:this.copy(),nullsFirst:t?ht(t):void 0})}desc(e={}){let{nullsFirst:t=!1}=e;return new hs({this:this.copy(),desc:ht(!0),nullsFirst:t?ht(t):void 0})}lt(e){return this.binop(Fe,e)}lte(e){return this.binop(nt,e)}gt(e){return this.binop(je,e)}gte(e){return this.binop(Je,e)}add(e){return this.binop(we,e)}radd(e){return this.binop(we,e,{reverse:!0})}sub(e){return this.binop(ye,e)}rsub(e){return this.binop(ye,e,{reverse:!0})}mul(e){return this.binop(xs,e)}rmul(e){return this.binop(xs,e,{reverse:!0})}truediv(e){return this.binop(wt,e)}rtruediv(e){return this.binop(wt,e,{reverse:!0})}floorDiv(e){return this.binop(Un,e)}rfloorDiv(e){return this.binop(Un,e,{reverse:!0})}mod(e){return this.binop(jr,e)}rmod(e){return this.binop(jr,e,{reverse:!0})}pow(e){return this.binop(Gh,e)}rpow(e){return this.binop(Gh,e,{reverse:!0})}neg(){return new bt({this:mr(this.copy(),U)})}invert(){return ks(this.copy())}getItem(...e){return new Lt({this:this.copy(),expressions:(Array.isArray(e)?e:[e]).map(t=>ht(t,{copy:!0}))})}get _constructor(){return this.constructor}};n(_e,"Expression"),_e.key="expression",_e.requiredArgs=new Set(["this"]),_e.availableArgs=new Set(["this"]);var d=_e,VM=class VM extends d{constructor(e={}){super(e)}};n(VM,"ConditionExpr"),VM.key="condition";var Ce=VM,fd=class fd extends Ce{constructor(e={}){super(e)}};n(fd,"PredicateExpr"),fd.key="predicate",fd.requiredArgs=new Set(["this"]),fd.availableArgs=new Set(["this"]);var ke=fd,xd=class xd extends d{constructor(e={}){super(e)}get selects(){return this.args.this instanceof ee?this.args.this.selects:[]}get namedSelects(){return this.selects.map(e=>e.outputName)}};n(xd,"DerivedTableExpr"),xd.key="derivedTable",xd.requiredArgs=new Set(["this"]),xd.availableArgs=new Set(["this"]);var An=xd,Td=class Td extends d{constructor(e={}){super(e)}subquery(e,t={}){let{copy:s=!0}=t,r=$e(this,s),i;return e instanceof pe?i=e:e&&(i=new pe({this:K(e)})),new he({this:r,alias:i})}limit(e,t={}){let{copy:s=!0,...r}=t;return JE(e,{instance:this,arg:"limit",into:kt,prefix:"LIMIT",intoArg:"expression",...r,copy:s})}offset(e,t={}){let{copy:s=!0,...r}=t;return JE(e,{instance:this,arg:"offset",into:Cn,prefix:"OFFSET",intoArg:"expression",...r,copy:s})}orderBy(e,t={}){let{append:s=!0,copy:r=!0,...i}=t,o=Array.from(J(e));return dd(o,{instance:this,arg:"order",prefix:"ORDER BY",into:Ie,...i,append:s,copy:r})}get ctes(){let e=this.args.with;return Et(e?.args.expressions??[],d)}get selects(){throw new Error("Query objects must implement `selects`")}get namedSelects(){throw new Error("Query objects must implement `namedSelects`")}select(e,t={}){throw new Error("Query objects must implement `select`")}where(e,t={}){let{append:s=!0,copy:r=!0,dialect:i,...o}=t;return vI(J(e).map(c=>c instanceof St?c.args.this:c),{instance:this,arg:"where",into:St,append:s,copy:r,dialect:i,...o})}with(e,t,s={}){let{recursive:r=!1,append:i=!0,copy:o=!0,...c}=s;return z$({instance:this,alias:e,as:t,...c,recursive:r,append:i,copy:o})}union(e,t={}){return WA([this,...e!==void 0?J(e):[]],{...t,distinct:t.distinct??!0})}intersect(e,t={}){return B_([this,...J(e)],{...t,distinct:t.distinct??!0})}except(e,t={}){return $_([this,...e!==void 0?Array.from(J(e)):[]],{...t,distinct:t.distinct??!0})}};n(Td,"QueryExpr"),Td.key="query",Td.requiredArgs=new Set(["this"]),Td.availableArgs=new Set(["this"]);var ee=Td,HM=class HM extends An{constructor(e={}){super(e)}get selects(){let e=this.args.alias;return Y(e,pe)?e.columns:[]}};n(HM,"UdtfExpr"),HM.key="udtf";var yt=HM,Sd=class Sd extends d{constructor(e={}){super(e)}};n(Sd,"CacheExpr"),Sd.key="cache",Sd.requiredArgs=new Set(["this"]),Sd.availableArgs=new Set(["this","lazy","options","expression"]);var iy=Sd,Rd=class Rd extends d{constructor(e={}){super(e)}};n(Rd,"UncacheExpr"),Rd.key="uncache",Rd.requiredArgs=new Set(["this"]),Rd.availableArgs=new Set(["this","exists"]);var ny=Rd,Od=class Od extends d{constructor(e={}){super(e)}};n(Od,"RefreshExpr"),Od.key="refresh",Od.requiredArgs=new Set(["this","kind"]),Od.availableArgs=new Set(["this","kind"]);var ay=Od,md=class md extends d{constructor(e={}){super(e)}get ctes(){let e=this.args.with;return Et(e?.args.expressions??[],d)}get selects(){let e=this.args.expression;return e instanceof ee?e.selects:[]}get namedSelects(){let e=this.args.expression;return e instanceof ee?e.namedSelects:[]}};n(md,"DdlExpr"),md.key="ddl",md.requiredArgs=new Set(["this"]),md.availableArgs=new Set(["this"]);var dn=md,Nd=class Nd extends d{constructor(e={}){super(e)}};n(Nd,"LockingStatementExpr"),Nd.key="lockingStatement",Nd.requiredArgs=new Set(["this","expression"]),Nd.availableArgs=new Set(["this","expression"]);var _D=Nd,Id=class Id extends d{constructor(e={}){super(e)}returning(e,t={}){let{copy:s=!0,...r}=t;return JE(e,{instance:this,arg:"returning",prefix:"RETURNING",into:FA,...r,copy:s})}};n(Id,"DmlExpr"),Id.key="dml",Id.requiredArgs=new Set(["this"]),Id.availableArgs=new Set(["this"]);var bs=Id,yd=class yd extends dn{constructor(e={}){super(e)}get kind(){return this.args.kind}};n(yd,"CreateExpr"),yd.key="create",yd.requiredArgs=new Set(["this","kind"]),yd.availableArgs=new Set(["with","this","kind","expression","exists","properties","replace","refresh","unique","indexes","noSchemaBinding","begin","clone","concurrently","clustered"]);var ss=yd,Cd=class Cd extends d{constructor(e={}){super(e)}};n(Cd,"SequencePropertiesExpr"),Cd.key="sequenceProperties",Cd.requiredArgs=new Set,Cd.availableArgs=new Set(["increment","minvalue","maxvalue","cache","start","owned","options"]);var Br=Cd,bd=class bd extends d{constructor(e={}){super(e)}};n(bd,"TriggerPropertiesExpr"),bd.key="triggerProperties",bd.requiredArgs=new Set(["table","timing","events","execute"]),bd.availableArgs=new Set(["table","timing","events","execute","constraint","referencedTable","deferrable","initially","referencing","forEach","when"]);var Gn=bd,_M=class _M extends d{constructor(e={}){super(e)}};n(_M,"TriggerExecuteExpr"),_M.key="triggerExecute";var oy=_M,Pd=class Pd extends d{constructor(e={}){super(e)}};n(Pd,"TriggerEventExpr"),Pd.key="triggerEvent",Pd.requiredArgs=new Set(["this"]),Pd.availableArgs=new Set(["this","columns"]);var cy=Pd,Ld=class Ld extends d{constructor(e={}){super(e)}};n(Ld,"TriggerReferencingExpr"),Ld.key="triggerReferencing",Ld.requiredArgs=new Set,Ld.availableArgs=new Set(["old","new"]);var py=Ld,wd=class wd extends d{constructor(e={}){super(e)}};n(wd,"TruncateTableExpr"),wd.key="truncateTable",wd.requiredArgs=new Set(["expressions"]),wd.availableArgs=new Set(["expressions","isDatabase","exists","only","cluster","identity","option","partition"]);var ly=wd,Md=class Md extends d{constructor(e={}){super(e)}};n(Md,"CloneExpr"),Md.key="clone",Md.requiredArgs=new Set(["this"]),Md.availableArgs=new Set(["this","shallow","copy"]);var uy=Md,kd=class kd extends d{constructor(e={}){super(e)}};n(kd,"DescribeExpr"),kd.key="describe",kd.requiredArgs=new Set(["this"]),kd.availableArgs=new Set(["this","properties","style","kind","expressions","partition","format","asJson"]);var Ql=kd,Dd=class Dd extends d{constructor(e={}){super(e)}};n(Dd,"AttachExpr"),Dd.key="attach",Dd.requiredArgs=new Set(["this"]),Dd.availableArgs=new Set(["this","exists","expressions"]);var WD=Dd,qd=class qd extends d{constructor(e={}){super(e)}};n(qd,"DetachExpr"),qd.key="detach",qd.requiredArgs=new Set(["this"]),qd.availableArgs=new Set(["this","kind","exists","cluster","permanent","sync"]);var jD=qd,Ud=class Ud extends d{constructor(e={}){super(e)}};n(Ud,"InstallExpr"),Ud.key="install",Ud.requiredArgs=new Set(["this"]),Ud.availableArgs=new Set(["this","from","force"]);var XD=Ud,vd=class vd extends d{constructor(e={}){super(e)}};n(vd,"SummarizeExpr"),vd.key="summarize",vd.requiredArgs=new Set(["this"]),vd.availableArgs=new Set(["this","table"]);var hy=vd,Fd=class Fd extends d{constructor(e={}){super(e)}};n(Fd,"KillExpr"),Fd.key="kill",Fd.requiredArgs=new Set(["this"]),Fd.availableArgs=new Set(["this","kind"]);var gy=Fd,Bd=class Bd extends d{constructor(e={}){super(e)}};n(Bd,"PragmaExpr"),Bd.key="pragma",Bd.requiredArgs=new Set(["this"]),Bd.availableArgs=new Set(["this"]);var Ey=Bd,$d=class $d extends d{constructor(e={}){super(e)}};n($d,"DeclareExpr"),$d.key="declare",$d.requiredArgs=new Set(["expressions"]),$d.availableArgs=new Set(["expressions","replace"]);var Ay=$d,Gd=class Gd extends d{constructor(e={}){super(e)}};n(Gd,"DeclareItemExpr"),Gd.key="declareItem",Gd.requiredArgs=new Set(["this"]),Gd.availableArgs=new Set(["this","kind","default"]);var dy=Gd,Yd=class Yd extends d{constructor(e={}){super(e)}};n(Yd,"SetExpr"),Yd.key="set",Yd.requiredArgs=new Set,Yd.availableArgs=new Set(["expressions","unset","tag"]);var Zl=Yd,Vd=class Vd extends d{constructor(e={}){super(e)}};n(Vd,"HeredocExpr"),Vd.key="heredoc",Vd.requiredArgs=new Set(["this"]),Vd.availableArgs=new Set(["this","tag"]);var xA=Vd,Hd=class Hd extends d{constructor(e={}){super(e)}};n(Hd,"SetItemExpr"),Hd.key="setItem",Hd.requiredArgs=new Set,Hd.availableArgs=new Set(["this","expressions","kind","collate","global"]);var Xl=Hd,_d=class _d extends d{constructor(e={}){super(e)}};n(_d,"QueryBandExpr"),_d.key="queryBand",_d.requiredArgs=new Set(["this"]),_d.availableArgs=new Set(["this","scope","update"]);var JD=_d,Wd=class Wd extends d{constructor(e={}){super(e)}};n(Wd,"ShowExpr"),Wd.key="show",Wd.requiredArgs=new Set(["this"]),Wd.availableArgs=new Set(["this","history","terse","target","offset","startsWith","limit","from","like","where","db","scope","scopeKind","full","mutex","query","channel","global","log","position","types","privileges","forTable","forGroup","forUser","forRole","intoOutfile","json","iceberg"]);var zD=Wd,jd=class jd extends d{constructor(e={}){super(e)}};n(jd,"UserDefinedFunctionExpr"),jd.key="userDefinedFunction",jd.requiredArgs=new Set(["this"]),jd.availableArgs=new Set(["this","expressions","wrapped"]);var fy=jd,Xd=class Xd extends d{constructor(e={}){super(e)}};n(Xd,"CharacterSetExpr"),Xd.key="characterSet",Xd.requiredArgs=new Set(["this"]),Xd.availableArgs=new Set(["this","default"]);var TA=Xd,Jd=class Jd extends d{constructor(e={}){super(e)}};n(Jd,"RecursiveWithSearchExpr"),Jd.key="recursiveWithSearch",Jd.requiredArgs=new Set(["kind","this","expression"]),Jd.availableArgs=new Set(["kind","this","expression","using"]);var xy=Jd,zd=class zd extends d{constructor(e={}){super(e)}get recursive(){return this.args.recursive}};n(zd,"WithExpr"),zd.key="with",zd.requiredArgs=new Set(["expressions"]),zd.availableArgs=new Set(["expressions","recursive","search"]);var dt=zd,Qd=class Qd extends d{constructor(e={}){super(e)}};n(Qd,"WithinGroupExpr"),Qd.key="withinGroup",Qd.requiredArgs=new Set(["this"]),Qd.availableArgs=new Set(["this","expression"]);var ns=Qd,Zd=class Zd extends d{constructor(e={}){super(e)}};n(Zd,"ProjectionDefExpr"),Zd.key="projectionDef",Zd.requiredArgs=new Set(["this","expression"]),Zd.availableArgs=new Set(["this","expression"]);var QD=Zd,Kd=class Kd extends d{constructor(e={}){super(e)}get columns(){return this.args.columns||[]}};n(Kd,"TableAliasExpr"),Kd.key="tableAlias",Kd.requiredArgs=new Set,Kd.availableArgs=new Set(["this","columns"]);var pe=Kd,ef=class ef extends d{constructor(e={}){super(e)}};n(ef,"ColumnPositionExpr"),ef.key="columnPosition",ef.requiredArgs=new Set(["position"]),ef.availableArgs=new Set(["this","position"]);var Ty=ef,tf=class tf extends d{constructor(e={}){super(e)}get kind(){return this.args.kind}get constraints(){return this.args.constraints||[]}};n(tf,"ColumnDefExpr"),tf.key="columnDef",tf.requiredArgs=new Set(["this"]),tf.availableArgs=new Set(["this","kind","constraints","exists","position","default","output"]);var be=tf,sf=class sf extends d{constructor(e={}){super(e)}};n(sf,"AlterColumnExpr"),sf.key="alterColumn",sf.requiredArgs=new Set(["this"]),sf.availableArgs=new Set(["this","dtype","collate","using","default","drop","comment","allowNull","visible","renameTo"]);var Os=sf,WM=class WM extends d{constructor(e={}){super(e)}};n(WM,"ModifyColumnExpr"),WM.key="modifyColumn";var ZD=WM,rf=class rf extends d{constructor(e={}){super(e)}};n(rf,"AlterIndexExpr"),rf.key="alterIndex",rf.requiredArgs=new Set(["this","visible"]),rf.availableArgs=new Set(["this","visible"]);var KD=rf,nf=class nf extends d{constructor(e={}){super(e)}};n(nf,"AlterDistStyleExpr"),nf.key="alterDistStyle",nf.requiredArgs=new Set(["this"]),nf.availableArgs=new Set(["this"]);var SA=nf,af=class af extends d{constructor(e={}){super(e)}};n(af,"AlterSortKeyExpr"),af.key="alterSortKey",af.requiredArgs=new Set,af.availableArgs=new Set(["this","expressions","compound"]);var RA=af,of=class of extends d{constructor(e={}){super(e)}};n(of,"AlterSetExpr"),of.key="alterSet",of.requiredArgs=new Set,of.availableArgs=new Set(["expressions","option","tablespace","accessMethod","fileFormat","copyOptions","tag","location","serde"]);var Sy=of,cf=class cf extends d{constructor(e={}){super(e)}};n(cf,"RenameColumnExpr"),cf.key="renameColumn",cf.requiredArgs=new Set(["this","to"]),cf.availableArgs=new Set(["this","to","exists"]);var vA=cf,pf=class pf extends d{constructor(e={}){super(e)}};n(pf,"AlterRenameExpr"),pf.key="alterRename",pf.requiredArgs=new Set(["this"]),pf.availableArgs=new Set(["this"]);var Yn=pf,lf=class lf extends d{constructor(e={}){super(e)}};n(lf,"AlterModifySqlSecurityExpr"),lf.key="alterModifySqlSecurity",lf.requiredArgs=new Set(["expressions"]),lf.availableArgs=new Set(["expressions"]);var eq=lf,uf=class uf extends d{constructor(e={}){super(e)}};n(uf,"SwapTableExpr"),uf.key="swapTable",uf.requiredArgs=new Set(["this"]),uf.availableArgs=new Set(["this"]);var Kl=uf,hf=class hf extends d{constructor(e={}){super(e)}};n(hf,"CommentExpr"),hf.key="comment",hf.requiredArgs=new Set(["this","kind","expression"]),hf.availableArgs=new Set(["this","kind","expression","exists","materialized"]);var Ry=hf,gf=class gf extends d{constructor(e={}){super(e)}};n(gf,"ComprehensionExpr"),gf.key="comprehension",gf.requiredArgs=new Set(["this","expression","iterator"]),gf.availableArgs=new Set(["this","expression","position","iterator","condition"]);var Oy=gf,Ef=class Ef extends d{constructor(e={}){super(e)}};n(Ef,"MergeTreeTtlActionExpr"),Ef.key="mergeTreeTtlAction",Ef.requiredArgs=new Set(["this"]),Ef.availableArgs=new Set(["this","delete","recompress","toDisk","toVolume"]);var In=Ef,Af=class Af extends d{constructor(e={}){super(e)}};n(Af,"MergeTreeTtlExpr"),Af.key="mergeTreeTtl",Af.requiredArgs=new Set(["expressions"]),Af.availableArgs=new Set(["expressions","where","group","aggregates"]);var Pn=Af,df=class df extends d{constructor(e={}){super(e)}};n(df,"IndexConstraintOptionExpr"),df.key="indexConstraintOption",df.requiredArgs=new Set,df.availableArgs=new Set(["keyBlockSize","using","parser","comment","visible","engineAttr","secondaryEngineAttr"]);var tq=df,ff=class ff extends d{constructor(e={}){super(e)}get kind(){return this.args.kind}};n(ff,"ColumnConstraintExpr"),ff.key="columnConstraint",ff.requiredArgs=new Set(["kind"]),ff.availableArgs=new Set(["this","kind"]);var yn=ff,xf=class xf extends d{constructor(e={}){super(e)}};n(xf,"ColumnConstraintKindExpr"),xf.key="columnConstraintKind",xf.requiredArgs=new Set(["this"]),xf.availableArgs=new Set(["this"]);var oe=xf,Tf=class Tf extends d{constructor(e={}){super(e)}};n(Tf,"WithOperatorExpr"),Tf.key="withOperator",Tf.requiredArgs=new Set(["this","op"]),Tf.availableArgs=new Set(["this","op"]);var eu=Tf,Sf=class Sf extends d{constructor(e={}){super(e)}};n(Sf,"WatermarkColumnConstraintExpr"),Sf.key="watermarkColumnConstraint",Sf.requiredArgs=new Set(["this","expression"]),Sf.availableArgs=new Set(["this","expression"]);var sq=Sf,Rf=class Rf extends d{constructor(e={}){super(e)}};n(Rf,"ConstraintExpr"),Rf.key="constraint",Rf.requiredArgs=new Set(["this","expressions"]),Rf.availableArgs=new Set(["this","expressions"]);var my=Rf,Of=class Of extends bs{constructor(e={}){super(e)}delete(e,t={}){let{copy:s=!0,...r}=t;return JE(e,{instance:this,arg:"this",into:_,...r,copy:s})}where(e,t={}){let{append:s=!0,copy:r=!0,...i}=t;return vI(Array.from(J(e)),{instance:this,arg:"where",into:St,...i,append:s,copy:r})}};n(Of,"DeleteExpr"),Of.key="delete",Of.requiredArgs=new Set,Of.availableArgs=new Set(["with","this","using","where","returning","order","limit","tables","cluster"]);var Gr=Of,mf=class mf extends d{constructor(e={}){super(e)}get kind(){return this.args.kind}};n(mf,"DropExpr"),mf.key="drop",mf.requiredArgs=new Set,mf.availableArgs=new Set(["this","kind","expressions","exists","temporary","materialized","cascade","restrict","constraints","purge","cluster","concurrently","sync","iceberg"]);var tu=mf,Nf=class Nf extends d{constructor(e={}){super(e)}};n(Nf,"ExportExpr"),Nf.key="export",Nf.requiredArgs=new Set(["this","options"]),Nf.availableArgs=new Set(["this","connection","options"]);var rq=Nf,If=class If extends d{constructor(e={}){super(e)}};n(If,"FilterExpr"),If.key="filter",If.requiredArgs=new Set(["this","expression"]),If.availableArgs=new Set(["this","expression"]);var Xr=If,yf=class yf extends d{constructor(e={}){super(e)}};n(yf,"CheckExpr"),yf.key="check",yf.requiredArgs=new Set(["this"]),yf.availableArgs=new Set(["this"]);var iq=yf,Cf=class Cf extends d{constructor(e={}){super(e)}};n(Cf,"ChangesExpr"),Cf.key="changes",Cf.requiredArgs=new Set(["information"]),Cf.availableArgs=new Set(["information","atBefore","end"]);var Ny=Cf,bf=class bf extends d{constructor(e={}){super(e)}};n(bf,"ConnectExpr"),bf.key="connect",bf.requiredArgs=new Set(["connect"]),bf.availableArgs=new Set(["start","connect","nocycle"]);var Iy=bf,Pf=class Pf extends d{constructor(e={}){super(e)}};n(Pf,"CopyParameterExpr"),Pf.key="copyParameter",Pf.requiredArgs=new Set(["this"]),Pf.availableArgs=new Set(["this","expression","expressions"]);var yy=Pf,Lf=class Lf extends d{constructor(e={}){super(e)}};n(Lf,"CredentialsExpr"),Lf.key="credentials",Lf.requiredArgs=new Set,Lf.availableArgs=new Set(["credentials","encryption","storage","iamRole","region"]);var Cy=Lf,wf=class wf extends d{constructor(e={}){super(e)}};n(wf,"PriorExpr"),wf.key="prior",wf.requiredArgs=new Set(["this"]),wf.availableArgs=new Set(["this"]);var by=wf,Mf=class Mf extends d{constructor(e={}){super(e)}};n(Mf,"DirectoryExpr"),Mf.key="directory",Mf.requiredArgs=new Set(["this"]),Mf.availableArgs=new Set(["this","local","rowFormat"]);var su=Mf,kf=class kf extends d{constructor(e={}){super(e)}};n(kf,"DirectoryStageExpr"),kf.key="directoryStage",kf.requiredArgs=new Set(["this"]),kf.availableArgs=new Set(["this"]);var nq=kf,Df=class Df extends d{constructor(e={}){super(e)}};n(Df,"ForeignKeyExpr"),Df.key="foreignKey",Df.requiredArgs=new Set,Df.availableArgs=new Set(["expressions","reference","delete","update","options"]);var Py=Df,qf=class qf extends d{constructor(e={}){super(e)}};n(qf,"ColumnPrefixExpr"),qf.key="columnPrefix",qf.requiredArgs=new Set(["this","expression"]),qf.availableArgs=new Set(["this","expression"]);var aq=qf,Uf=class Uf extends d{constructor(e={}){super(e)}};n(Uf,"PrimaryKeyExpr"),Uf.key="primaryKey",Uf.requiredArgs=new Set(["expressions"]),Uf.availableArgs=new Set(["this","expressions","options","include"]);var ru=Uf,vf=class vf extends d{constructor(e={}){super(e)}};n(vf,"IntoExpr"),vf.key="into",vf.requiredArgs=new Set,vf.availableArgs=new Set(["this","temporary","unlogged","bulkCollect","expressions"]);var iu=vf,Ff=class Ff extends d{constructor(e={}){super(e)}get name(){return this.args.this?.name||""}get aliasOrName(){return this.args.this?.aliasOrName??""}};n(Ff,"FromExpr"),Ff.key="from",Ff.requiredArgs=new Set(["this"]),Ff.availableArgs=new Set(["this"]);var rt=Ff,Bf=class Bf extends d{constructor(e={}){super(e)}};n(Bf,"HavingExpr"),Bf.key="having",Bf.requiredArgs=new Set(["this"]),Bf.availableArgs=new Set(["this"]);var ds=Bf,$f=class $f extends d{constructor(e={}){super(e)}};n($f,"HintExpr"),$f.key="hint",$f.requiredArgs=new Set(["expressions"]),$f.availableArgs=new Set(["expressions"]);var Ps=$f,Gf=class Gf extends d{constructor(e={}){super(e)}};n(Gf,"JoinHintExpr"),Gf.key="joinHint",Gf.requiredArgs=new Set(["this","expressions"]),Gf.availableArgs=new Set(["this","expressions"]);var gn=Gf,Yf=class Yf extends d{constructor(e={}){super(e)}get outputName(){return this.name}get quoted(){return!!this.args.quoted}};n(Yf,"IdentifierExpr"),Yf.key="identifier",Yf.requiredArgs=new Set(["this"]),Yf.availableArgs=new Set(["this","quoted","global","temporary"]);var v=Yf,Vf=class Vf extends d{constructor(e={}){super(e)}};n(Vf,"OpclassExpr"),Vf.key="opclass",Vf.requiredArgs=new Set(["this","expression"]),Vf.availableArgs=new Set(["this","expression"]);var Ly=Vf,Hf=class Hf extends d{constructor(e={}){super(e)}};n(Hf,"IndexExpr"),Hf.key="index",Hf.requiredArgs=new Set,Hf.availableArgs=new Set(["this","table","unique","primary","amp","params"]);var wy=Hf,_f=class _f extends d{constructor(e={}){super(e)}};n(_f,"IndexParametersExpr"),_f.key="indexParameters",_f.requiredArgs=new Set,_f.availableArgs=new Set(["using","include","columns","withStorage","partitionBy","tablespace","where","on"]);var My=_f,Wf=class Wf extends d{constructor(e={}){super(e)}};n(Wf,"ConditionalInsertExpr"),Wf.key="conditionalInsert",Wf.requiredArgs=new Set(["this"]),Wf.availableArgs=new Set(["this","expression","else"]);var ky=Wf,jf=class jf extends d{constructor(e={}){super(e)}};n(jf,"MultitableInsertsExpr"),jf.key="multitableInserts",jf.requiredArgs=new Set(["expressions","kind","source"]),jf.availableArgs=new Set(["expressions","kind","source"]);var nu=jf,Xf=class Xf extends d{constructor(e={}){super(e)}};n(Xf,"OnConflictExpr"),Xf.key="onConflict",Xf.requiredArgs=new Set,Xf.availableArgs=new Set(["duplicate","expressions","action","conflictKeys","indexPredicate","constraint","where"]);var Dy=Xf,Jf=class Jf extends d{constructor(e={}){super(e)}};n(Jf,"OnConditionExpr"),Jf.key="onCondition",Jf.requiredArgs=new Set,Jf.availableArgs=new Set(["error","empty","null"]);var qy=Jf,zf=class zf extends d{constructor(e={}){super(e)}};n(zf,"ReturningExpr"),zf.key="returning",zf.requiredArgs=new Set(["expressions"]),zf.availableArgs=new Set(["expressions","into"]);var FA=zf,Qf=class Qf extends d{constructor(e={}){super(e)}};n(Qf,"IntroducerExpr"),Qf.key="introducer",Qf.requiredArgs=new Set(["this","expression"]),Qf.availableArgs=new Set(["this","expression"]);var Uy=Qf,Zf=class Zf extends d{constructor(e={}){super(e)}};n(Zf,"NationalExpr"),Zf.key="national",Zf.requiredArgs=new Set(["this"]),Zf.availableArgs=new Set(["this"]);var vy=Zf,Kf=class Kf extends d{constructor(e={}){super(e)}};n(Kf,"LoadDataExpr"),Kf.key="loadData",Kf.requiredArgs=new Set(["this","inpath"]),Kf.availableArgs=new Set(["this","local","overwrite","inpath","partition","inputFormat","serde"]);var Fy=Kf,ex=class ex extends d{constructor(e={}){super(e)}};n(ex,"PartitionExpr"),ex.key="partition",ex.requiredArgs=new Set(["expressions"]),ex.availableArgs=new Set(["expressions","subpartition"]);var By=ex,tx=class tx extends d{constructor(e={}){super(e)}};n(tx,"PartitionRangeExpr"),tx.key="partitionRange",tx.requiredArgs=new Set(["this"]),tx.availableArgs=new Set(["this","expression","expressions"]);var oq=tx,sx=class sx extends d{constructor(e={}){super(e)}};n(sx,"PartitionIdExpr"),sx.key="partitionId",sx.requiredArgs=new Set(["this"]),sx.availableArgs=new Set(["this"]);var cq=sx,rx=class rx extends d{constructor(e={}){super(e)}};n(rx,"FetchExpr"),rx.key="fetch",rx.requiredArgs=new Set,rx.availableArgs=new Set(["direction","count","limitOptions"]);var hr=rx,ix=class ix extends d{constructor(e={}){super(e)}};n(ix,"GrantExpr"),ix.key="grant",ix.requiredArgs=new Set(["privileges","securable","principals"]),ix.availableArgs=new Set(["privileges","kind","securable","principals","grantOption"]);var $y=ix,nx=class nx extends d{constructor(e={}){super(e)}};n(nx,"RevokeExpr"),nx.key="revoke",nx.requiredArgs=new Set(["privileges","securable","principals"]),nx.availableArgs=new Set(["privileges","kind","securable","principals","grantOption","cascade"]);var Gy=nx,ax=class ax extends d{constructor(e={}){super(e)}};n(ax,"GroupExpr"),ax.key="group",ax.requiredArgs=new Set,ax.availableArgs=new Set(["expressions","groupingSets","cube","rollup","totals","all"]);var Yr=ax,ox=class ox extends d{constructor(e={}){super(e)}};n(ox,"CubeExpr"),ox.key="cube",ox.requiredArgs=new Set,ox.availableArgs=new Set(["expressions"]);var Yy=ox,cx=class cx extends d{constructor(e={}){super(e)}};n(cx,"RollupExpr"),cx.key="rollup",cx.requiredArgs=new Set,cx.availableArgs=new Set(["expressions"]);var OA=cx,px=class px extends d{constructor(e={}){super(e)}};n(px,"GroupingSetsExpr"),px.key="groupingSets",px.requiredArgs=new Set(["expressions"]),px.availableArgs=new Set(["expressions"]);var Vy=px,lx=class lx extends d{constructor(e={}){super(e)}};n(lx,"LambdaExpr"),lx.key="lambda",lx.requiredArgs=new Set(["this","expressions"]),lx.availableArgs=new Set(["this","expressions","colon"]);var ps=lx,ux=class ux extends d{constructor(e={}){super(e)}};n(ux,"LimitExpr"),ux.key="limit",ux.requiredArgs=new Set(["expression"]),ux.availableArgs=new Set(["this","expression","offset","limitOptions","expressions"]);var kt=ux,hx=class hx extends d{constructor(e={}){super(e)}};n(hx,"LimitOptionsExpr"),hx.key="limitOptions",hx.requiredArgs=new Set,hx.availableArgs=new Set(["percent","rows","withTies"]);var Hy=hx,gx=class gx extends d{constructor(e={}){super(e)}on(e,t={}){let{append:s,dialect:r,copy:i,...o}=t,c=Array.from(J(e)),p=vI(c,{instance:this,arg:"on",append:s,dialect:r,copy:i,...o});return p.args.kind==="cross"&&p.setArgKey("kind",void 0),p}using(e,t={}){let{append:s,dialect:r,copy:i,...o}=t,c=Array.from(J(e)),p=Hh(c,{instance:this,arg:"using",append:s,dialect:r,copy:i,...o});return p.args.kind==="cross"&&p.setArgKey("kind",void 0),p}get method(){return this.text("method").toUpperCase()}get kind(){return this.text("kind").toUpperCase()}get side(){return this.text("side").toUpperCase()}get hint(){return this.text("hint").toUpperCase()}get aliasOrName(){return this.args.this?.aliasOrName??""}get isSemiOrAntiJoin(){return this.args.kind!==void 0&&["semi","anti"].includes(this.args.kind)}};n(gx,"JoinExpr"),gx.key="join",gx.requiredArgs=new Set(["this"]),gx.availableArgs=new Set(["this","on","side","kind","using","method","global","hint","matchCondition","directed","expressions","pivots"]);var xe=gx,Ex=class Ex extends d{constructor(e={}){super(e)}};n(Ex,"MatchRecognizeMeasureExpr"),Ex.key="matchRecognizeMeasure",Ex.requiredArgs=new Set(["this"]),Ex.availableArgs=new Set(["this","windowFrame"]);var _y=Ex,Ax=class Ax extends d{constructor(e={}){super(e)}};n(Ax,"MatchRecognizeExpr"),Ax.key="matchRecognize",Ax.requiredArgs=new Set,Ax.availableArgs=new Set(["partitionBy","order","measures","rows","after","pattern","define","alias"]);var Wy=Ax,dx=class dx extends d{constructor(e={}){super(e)}};n(dx,"FinalExpr"),dx.key="final",dx.requiredArgs=new Set(["this"]),dx.availableArgs=new Set(["this"]);var HI=dx,fx=class fx extends d{constructor(e={}){super(e)}};n(fx,"OffsetExpr"),fx.key="offset",fx.requiredArgs=new Set(["expression"]),fx.availableArgs=new Set(["this","expression","expressions"]);var Cn=fx,xx=class xx extends d{constructor(e={}){super(e)}};n(xx,"OrderExpr"),xx.key="order",xx.requiredArgs=new Set(["expressions"]),xx.availableArgs=new Set(["this","expressions","siblings"]);var Ie=xx,Tx=class Tx extends d{constructor(e={}){super(e)}};n(Tx,"WithFillExpr"),Tx.key="withFill",Tx.requiredArgs=new Set,Tx.availableArgs=new Set(["from","to","step","interpolate"]);var jy=Tx,Sx=class Sx extends d{constructor(e={}){super(e)}};n(Sx,"SkipJsonColumnExpr"),Sx.key="skipJsonColumn",Sx.requiredArgs=new Set(["expression"]),Sx.availableArgs=new Set(["regexp","expression"]);var Xy=Sx,Rx=class Rx extends d{constructor(e={}){super(e)}get name(){return this.args.this?.name||""}};n(Rx,"OrderedExpr"),Rx.key="ordered",Rx.requiredArgs=new Set(["this","nullsFirst"]),Rx.availableArgs=new Set(["this","desc","nullsFirst","withFill"]);var hs=Rx,Ox=class Ox extends d{constructor(e={}){super(e)}};n(Ox,"PropertyExpr"),Ox.key="property",Ox.requiredArgs=new Set(["this","value"]),Ox.availableArgs=new Set(["this","value"]);var w=Ox,mx=class mx extends d{constructor(e={}){super(e)}};n(mx,"GrantPrivilegeExpr"),mx.key="grantPrivilege",mx.requiredArgs=new Set(["this"]),mx.availableArgs=new Set(["this","expressions"]);var Jy=mx,Nx=class Nx extends d{constructor(e={}){super(e)}};n(Nx,"GrantPrincipalExpr"),Nx.key="grantPrincipal",Nx.requiredArgs=new Set(["this"]),Nx.availableArgs=new Set(["this","kind"]);var zy=Nx,Ix=class Ix extends d{constructor(e={}){super(e)}};n(Ix,"AllowedValuesPropertyExpr"),Ix.key="allowedValuesProperty",Ix.requiredArgs=new Set(["expressions"]),Ix.availableArgs=new Set(["expressions"]);var Vn=Ix,yx=class yx extends d{constructor(e={}){super(e)}};n(yx,"PartitionByRangePropertyDynamicExpr"),yx.key="partitionByRangePropertyDynamic",yx.requiredArgs=new Set(["start","end","every"]),yx.availableArgs=new Set(["this","start","end","every"]);var pq=yx,Cx=class Cx extends d{constructor(e={}){super(e)}};n(Cx,"RollupIndexExpr"),Cx.key="rollupIndex",Cx.requiredArgs=new Set(["this","expressions"]),Cx.availableArgs=new Set(["this","expressions","fromIndex","properties"]);var lq=Cx,bx=class bx extends d{constructor(e={}){super(e)}};n(bx,"PartitionListExpr"),bx.key="partitionList",bx.requiredArgs=new Set(["this","expressions"]),bx.availableArgs=new Set(["this","expressions"]);var uq=bx,Px=class Px extends d{constructor(e={}){super(e)}};n(Px,"PartitionBoundSpecExpr"),Px.key="partitionBoundSpec",Px.requiredArgs=new Set,Px.availableArgs=new Set(["this","expression","fromExpressions","toExpressions"]);var au=Px,Lx=class Lx extends d{constructor(e={}){super(e)}};n(Lx,"QueryTransformExpr"),Lx.key="queryTransform",Lx.requiredArgs=new Set(["expressions","commandScript"]),Lx.availableArgs=new Set(["expressions","commandScript","schema","rowFormatBefore","recordWriter","rowFormatAfter","recordReader"]);var hq=Lx,wx=class wx extends d{constructor(e={}){super(e)}};n(wx,"SemanticViewExpr"),wx.key="semanticView",wx.requiredArgs=new Set(["this"]),wx.availableArgs=new Set(["this","metrics","dimensions","facts","where"]);var gq=wx,Mx=class Mx extends d{constructor(e={}){super(e)}};n(Mx,"LocationExpr"),Mx.key="location",Mx.requiredArgs=new Set,Mx.availableArgs=new Set;var Eq=Mx,kx=class kx extends d{constructor(e={}){super(e)}};n(kx,"QualifyExpr"),kx.key="qualify",kx.requiredArgs=new Set(["this"]),kx.availableArgs=new Set(["this"]);var Xs=kx,Dx=class Dx extends d{constructor(e={}){super(e)}};n(Dx,"InputOutputFormatExpr"),Dx.key="inputOutputFormat",Dx.requiredArgs=new Set,Dx.availableArgs=new Set(["inputFormat","outputFormat"]);var Qy=Dx,qx=class qx extends d{constructor(e={}){super(e)}};n(qx,"ReturnExpr"),qx.key="return",qx.requiredArgs=new Set(["this"]),qx.availableArgs=new Set(["this"]);var ou=qx,Ux=class Ux extends d{constructor(e={}){super(e)}};n(Ux,"ReferenceExpr"),Ux.key="reference",Ux.requiredArgs=new Set(["this"]),Ux.availableArgs=new Set(["this","expressions","options"]);var Zy=Ux,vx=class vx extends d{constructor(e={}){super(e)}in(e,t,s={}){let{copy:r=!0,unnest:i,...o}=s;return new lt({this:$e(this,r),expressions:e?.map(c=>ht(c,{copy:r})),query:t?W(t,{...o,copy:r}):void 0,unnest:i?new Ee({expressions:Array.from(J(i)).map(c=>W(c,{...o,copy:r}))}):void 0})}};n(vx,"TupleExpr"),vx.key="tuple",vx.requiredArgs=new Set,vx.availableArgs=new Set(["expressions"]);var Ze=vx,Nj={match:!1,laterals:!1,joins:!1,connect:!1,pivots:!1,prewhere:!1,where:!1,group:!1,having:!1,qualify:!1,windows:!1,distribute:!1,sort:!1,cluster:!1,order:!1,limit:!1,offset:!1,locks:!1,sample:!1,settings:!1,format:!1,options:!1},Fx=class Fx extends d{constructor(e={}){super(e)}};n(Fx,"QueryOptionExpr"),Fx.key="queryOption",Fx.requiredArgs=new Set(["this"]),Fx.availableArgs=new Set(["this","expression"]);var Aq=Fx,Bx=class Bx extends d{constructor(e={}){super(e)}};n(Bx,"WithTableHintExpr"),Bx.key="withTableHint",Bx.requiredArgs=new Set(["expressions"]),Bx.availableArgs=new Set(["expressions"]);var cu=Bx,$x=class $x extends d{constructor(e={}){super(e)}};n($x,"IndexTableHintExpr"),$x.key="indexTableHint",$x.requiredArgs=new Set(["this"]),$x.availableArgs=new Set(["this","expressions","target"]);var Ky=$x,Gx=class Gx extends d{constructor(e={}){super(e)}};n(Gx,"HistoricalDataExpr"),Gx.key="historicalData",Gx.requiredArgs=new Set(["this","kind","expression"]),Gx.availableArgs=new Set(["this","kind","expression"]);var eC=Gx,Yx=class Yx extends d{constructor(e={}){super(e)}};n(Yx,"PutExpr"),Yx.key="put",Yx.requiredArgs=new Set(["this","target"]),Yx.availableArgs=new Set(["this","target","properties"]);var jA=Yx,Vx=class Vx extends d{constructor(e={}){super(e)}};n(Vx,"GetExpr"),Vx.key="get",Vx.requiredArgs=new Set(["this","target"]),Vx.availableArgs=new Set(["this","target","properties"]);var bb=Vx,Hx=class Hx extends d{constructor(e={}){super(e)}get name(){let e=this.args.this;return!e||e instanceof E?"":e instanceof d?e.name||"":e.toString()}get db(){return this.text("db")}get catalog(){return this.text("catalog")}get selects(){return[]}get namedSelects(){return[]}get parts(){let e=[];for(let t of["catalog","db","this"]){let s=this.args[t];s instanceof ge?e.push(...s.flatten()):s instanceof d&&e.push(s)}return e}toColumn(e={}){let{copy:t=!0}=e,s=this.parts,r=s[s.length-1],i;if(r instanceof v){let c=s.slice(0,4).reverse(),p=s.slice(4);i=$n({col:c[0],table:c[1],db:c[2],catalog:c[3]},{fields:p,copy:t})}else i=r;let o=this.args.alias;if(o){let c=o.args.this,p=typeof c=="string"||Y(c,v)?c:void 0;i=Be(i,p,{copy:t})}return i}};n(Hx,"TableExpr"),Hx.key="table",Hx.requiredArgs=new Set,Hx.availableArgs=new Set(["this","alias","db","catalog","laterals","joins","pivots","hints","systemTime","version","format","pattern","ordinality","when","only","partition","changes","rowsFrom","sample","indexed"]);var _=Hx,_x=class _x extends d{constructor(e={}){super(e)}};n(_x,"VarExpr"),_x.key="var",_x.requiredArgs=new Set(["this"]),_x.availableArgs=new Set(["this"]);var Ve=_x,Wx=class Wx extends d{constructor(e={}){super(e)}};n(Wx,"VersionExpr"),Wx.key="version",Wx.requiredArgs=new Set(["this","kind"]),Wx.availableArgs=new Set(["this","kind","expression"]);var tC=Wx,jx=class jx extends d{constructor(e={}){super(e)}};n(jx,"SchemaExpr"),jx.key="schema",jx.requiredArgs=new Set,jx.availableArgs=new Set(["this","expressions"]);var Rt=jx,Xx=class Xx extends d{constructor(e={}){super(e)}};n(Xx,"LockExpr"),Xx.key="lock",Xx.requiredArgs=new Set(["update"]),Xx.availableArgs=new Set(["update","expressions","wait","key"]);var BA=Xx,Jx=class Jx extends d{constructor(e={}){super(e)}};n(Jx,"TableSampleExpr"),Jx.key="tableSample",Jx.requiredArgs=new Set,Jx.availableArgs=new Set(["expressions","method","bucketNumerator","bucketDenominator","bucketField","percent","rows","size","seed"]);var sC=Jx,rw=class rw extends d{constructor(e={}){super(e)}get this(){return this.args.this}};n(rw,"TagExpr"),rw.key="tag",rw.availableArgs=new Set(["this","prefix","postfix"]);var dq=rw,zx=class zx extends d{constructor(e={}){super(e)}get unpivot(){return!!this.args.unpivot}get fields(){return this.args.fields||[]}};n(zx,"PivotExpr"),zx.key="pivot",zx.requiredArgs=new Set([]),zx.availableArgs=new Set(["this","alias","expressions","fields","unpivot","using","group","columns","includeNulls","defaultOnNull","into","with"]);var Ln=zx,Qx=class Qx extends d{constructor(e={}){super(e)}};n(Qx,"UnpivotColumnsExpr"),Qx.key="unpivotColumns",Qx.requiredArgs=new Set(["this","expressions"]),Qx.availableArgs=new Set(["this","expressions"]);var rC=Qx,Zx=class Zx extends d{constructor(e={}){super(e)}};n(Zx,"WindowSpecExpr"),Zx.key="windowSpec",Zx.requiredArgs=new Set,Zx.availableArgs=new Set(["kind","start","startSide","end","endSide","exclude"]);var pu=Zx,Kx=class Kx extends d{constructor(e={}){super(e)}};n(Kx,"PreWhereExpr"),Kx.key="preWhere",Kx.requiredArgs=new Set(["this"]),Kx.availableArgs=new Set(["this"]);var iC=Kx,eT=class eT extends d{constructor(e={}){super(e)}};n(eT,"WhereExpr"),eT.key="where",eT.requiredArgs=new Set(["this"]),eT.availableArgs=new Set(["this"]);var St=eT,tT=class tT extends d{constructor(e={}){super(e)}get name(){return"*"}get outputName(){return this.name}};n(tT,"StarExpr"),tT.key="star",tT.requiredArgs=new Set,tT.availableArgs=new Set(["except","replace","rename"]);var Ne=tT,sT=class sT extends d{constructor(e={}){super(e)}get name(){return this.args.this?.name??""}};n(sT,"DataTypeParamExpr"),sT.key="dataTypeParam",sT.requiredArgs=new Set(["this"]),sT.availableArgs=new Set(["this","expression"]);var Jr=sT,Oe=class Oe extends d{constructor(e={}){super(e)}static build(e,t={}){let{udt:s=!1,copy:r=!0,dialect:i,...o}=t,c;if(typeof e=="string"){if(e==="unknown")return new Oe({...o,this:"unknown"});if(Object.values(At).includes(e))return new Oe({...o,this:e});try{c=mD(e,{read:i,into:Oe,errorLevel:0})}catch(h){if(h instanceof Ke){if(s)return new Oe({this:"user-defined",kind:e,...o});throw h}else throw h}}else{if((e instanceof v||e instanceof ge)&&s)return new Oe({...o,this:"user-defined",kind:e});if(e instanceof Oe)return $e(e,r);throw new Error(`Invalid data type: ${typeof e}. Expected string, DataTypeExprKind, or DataTypeExpr`)}for(let[p,u]of Object.entries(o))c?.setArgKey(p,u);return c}toString(){let e=this.args.this;return e===void 0?super.toString():e instanceof d?e.toString():String(e)}isType(e,t){let s=t?.checkNullable??!1,r=this.args.nullable;for(let i of J(e)){let o=Oe.build(i,{copy:!1,udt:!0}),c=o?.args.nullable,p;if(o?.args.expressions||s&&(r||c)||this.args.this==="user-defined"||o?.args.this==="user-defined"?p=this.equals(o):p=this.args.this===o?.args.this,p)return!0}return!1}};n(Oe,"DataTypeExpr"),Oe.key="dataType",Oe.requiredArgs=new Set(["this"]),Oe.availableArgs=new Set(["this","expressions","nested","values","prefix","kind","nullable"]),Oe.STRUCT_TYPES=new Set(["file","nested","object","struct","union"]),Oe.ARRAY_TYPES=new Set(["array","list"]),Oe.NESTED_TYPES=new Set([...Oe.STRUCT_TYPES,...Oe.ARRAY_TYPES,"map"]),Oe.TEXT_TYPES=new Set(["char","nchar","nvarchar","text","varchar","name"]),Oe.SIGNED_INTEGER_TYPES=new Set(["bigint","int","int128","int256","mediumint","smallint","tinyint"]),Oe.UNSIGNED_INTEGER_TYPES=new Set(["ubigint","uint","uint128","uint256","umediumint","usmallint","utinyint"]),Oe.INTEGER_TYPES=new Set([...Oe.SIGNED_INTEGER_TYPES,...Oe.UNSIGNED_INTEGER_TYPES,"bit"]),Oe.FLOAT_TYPES=new Set(["double","float"]),Oe.REAL_TYPES=new Set([...Oe.FLOAT_TYPES,"bigdecimal","decimal","decimal32","decimal64","decimal128","decimal256","decfloat","money","smallmoney","udecimal","udouble"]),Oe.NUMERIC_TYPES=new Set([...Oe.INTEGER_TYPES,...Oe.REAL_TYPES]),Oe.TEMPORAL_TYPES=new Set(["date","date32","datetime","datetime2","datetime64","smalldatetime","time","timestamp","timestampntz","timestampltz","timestamptz","timestampMs","timestampNs","timestampS","timetz"]);var m=Oe,rT=class rT extends d{constructor(e={}){super(e)}};n(rT,"TypeExpr"),rT.key="type",rT.requiredArgs=new Set,rT.availableArgs=new Set;var fq=rT,iT=class iT extends d{constructor(e={}){super(e)}};n(iT,"CommandExpr"),iT.key="command",iT.requiredArgs=new Set(["this"]),iT.availableArgs=new Set(["this","expression"]);var $r=iT,nT=class nT extends d{constructor(e={}){super(e)}};n(nT,"TransactionExpr"),nT.key="transaction",nT.requiredArgs=new Set,nT.availableArgs=new Set(["this","modes","mark"]);var nC=nT,aT=class aT extends d{constructor(e={}){super(e)}};n(aT,"CommitExpr"),aT.key="commit",aT.requiredArgs=new Set,aT.availableArgs=new Set(["chain","this","durability"]);var aC=aT,oT=class oT extends d{constructor(e={}){super(e)}};n(oT,"RollbackExpr"),oT.key="rollback",oT.requiredArgs=new Set,oT.availableArgs=new Set(["savepoint","this"]);var oC=oT,cT=class cT extends d{constructor(e={}){super(e)}get kind(){let e=this.args.kind;return e?e.toUpperCase():void 0}get actions(){return this.args.actions||[]}};n(cT,"AlterExpr"),cT.key="alter",cT.requiredArgs=new Set(["kind","actions"]),cT.availableArgs=new Set(["this","kind","actions","exists","only","options","cluster","notValid","check","cascade","iceberg"]);var lu=cT,pT=class pT extends d{constructor(e={}){super(e)}};n(pT,"AlterSessionExpr"),pT.key="alterSession",pT.requiredArgs=new Set(["expressions"]),pT.availableArgs=new Set(["expressions","unset"]);var mA=pT,lT=class lT extends d{constructor(e={}){super(e)}};n(lT,"AnalyzeExpr"),lT.key="analyze",lT.requiredArgs=new Set,lT.availableArgs=new Set(["kind","this","options","mode","partition","expression","properties"]);var NA=lT,uT=class uT extends d{constructor(e={}){super(e)}};n(uT,"AnalyzeStatisticsExpr"),uT.key="analyzeStatistics",uT.requiredArgs=new Set(["kind"]),uT.availableArgs=new Set(["kind","option","this","expressions"]);var cC=uT,hT=class hT extends d{constructor(e={}){super(e)}};n(hT,"AnalyzeHistogramExpr"),hT.key="analyzeHistogram",hT.requiredArgs=new Set(["this","expressions"]),hT.availableArgs=new Set(["this","expressions","expression","updateOptions"]);var pC=hT,gT=class gT extends d{constructor(e={}){super(e)}};n(gT,"AnalyzeSampleExpr"),gT.key="analyzeSample",gT.requiredArgs=new Set(["kind","sample"]),gT.availableArgs=new Set(["kind","sample"]);var lC=gT,ET=class ET extends d{constructor(e={}){super(e)}};n(ET,"AnalyzeListChainedRowsExpr"),ET.key="analyzeListChainedRows",ET.requiredArgs=new Set,ET.availableArgs=new Set(["expression"]);var uC=ET,AT=class AT extends d{constructor(e={}){super(e)}};n(AT,"AnalyzeDeleteExpr"),AT.key="analyzeDelete",AT.requiredArgs=new Set,AT.availableArgs=new Set(["kind"]);var hC=AT,dT=class dT extends d{constructor(e={}){super(e)}};n(dT,"AnalyzeWithExpr"),dT.key="analyzeWith",dT.requiredArgs=new Set(["expressions"]),dT.availableArgs=new Set(["expressions"]);var uu=dT,fT=class fT extends d{constructor(e={}){super(e)}};n(fT,"AnalyzeValidateExpr"),fT.key="analyzeValidate",fT.requiredArgs=new Set(["kind"]),fT.availableArgs=new Set(["kind","this","expression"]);var gC=fT,xT=class xT extends d{constructor(e={}){super(e)}};n(xT,"AnalyzeColumnsExpr"),xT.key="analyzeColumns",xT.requiredArgs=new Set(["this"]),xT.availableArgs=new Set(["this"]);var hu=xT,TT=class TT extends d{constructor(e={}){super(e)}};n(TT,"UsingDataExpr"),TT.key="usingData",TT.requiredArgs=new Set(["this"]),TT.availableArgs=new Set(["this"]);var gu=TT,ST=class ST extends d{constructor(e={}){super(e)}};n(ST,"AddConstraintExpr"),ST.key="addConstraint",ST.requiredArgs=new Set(["expressions"]),ST.availableArgs=new Set(["expressions"]);var EC=ST,RT=class RT extends d{constructor(e={}){super(e)}};n(RT,"AddPartitionExpr"),RT.key="addPartition",RT.requiredArgs=new Set(["this"]),RT.availableArgs=new Set(["this","exists","location"]);var AC=RT,OT=class OT extends d{constructor(e={}){super(e)}};n(OT,"AttachOptionExpr"),OT.key="attachOption",OT.requiredArgs=new Set(["this"]),OT.availableArgs=new Set(["this","expression"]);var xq=OT,mT=class mT extends d{constructor(e={}){super(e)}};n(mT,"DropPartitionExpr"),mT.key="dropPartition",mT.requiredArgs=new Set(["expressions"]),mT.availableArgs=new Set(["expressions","exists"]);var dC=mT,NT=class NT extends d{constructor(e={}){super(e)}};n(NT,"ReplacePartitionExpr"),NT.key="replacePartition",NT.requiredArgs=new Set(["expression","source"]),NT.availableArgs=new Set(["expression","source"]);var Tq=NT,IT=class IT extends d{constructor(e={}){super(e)}get outputName(){return typeof this.args.alias=="string"?this.args.alias:this.args.alias?.name??""}};n(IT,"AliasExpr"),IT.key="alias",IT.requiredArgs=new Set(["this"]),IT.availableArgs=new Set(["this","alias"]);var Re=IT,yT=class yT extends d{constructor(e={}){super(e)}};n(yT,"PivotAnyExpr"),yT.key="pivotAny",yT.requiredArgs=new Set,yT.availableArgs=new Set(["this"]);var wn=yT,CT=class CT extends d{constructor(e={}){super(e)}get aliases(){return this.args.expressions??[]}};n(CT,"AliasesExpr"),CT.key="aliases",CT.requiredArgs=new Set(["this","expressions"]),CT.availableArgs=new Set(["this","expressions"]);var Hn=CT,bT=class bT extends d{constructor(e={}){super(e)}};n(bT,"AtIndexExpr"),bT.key="atIndex",bT.requiredArgs=new Set(["this","expression"]),bT.availableArgs=new Set(["this","expression"]);var fC=bT,PT=class PT extends d{constructor(e={}){super(e)}};n(PT,"AtTimeZoneExpr"),PT.key="atTimeZone",PT.requiredArgs=new Set(["this","zone"]),PT.availableArgs=new Set(["this","zone"]);var gs=PT,LT=class LT extends d{constructor(e={}){super(e)}};n(LT,"FromTimeZoneExpr"),LT.key="fromTimeZone",LT.requiredArgs=new Set(["this","zone"]),LT.availableArgs=new Set(["this","zone"]);var Sq=LT,wT=class wT extends d{constructor(e={}){super(e)}};n(wT,"FormatPhraseExpr"),wT.key="formatPhrase",wT.requiredArgs=new Set(["this","format"]),wT.availableArgs=new Set(["this","format"]);var Rq=wT,MT=class MT extends d{constructor(e={}){super(e)}};n(MT,"DistinctExpr"),MT.key="distinct",MT.requiredArgs=new Set,MT.availableArgs=new Set(["expressions","on"]);var et=MT,kT=class kT extends d{constructor(e={}){super(e)}};n(kT,"ForInExpr"),kT.key="forIn",kT.requiredArgs=new Set(["this","expression"]),kT.availableArgs=new Set(["this","expression"]);var Oq=kT,ui=class ui extends d{static isVarLike(e){return e instanceof Ve||e instanceof $||e instanceof N}static initTimeArgs(e){let t=e.unit;if(t&&ui.isVarLike(t)&&!(t instanceof $&&t.parts.length!==1))e.unit=new Ve({this:(ui.UNABBREVIATED_UNIT_NAME[t.name.toUpperCase()]||t.name).toUpperCase()});else if(t instanceof Ed){let s=t.args.this;s&&t.setArgKey("this",new Ve({this:s.name.toUpperCase()}))}return e}constructor(e={}){super(ui.initTimeArgs(e))}get unit(){return this.args.unit}};n(ui,"TimeUnitExpr"),ui.key="timeUnit",ui.availableArgs=new Set(["unit"]),ui.UNABBREVIATED_UNIT_NAME={D:"DAY",H:"HOUR",M:"MINUTE",MS:"MILLISECOND",NS:"NANOSECOND",Q:"QUARTER",S:"SECOND",US:"MICROSECOND",W:"WEEK",Y:"YEAR"};var te=ui,DT=class DT extends d{constructor(e={}){super(e)}};n(DT,"IgnoreNullsExpr"),DT.key="ignoreNulls",DT.requiredArgs=new Set(["this"]),DT.availableArgs=new Set(["this"]);var IA=DT,qT=class qT extends d{constructor(e={}){super(e)}};n(qT,"RespectNullsExpr"),qT.key="respectNulls",qT.requiredArgs=new Set(["this"]),qT.availableArgs=new Set(["this"]);var yA=qT,UT=class UT extends d{constructor(e={}){super(e)}};n(UT,"HavingMaxExpr"),UT.key="havingMax",UT.requiredArgs=new Set(["this","expression","max"]),UT.availableArgs=new Set(["this","expression","max"]);var gr=UT,vT=class vT extends d{constructor(e={}){super(e)}};n(vT,"TranslateCharactersExpr"),vT.key="translateCharacters",vT.requiredArgs=new Set(["this","expression"]),vT.availableArgs=new Set(["this","expression","withError"]);var mq=vT,FT=class FT extends d{constructor(e={}){super(e)}};n(FT,"PositionalColumnExpr"),FT.key="positionalColumn",FT.requiredArgs=new Set(["this"]),FT.availableArgs=new Set(["this"]);var Pb=FT,BT=class BT extends d{constructor(e={}){super(e)}};n(BT,"OverflowTruncateBehaviorExpr"),BT.key="overflowTruncateBehavior",BT.requiredArgs=new Set(["withCount"]),BT.availableArgs=new Set(["this","withCount"]);var xC=BT,$T=class $T extends d{constructor(e={}){super(e)}};n($T,"JsonExpr"),$T.key="json",$T.requiredArgs=new Set,$T.availableArgs=new Set(["this","with","unique"]);var TC=$T,GT=class GT extends d{constructor(e={}){super(e)}get outputName(){let t=this.args.expressions?.[this.args.expressions.length-1]?.args.this;return typeof t=="string"?t:""}};n(GT,"JsonPathExpr"),GT.key="jsonPath",GT.requiredArgs=new Set(["expressions"]),GT.availableArgs=new Set(["expressions","escape"]);var Er=GT,YT=class YT extends d{constructor(e={}){super(e)}};n(YT,"JsonPathPartExpr"),YT.key="jsonPathPart",YT.requiredArgs=new Set,YT.availableArgs=new Set;var qt=YT,VT=class VT extends d{constructor(e={}){super(e)}};n(VT,"FormatJsonExpr"),VT.key="formatJson",VT.requiredArgs=new Set(["this"]),VT.availableArgs=new Set(["this"]);var SC=VT,HT=class HT extends d{constructor(e={}){super(e)}};n(HT,"JsonKeyValueExpr"),HT.key="jsonKeyValue",HT.requiredArgs=new Set(["this","expression"]),HT.availableArgs=new Set(["this","expression"]);var RC=HT,_T=class _T extends d{constructor(e={}){super(e)}};n(_T,"JsonColumnDefExpr"),_T.key="jsonColumnDef",_T.requiredArgs=new Set,_T.availableArgs=new Set(["this","kind","path","nestedSchema","ordinality"]);var OC=_T,WT=class WT extends d{constructor(e={}){super(e)}};n(WT,"JsonSchemaExpr"),WT.key="jsonSchema",WT.requiredArgs=new Set(["expressions"]),WT.availableArgs=new Set(["expressions"]);var mC=WT,jT=class jT extends d{constructor(e={}){super(e)}};n(jT,"JsonValueExpr"),jT.key="jsonValue",jT.requiredArgs=new Set(["this","path"]),jT.availableArgs=new Set(["this","path","returning","onCondition"]);var NC=jT,XT=class XT extends d{constructor(e={}){super(e)}};n(XT,"OpenJsonColumnDefExpr"),XT.key="openJsonColumnDef",XT.requiredArgs=new Set(["this","kind"]),XT.availableArgs=new Set(["this","kind","path","asJson"]);var IC=XT,JT=class JT extends d{constructor(e={}){super(e)}};n(JT,"JsonExtractQuoteExpr"),JT.key="jsonExtractQuote",JT.requiredArgs=new Set(["option"]),JT.availableArgs=new Set(["option","scalar"]);var Nq=JT,zT=class zT extends d{constructor(e={}){super(e)}};n(zT,"ScopeResolutionExpr"),zT.key="scopeResolution",zT.requiredArgs=new Set(["expression"]),zT.availableArgs=new Set(["this","expression"]);var CA=zT,QT=class QT extends d{constructor(e={}){super(e)}};n(QT,"SliceExpr"),QT.key="slice",QT.requiredArgs=new Set,QT.availableArgs=new Set(["this","expression","step"]);var On=QT,ZT=class ZT extends d{constructor(e={}){super(e)}};n(ZT,"StreamExpr"),ZT.key="stream",ZT.requiredArgs=new Set(["this"]),ZT.availableArgs=new Set(["this"]);var Eu=ZT,KT=class KT extends d{constructor(e={}){super(e)}};n(KT,"ModelAttributeExpr"),KT.key="modelAttribute",KT.requiredArgs=new Set(["this","expression"]),KT.availableArgs=new Set(["this","expression"]);var Iq=KT,eS=class eS extends d{constructor(e={}){super(e)}};n(eS,"WeekStartExpr"),eS.key="weekStart",eS.requiredArgs=new Set(["this"]),eS.availableArgs=new Set(["this"]);var zL=eS,tS=class tS extends d{constructor(e={}){super(e)}};n(tS,"XmlNamespaceExpr"),tS.key="xmlNamespace",tS.requiredArgs=new Set(["this"]),tS.availableArgs=new Set(["this"]);var yC=tS,sS=class sS extends d{constructor(e={}){super(e)}};n(sS,"XmlKeyValueOptionExpr"),sS.key="xmlKeyValueOption",sS.requiredArgs=new Set(["this"]),sS.availableArgs=new Set(["this","expression"]);var yq=sS,rS=class rS extends d{constructor(e={}){super(e)}};n(rS,"UseExpr"),rS.key="use",rS.requiredArgs=new Set,rS.availableArgs=new Set(["this","expressions","kind"]);var CC=rS,iS=class iS extends d{constructor(e={}){super(e)}};n(iS,"WhenExpr"),iS.key="when",iS.requiredArgs=new Set(["matched","then"]),iS.availableArgs=new Set(["matched","source","condition","then"]);var _n=iS,nS=class nS extends d{constructor(e={}){super(e)}};n(nS,"WhensExpr"),nS.key="whens",nS.requiredArgs=new Set(["expressions"]),nS.availableArgs=new Set(["expressions"]);var Au=nS,aS=class aS extends d{constructor(e={}){super(e)}};n(aS,"SemicolonExpr"),aS.key="semicolon",aS.requiredArgs=new Set,aS.availableArgs=new Set;var bC=aS,oS=class oS extends d{constructor(e={}){super(e)}};n(oS,"TableColumnExpr"),oS.key="tableColumn",oS.requiredArgs=new Set(["this"]),oS.availableArgs=new Set(["this"]);var Gl=oS,cS=class cS extends d{constructor(e={}){super(e)}};n(cS,"VariadicExpr"),cS.key="variadic",cS.requiredArgs=new Set(["this"]),cS.availableArgs=new Set(["this"]);var Lb=cS,pS=class pS extends d{constructor(e={}){super(e)}};n(pS,"StoredProcedureExpr"),pS.key="storedProcedure",pS.requiredArgs=new Set(["this"]),pS.availableArgs=new Set(["this","expressions","wrapped"]);var Cq=pS,lS=class lS extends d{constructor(e={}){super(e)}};n(lS,"BlockExpr"),lS.key="block",lS.requiredArgs=new Set(["expressions"]),lS.availableArgs=new Set(["expressions"]);var $A=lS,uS=class uS extends d{constructor(e={}){super(e)}};n(uS,"IfBlockExpr"),uS.key="ifBlock",uS.requiredArgs=new Set(["this","true"]),uS.availableArgs=new Set(["this","true","false"]);var bq=uS,hS=class hS extends d{constructor(e={}){super(e)}};n(hS,"WhileBlockExpr"),hS.key="whileBlock",hS.requiredArgs=new Set(["this","body"]),hS.availableArgs=new Set(["this","body"]);var PC=hS,gS=class gS extends d{constructor(e={}){super(e)}};n(gS,"EndStatementExpr"),gS.key="endStatement",gS.requiredArgs=new Set,gS.availableArgs=new Set;var du=gS,ES=class ES extends d{constructor(e={}){super(e)}get name(){return this.args.this?.args.this?.toString?.()??""}};n(ES,"ExecuteExpr"),ES.key="execute",ES.requiredArgs=new Set(["this"]),ES.availableArgs=new Set(["this","expressions"]);var BM=ES,jM=class jM extends BM{};n(jM,"ExecuteSqlExpr"),jM.key="executeSql";var Pq=jM,AS=class AS extends An{constructor(e={}){super(e)}};n(AS,"CteExpr"),AS.key="cte",AS.requiredArgs=new Set(["this","alias"]),AS.availableArgs=new Set(["this","alias","scalar","materialized","keyExpressions"]);var Ft=AS,XM=class XM extends Ce{constructor(e={}){super(e)}};n(XM,"BitStringExpr"),XM.key="bitString";var LC=XM,iw=class iw extends Ce{constructor(e={}){super(e)}};n(iw,"HexStringExpr"),iw.key="hexString",iw.availableArgs=new Set(["this","isInteger"]);var fu=iw,nw=class nw extends Ce{constructor(e={}){super(e)}};n(nw,"ByteStringExpr"),nw.key="byteString",nw.availableArgs=new Set(["this","isBytes"]);var wC=nw,JM=class JM extends Ce{constructor(e={}){super(e)}};n(JM,"RawStringExpr"),JM.key="rawString";var Mn=JM,aw=class aw extends Ce{constructor(e={}){super(e)}};n(aw,"UnicodeStringExpr"),aw.key="unicodeString",aw.availableArgs=new Set(["this","escape"]);var MC=aw,dS=class dS extends Ce{constructor(e={}){super(e)}get table(){return this.text("table")}get db(){return this.text("db")}get catalog(){return this.text("catalog")}get outputName(){return this.name}get parts(){let e=[];for(let t of["catalog","db","table","this"]){let s=this.args[t];s&&e.push(s)}return e}toDot(e={}){let{includeDots:t=!0}=e,s=this.parts,r=this.parent;if(t)for(;r instanceof ge&&r.args.expression!==void 0;)s.push(r.args.expression),r=r.parent;return 1<s.length?ge.build(s.map(i=>i.copy())):s[0]}};n(dS,"ColumnExpr"),dS.key="column",dS.requiredArgs=new Set(["this"]),dS.availableArgs=new Set(["this","table","db","catalog","joinMark"]);var $=dS,zM=class zM extends ${constructor(e={}){super(e)}};n(zM,"PseudocolumnExpr"),zM.key="pseudocolumn";var _I=zM,QM=class QM extends oe{constructor(e={}){super(e)}};n(QM,"AutoIncrementColumnConstraintExpr"),QM.key="autoIncrementColumnConstraint";var kC=QM,fS=class fS extends yn{constructor(e={}){super(e)}};n(fS,"ZeroFillColumnConstraintExpr"),fS.key="zeroFillColumnConstraint",fS.requiredArgs=new Set,fS.availableArgs=new Set;var wb=fS,xS=class xS extends oe{constructor(e={}){super(e)}};n(xS,"PeriodForSystemTimeConstraintExpr"),xS.key="periodForSystemTimeConstraint",xS.requiredArgs=new Set(["this","expression"]),xS.availableArgs=new Set(["this","expression"]);var DC=xS,TS=class TS extends oe{constructor(e={}){super(e)}};n(TS,"CaseSpecificColumnConstraintExpr"),TS.key="caseSpecificColumnConstraint",TS.requiredArgs=new Set(["not"]),TS.availableArgs=new Set(["not"]);var kn=TS,ZM=class ZM extends oe{constructor(e={}){super(e)}};n(ZM,"CharacterSetColumnConstraintExpr"),ZM.key="characterSetColumnConstraint";var xu=ZM,ow=class ow extends oe{constructor(e={}){super(e)}};n(ow,"CheckColumnConstraintExpr"),ow.key="checkColumnConstraint",ow.availableArgs=new Set(["this","enforced"]);var qC=ow,cw=class cw extends oe{constructor(e={}){super(e)}};n(cw,"AssumeColumnConstraintExpr"),cw.key="assumeColumnConstraint",cw.availableArgs=new Set(["this"]);var Mb=cw,KM=class KM extends oe{constructor(e={}){super(e)}};n(KM,"ClusteredColumnConstraintExpr"),KM.key="clusteredColumnConstraint";var Tu=KM,ek=class ek extends oe{constructor(e={}){super(e)}};n(ek,"CollateColumnConstraintExpr"),ek.key="collateColumnConstraint";var Su=ek,tk=class tk extends oe{constructor(e={}){super(e)}};n(tk,"CommentColumnConstraintExpr"),tk.key="commentColumnConstraint";var Ru=tk,pw=class pw extends oe{constructor(e={}){super(e)}};n(pw,"CompressColumnConstraintExpr"),pw.key="compressColumnConstraint",pw.requiredArgs=new Set;var bA=pw,sk=class sk extends oe{constructor(e={}){super(e)}};n(sk,"DateFormatColumnConstraintExpr"),sk.key="dateFormatColumnConstraint";var Ou=sk,rk=class rk extends oe{constructor(e={}){super(e)}};n(rk,"DefaultColumnConstraintExpr"),rk.key="defaultColumnConstraint";var mu=rk,ik=class ik extends oe{constructor(e={}){super(e)}};n(ik,"EncodeColumnConstraintExpr"),ik.key="encodeColumnConstraint";var Nu=ik,nk=class nk extends oe{constructor(e={}){super(e)}};n(nk,"ExcludeColumnConstraintExpr"),nk.key="excludeColumnConstraint";var Iu=nk,lw=class lw extends oe{constructor(e={}){super(e)}};n(lw,"EphemeralColumnConstraintExpr"),lw.key="ephemeralColumnConstraint",lw.requiredArgs=new Set;var yu=lw,uw=class uw extends oe{constructor(e={}){super(e)}};n(uw,"GeneratedAsIdentityColumnConstraintExpr"),uw.key="generatedAsIdentityColumnConstraint",uw.availableArgs=new Set(["this","expression","onNull","start","increment","minvalue","maxvalue","cycle","order"]);var Jl=uw,SS=class SS extends oe{constructor(e={}){super(e)}};n(SS,"GeneratedAsRowColumnConstraintExpr"),SS.key="generatedAsRowColumnConstraint",SS.requiredArgs=new Set,SS.availableArgs=new Set(["start","hidden"]);var UC=SS,RS=class RS extends oe{constructor(e={}){super(e)}};n(RS,"IndexColumnConstraintExpr"),RS.key="indexColumnConstraint",RS.requiredArgs=new Set,RS.availableArgs=new Set(["this","expressions","kind","indexType","options","expression","granularity"]);var Lq=RS,ak=class ak extends oe{constructor(e={}){super(e)}};n(ak,"InlineLengthColumnConstraintExpr"),ak.key="inlineLengthColumnConstraint";var Cu=ak,ok=class ok extends oe{constructor(e={}){super(e)}};n(ok,"NonClusteredColumnConstraintExpr"),ok.key="nonClusteredColumnConstraint";var bu=ok,OS=class OS extends oe{constructor(e={}){super(e)}};n(OS,"NotForReplicationColumnConstraintExpr"),OS.key="notForReplicationColumnConstraint",OS.requiredArgs=new Set,OS.availableArgs=new Set;var Pu=OS,hw=class hw extends oe{constructor(e={}){super(e)}};n(hw,"MaskingPolicyColumnConstraintExpr"),hw.key="maskingPolicyColumnConstraint",hw.availableArgs=new Set(["this","expressions"]);var wq=hw,mS=class mS extends oe{constructor(e={}){super(e)}};n(mS,"NotNullColumnConstraintExpr"),mS.key="notNullColumnConstraint",mS.requiredArgs=new Set,mS.availableArgs=new Set(["allowNull"]);var PA=mS,ck=class ck extends oe{constructor(e={}){super(e)}};n(ck,"OnUpdateColumnConstraintExpr"),ck.key="onUpdateColumnConstraint";var Lu=ck,NS=class NS extends oe{constructor(e={}){super(e)}};n(NS,"PrimaryKeyColumnConstraintExpr"),NS.key="primaryKeyColumnConstraint",NS.requiredArgs=new Set,NS.availableArgs=new Set(["desc","options"]);var vC=NS,pk=class pk extends oe{constructor(e={}){super(e)}};n(pk,"TitleColumnConstraintExpr"),pk.key="titleColumnConstraint";var wu=pk,IS=class IS extends oe{constructor(e={}){super(e)}};n(IS,"UniqueColumnConstraintExpr"),IS.key="uniqueColumnConstraint",IS.requiredArgs=new Set,IS.availableArgs=new Set(["this","indexType","onConflict","nulls","options"]);var Mu=IS,yS=class yS extends oe{constructor(e={}){super(e)}};n(yS,"UppercaseColumnConstraintExpr"),yS.key="uppercaseColumnConstraint",yS.requiredArgs=new Set,yS.availableArgs=new Set;var ku=yS,lk=class lk extends oe{constructor(e={}){super(e)}};n(lk,"PathColumnConstraintExpr"),lk.key="pathColumnConstraint";var Du=lk,uk=class uk extends oe{constructor(e={}){super(e)}};n(uk,"ProjectionPolicyColumnConstraintExpr"),uk.key="projectionPolicyColumnConstraint";var kb=uk,gw=class gw extends oe{constructor(e={}){super(e)}};n(gw,"ComputedColumnConstraintExpr"),gw.key="computedColumnConstraint",gw.availableArgs=new Set(["this","persisted","notNull","dataType"]);var Dn=gw,CS=class CS extends oe{constructor(e={}){super(e)}};n(CS,"InOutColumnConstraintExpr"),CS.key="inOutColumnConstraint",CS.requiredArgs=new Set,CS.availableArgs=new Set(["input","output","variadic"]);var FC=CS,bS=class bS extends bs{constructor(e={}){super(e)}};n(bS,"CopyExpr"),bS.key="copy",bS.requiredArgs=new Set(["this","kind"]),bS.availableArgs=new Set(["this","kind","files","credentials","format","params"]);var BC=bS,PS=class PS extends V(dn,bs,d){constructor(e={}){super(e)}with(e,t,s={}){let{recursive:r,materialized:i,append:o,dialect:c,copy:p,...u}=s;return z$({instance:this,alias:e,as:t,recursive:r,materialized:i,append:o,dialect:c,copy:p,...u})}};n(PS,"InsertExpr"),PS.key="insert",PS.requiredArgs=new Set,PS.availableArgs=new Set(["hint","with","isFunction","this","expression","conflict","returning","overwrite","exists","alternative","where","ignore","byName","stored","partition","settings","source","default"]);var es=PS,hi=class hi extends Ce{static number(e){let t=new hi({this:String(e),isString:!1}),s=typeof e=="number"?e:parseFloat(String(e));if(!isNaN(s)&&s<0){let r=typeof e=="string"&&e.startsWith("-")?e.slice(1):String(Math.abs(s));t=new hi({this:r,isString:!1}),t=new bt({this:t})}return t}static string(e){return new hi({this:String(e),isString:!0})}constructor(e={}){super(e)}get outputName(){return this.name}toValue(){if(this.isNumber){let e=parseFloat(this.args.this);if(!isNaN(e))return e}return this.args.this}};n(hi,"LiteralExpr"),hi.key="literal",hi.requiredArgs=new Set(["this","isString"]),hi.availableArgs=new Set(["this","isString"]);var N=hi,hk=class hk extends Ie{constructor(e={}){super(e)}};n(hk,"ClusterExpr"),hk.key="cluster";var rr=hk,gk=class gk extends Ie{constructor(e={}){super(e)}};n(gk,"DistributeExpr"),gk.key="distribute";var $C=gk,Ek=class Ek extends Ie{constructor(e={}){super(e)}};n(Ek,"SortExpr"),Ek.key="sort";var zl=Ek,LS=class LS extends w{constructor(e={}){super(e)}};n(LS,"AlgorithmPropertyExpr"),LS.key="algorithmProperty",LS.requiredArgs=new Set(["this"]),LS.availableArgs=new Set(["this"]);var Wn=LS,wS=class wS extends w{constructor(e={}){super(e)}};n(wS,"AutoIncrementPropertyExpr"),wS.key="autoIncrementProperty",wS.requiredArgs=new Set(["this"]),wS.availableArgs=new Set(["this"]);var jn=wS,MS=class MS extends w{constructor(e={}){super(e)}};n(MS,"AutoRefreshPropertyExpr"),MS.key="autoRefreshProperty",MS.requiredArgs=new Set(["this"]),MS.availableArgs=new Set(["this"]);var Xn=MS,kS=class kS extends w{constructor(e={}){super(e)}};n(kS,"BackupPropertyExpr"),kS.key="backupProperty",kS.requiredArgs=new Set(["this"]),kS.availableArgs=new Set(["this"]);var Jn=kS,DS=class DS extends w{constructor(e={}){super(e)}};n(DS,"BuildPropertyExpr"),DS.key="buildProperty",DS.requiredArgs=new Set(["this"]),DS.availableArgs=new Set(["this"]);var Mq=DS,qS=class qS extends w{constructor(e={}){super(e)}};n(qS,"BlockCompressionPropertyExpr"),qS.key="blockCompressionProperty",qS.requiredArgs=new Set,qS.availableArgs=new Set(["autotemp","always","default","manual","never"]);var qu=qS,US=class US extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(US,"CharacterSetPropertyExpr"),US.key="characterSetProperty",US.requiredArgs=new Set(["this","default"]),US.availableArgs=new Set(["this","default"]);var zr=US,vS=class vS extends w{constructor(e={}){super(e)}};n(vS,"ChecksumPropertyExpr"),vS.key="checksumProperty",vS.requiredArgs=new Set,vS.availableArgs=new Set(["on","default"]);var Uu=vS,FS=class FS extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(FS,"CollatePropertyExpr"),FS.key="collateProperty",FS.requiredArgs=new Set(["this"]),FS.availableArgs=new Set(["this","default"]);var zn=FS,BS=class BS extends w{constructor(e={}){super(e)}};n(BS,"CopyGrantsPropertyExpr"),BS.key="copyGrantsProperty",BS.requiredArgs=new Set,BS.availableArgs=new Set;var Qn=BS,$S=class $S extends w{constructor(e={}){super(e)}};n($S,"DataBlocksizePropertyExpr"),$S.key="dataBlocksizeProperty",$S.requiredArgs=new Set,$S.availableArgs=new Set(["size","units","minimum","maximum","default"]);var vu=$S,GS=class GS extends w{constructor(e={}){super(e)}};n(GS,"DataDeletionPropertyExpr"),GS.key="dataDeletionProperty",GS.requiredArgs=new Set(["on"]),GS.availableArgs=new Set(["on","filterColumn","retentionPeriod"]);var Fu=GS,YS=class YS extends w{constructor(e={}){super(e)}};n(YS,"DefinerPropertyExpr"),YS.key="definerProperty",YS.requiredArgs=new Set(["this"]),YS.availableArgs=new Set(["this"]);var Zn=YS,VS=class VS extends w{constructor(e={}){super(e)}};n(VS,"DistKeyPropertyExpr"),VS.key="distKeyProperty",VS.requiredArgs=new Set(["this"]),VS.availableArgs=new Set(["this"]);var Kn=VS,HS=class HS extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(HS,"DistributedByPropertyExpr"),HS.key="distributedByProperty",HS.requiredArgs=new Set(["kind"]),HS.availableArgs=new Set(["expressions","kind","buckets","order"]);var ea=HS,_S=class _S extends w{constructor(e={}){super(e)}};n(_S,"DistStylePropertyExpr"),_S.key="distStyleProperty",_S.requiredArgs=new Set(["this"]),_S.availableArgs=new Set(["this"]);var ta=_S,WS=class WS extends w{constructor(e={}){super(e)}};n(WS,"DuplicateKeyPropertyExpr"),WS.key="duplicateKeyProperty",WS.requiredArgs=new Set(["expressions"]),WS.availableArgs=new Set(["expressions"]);var Bu=WS,jS=class jS extends w{constructor(e={}){super(e)}};n(jS,"EnginePropertyExpr"),jS.key="engineProperty",jS.requiredArgs=new Set(["this"]),jS.availableArgs=new Set(["this"]);var sa=jS,XS=class XS extends w{constructor(e={}){super(e)}};n(XS,"UuidPropertyExpr"),XS.key="uuidProperty",XS.requiredArgs=new Set(["this"]),XS.availableArgs=new Set(["this"]);var kq=XS,JS=class JS extends w{constructor(e={}){super(e)}};n(JS,"HandlerPropertyExpr"),JS.key="handlerProperty",JS.requiredArgs=new Set(["this"]),JS.availableArgs=new Set(["this"]);var ra=JS,zS=class zS extends w{constructor(e={}){super(e)}};n(zS,"ParameterStylePropertyExpr"),zS.key="parameterStyleProperty",zS.requiredArgs=new Set(["this"]),zS.availableArgs=new Set(["this"]);var ia=zS,QS=class QS extends w{constructor(e={}){super(e)}};n(QS,"HeapPropertyExpr"),QS.key="heapProperty",QS.requiredArgs=new Set,QS.availableArgs=new Set;var na=QS,ZS=class ZS extends w{constructor(e={}){super(e)}};n(ZS,"ToTablePropertyExpr"),ZS.key="toTableProperty",ZS.requiredArgs=new Set(["this"]),ZS.availableArgs=new Set(["this"]);var aa=ZS,KS=class KS extends w{constructor(e={}){super(e)}};n(KS,"ExecuteAsPropertyExpr"),KS.key="executeAsProperty",KS.requiredArgs=new Set(["this"]),KS.availableArgs=new Set(["this"]);var nr=KS,eR=class eR extends w{constructor(e={}){super(e)}};n(eR,"ExternalPropertyExpr"),eR.key="externalProperty",eR.requiredArgs=new Set,eR.availableArgs=new Set(["this"]);var oa=eR,tR=class tR extends w{constructor(e={}){super(e)}};n(tR,"FallbackPropertyExpr"),tR.key="fallbackProperty",tR.requiredArgs=new Set(["no"]),tR.availableArgs=new Set(["no","protection"]);var $u=tR,sR=class sR extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(sR,"FileFormatPropertyExpr"),sR.key="fileFormatProperty",sR.requiredArgs=new Set,sR.availableArgs=new Set(["this","expressions","hiveFormat"]);var ir=sR,rR=class rR extends w{constructor(e={}){super(e)}};n(rR,"CredentialsPropertyExpr"),rR.key="credentialsProperty",rR.requiredArgs=new Set(["expressions"]),rR.availableArgs=new Set(["expressions"]);var pd=rR,iR=class iR extends w{constructor(e={}){super(e)}};n(iR,"FreespacePropertyExpr"),iR.key="freespaceProperty",iR.requiredArgs=new Set(["this"]),iR.availableArgs=new Set(["this","percent"]);var Gu=iR,nR=class nR extends w{constructor(e={}){super(e)}};n(nR,"GlobalPropertyExpr"),nR.key="globalProperty",nR.requiredArgs=new Set,nR.availableArgs=new Set;var ca=nR,aR=class aR extends w{constructor(e={}){super(e)}};n(aR,"IcebergPropertyExpr"),aR.key="icebergProperty",aR.requiredArgs=new Set,aR.availableArgs=new Set;var pa=aR,oR=class oR extends w{constructor(e={}){super(e)}};n(oR,"InheritsPropertyExpr"),oR.key="inheritsProperty",oR.requiredArgs=new Set(["expressions"]),oR.availableArgs=new Set(["expressions"]);var la=oR,cR=class cR extends w{constructor(e={}){super(e)}};n(cR,"InputModelPropertyExpr"),cR.key="inputModelProperty",cR.requiredArgs=new Set(["this"]),cR.availableArgs=new Set(["this"]);var ua=cR,pR=class pR extends w{constructor(e={}){super(e)}};n(pR,"OutputModelPropertyExpr"),pR.key="outputModelProperty",pR.requiredArgs=new Set(["this"]),pR.availableArgs=new Set(["this"]);var ha=pR,lR=class lR extends w{constructor(e={}){super(e)}};n(lR,"IsolatedLoadingPropertyExpr"),lR.key="isolatedLoadingProperty",lR.requiredArgs=new Set,lR.availableArgs=new Set(["no","concurrent","target"]);var Yu=lR,uR=class uR extends w{constructor(e={}){super(e)}};n(uR,"JournalPropertyExpr"),uR.key="journalProperty",uR.requiredArgs=new Set,uR.availableArgs=new Set(["no","dual","before","local","after"]);var Vu=uR,hR=class hR extends w{constructor(e={}){super(e)}};n(hR,"LanguagePropertyExpr"),hR.key="languageProperty",hR.requiredArgs=new Set(["this"]),hR.availableArgs=new Set(["this"]);var Qr=hR,gR=class gR extends w{constructor(e={}){super(e)}};n(gR,"EnviromentPropertyExpr"),gR.key="enviromentProperty",gR.requiredArgs=new Set(["expressions"]),gR.availableArgs=new Set(["expressions"]);var ga=gR,ER=class ER extends w{constructor(e={}){super(e)}};n(ER,"ClusteredByPropertyExpr"),ER.key="clusteredByProperty",ER.requiredArgs=new Set(["expressions","buckets"]),ER.availableArgs=new Set(["expressions","sortedBy","buckets"]);var Ea=ER,AR=class AR extends w{constructor(e={}){super(e)}};n(AR,"DictPropertyExpr"),AR.key="dictProperty",AR.requiredArgs=new Set(["this","kind"]),AR.availableArgs=new Set(["this","kind","settings"]);var Hu=AR,Ak=class Ak extends w{constructor(e={}){super(e)}};n(Ak,"DictSubPropertyExpr"),Ak.key="dictSubProperty";var GC=Ak,dR=class dR extends w{constructor(e={}){super(e)}};n(dR,"DictRangeExpr"),dR.key="dictRange",dR.requiredArgs=new Set(["this","min","max"]),dR.availableArgs=new Set(["this","min","max"]);var _u=dR,fR=class fR extends w{constructor(e={}){super(e)}};n(fR,"DynamicPropertyExpr"),fR.key="dynamicProperty",fR.requiredArgs=new Set,fR.availableArgs=new Set;var Aa=fR,xR=class xR extends w{constructor(e={}){super(e)}};n(xR,"OnClusterExpr"),xR.key="onCluster",xR.requiredArgs=new Set(["this"]),xR.availableArgs=new Set(["this"]);var Dq=xR,TR=class TR extends w{constructor(e={}){super(e)}};n(TR,"EmptyPropertyExpr"),TR.key="emptyProperty",TR.requiredArgs=new Set,TR.availableArgs=new Set;var da=TR,SR=class SR extends w{constructor(e={}){super(e)}};n(SR,"LikePropertyExpr"),SR.key="likeProperty",SR.requiredArgs=new Set(["this"]),SR.availableArgs=new Set(["this","expressions"]);var Wu=SR,RR=class RR extends w{constructor(e={}){super(e)}};n(RR,"LocationPropertyExpr"),RR.key="locationProperty",RR.requiredArgs=new Set(["this"]),RR.availableArgs=new Set(["this"]);var Zr=RR,OR=class OR extends w{constructor(e={}){super(e)}};n(OR,"LockPropertyExpr"),OR.key="lockProperty",OR.requiredArgs=new Set(["this"]),OR.availableArgs=new Set(["this"]);var ld=OR,mR=class mR extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(mR,"LockingPropertyExpr"),mR.key="lockingProperty",mR.requiredArgs=new Set(["kind","lockType"]),mR.availableArgs=new Set(["this","kind","forOrIn","lockType","override"]);var ju=mR,NR=class NR extends w{constructor(e={}){super(e)}};n(NR,"LogPropertyExpr"),NR.key="logProperty",NR.requiredArgs=new Set(["no"]),NR.availableArgs=new Set(["no"]);var fa=NR,IR=class IR extends w{constructor(e={}){super(e)}};n(IR,"MaterializedPropertyExpr"),IR.key="materializedProperty",IR.requiredArgs=new Set,IR.availableArgs=new Set(["this"]);var xa=IR,yR=class yR extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(yR,"MergeBlockRatioPropertyExpr"),yR.key="mergeBlockRatioProperty",yR.requiredArgs=new Set,yR.availableArgs=new Set(["this","no","default","percent"]);var qn=yR,CR=class CR extends w{constructor(e={}){super(e)}};n(CR,"NoPrimaryIndexPropertyExpr"),CR.key="noPrimaryIndexProperty",CR.requiredArgs=new Set,CR.availableArgs=new Set;var Ta=CR,bR=class bR extends w{constructor(e={}){super(e)}};n(bR,"OnPropertyExpr"),bR.key="onProperty",bR.requiredArgs=new Set(["this"]),bR.availableArgs=new Set(["this"]);var Vr=bR,PR=class PR extends w{constructor(e={}){super(e)}};n(PR,"OnCommitPropertyExpr"),PR.key="onCommitProperty",PR.requiredArgs=new Set,PR.availableArgs=new Set(["delete"]);var Hr=PR,LR=class LR extends w{constructor(e={}){super(e)}};n(LR,"PartitionedByPropertyExpr"),LR.key="partitionedByProperty",LR.requiredArgs=new Set(["this"]),LR.availableArgs=new Set(["this"]);var ys=LR,wR=class wR extends w{constructor(e={}){super(e)}};n(wR,"PartitionedByBucketExpr"),wR.key="partitionedByBucket",wR.requiredArgs=new Set(["this","expression"]),wR.availableArgs=new Set(["this","expression"]);var Xu=wR,MR=class MR extends w{constructor(e={}){super(e)}};n(MR,"PartitionByTruncateExpr"),MR.key="partitionByTruncate",MR.requiredArgs=new Set(["this","expression"]),MR.availableArgs=new Set(["this","expression"]);var Ju=MR,kR=class kR extends w{constructor(e={}){super(e)}};n(kR,"PartitionByRangePropertyExpr"),kR.key="partitionByRangeProperty",kR.requiredArgs=new Set(["partitionExpressions","createExpressions"]),kR.availableArgs=new Set(["partitionExpressions","createExpressions"]);var qq=kR,DR=class DR extends w{constructor(e={}){super(e)}};n(DR,"RollupPropertyExpr"),DR.key="rollupProperty",DR.requiredArgs=new Set(["expressions"]),DR.availableArgs=new Set(["expressions"]);var Db=DR,qR=class qR extends w{constructor(e={}){super(e)}};n(qR,"PartitionByListPropertyExpr"),qR.key="partitionByListProperty",qR.requiredArgs=new Set(["partitionExpressions","createExpressions"]),qR.availableArgs=new Set(["partitionExpressions","createExpressions"]);var Uq=qR,UR=class UR extends w{constructor(e={}){super(e)}};n(UR,"RefreshTriggerPropertyExpr"),UR.key="refreshTriggerProperty",UR.requiredArgs=new Set,UR.availableArgs=new Set(["method","kind","every","unit","starts"]);var qb=UR,vR=class vR extends w{constructor(e={}){super(e)}};n(vR,"UniqueKeyPropertyExpr"),vR.key="uniqueKeyProperty",vR.requiredArgs=new Set(["expressions"]),vR.availableArgs=new Set(["expressions"]);var vq=vR,FR=class FR extends w{constructor(e={}){super(e)}};n(FR,"PartitionedOfPropertyExpr"),FR.key="partitionedOfProperty",FR.requiredArgs=new Set(["this","expression"]),FR.availableArgs=new Set(["this","expression"]);var zu=FR,BR=class BR extends w{constructor(e={}){super(e)}};n(BR,"StreamingTablePropertyExpr"),BR.key="streamingTableProperty",BR.requiredArgs=new Set,BR.availableArgs=new Set;var Sa=BR,$R=class $R extends w{constructor(e={}){super(e)}};n($R,"RemoteWithConnectionModelPropertyExpr"),$R.key="remoteWithConnectionModelProperty",$R.requiredArgs=new Set(["this"]),$R.availableArgs=new Set(["this"]);var Ra=$R,GR=class GR extends w{constructor(e={}){super(e)}};n(GR,"ReturnsPropertyExpr"),GR.key="returnsProperty",GR.requiredArgs=new Set,GR.availableArgs=new Set(["this","isTable","table","null"]);var Kr=GR,YR=class YR extends w{constructor(e={}){super(e)}};n(YR,"StrictPropertyExpr"),YR.key="strictProperty",YR.requiredArgs=new Set,YR.availableArgs=new Set;var Oa=YR,VR=class VR extends w{constructor(e={}){super(e)}};n(VR,"RowFormatPropertyExpr"),VR.key="rowFormatProperty",VR.requiredArgs=new Set(["this"]),VR.availableArgs=new Set(["this"]);var ma=VR,HR=class HR extends w{constructor(e={}){super(e)}};n(HR,"RowFormatDelimitedPropertyExpr"),HR.key="rowFormatDelimitedProperty",HR.requiredArgs=new Set,HR.availableArgs=new Set(["fields","escaped","collectionItems","mapKeys","lines","null","serde"]);var Qu=HR,_R=class _R extends w{constructor(e={}){super(e)}};n(_R,"RowFormatSerdePropertyExpr"),_R.key="rowFormatSerdeProperty",_R.requiredArgs=new Set(["this"]),_R.availableArgs=new Set(["this","serdeProperties"]);var Zu=_R,WR=class WR extends w{constructor(e={}){super(e)}};n(WR,"SamplePropertyExpr"),WR.key="sampleProperty",WR.requiredArgs=new Set(["this"]),WR.availableArgs=new Set(["this"]);var Na=WR,jR=class jR extends w{constructor(e={}){super(e)}};n(jR,"SchemaCommentPropertyExpr"),jR.key="schemaCommentProperty",jR.requiredArgs=new Set(["this"]),jR.availableArgs=new Set(["this"]);var Ia=jR,XR=class XR extends w{constructor(e={}){super(e)}};n(XR,"SerdePropertiesExpr"),XR.key="serdeProperties",XR.requiredArgs=new Set(["expressions"]),XR.availableArgs=new Set(["expressions","with"]);var Ku=XR,JR=class JR extends w{constructor(e={}){super(e)}};n(JR,"SetPropertyExpr"),JR.key="setProperty",JR.requiredArgs=new Set(["multi"]),JR.availableArgs=new Set(["multi"]);var _r=JR,zR=class zR extends w{constructor(e={}){super(e)}};n(zR,"SharingPropertyExpr"),zR.key="sharingProperty",zR.requiredArgs=new Set,zR.availableArgs=new Set(["this"]);var ya=zR,QR=class QR extends w{constructor(e={}){super(e)}};n(QR,"SetConfigPropertyExpr"),QR.key="setConfigProperty",QR.requiredArgs=new Set(["this"]),QR.availableArgs=new Set(["this"]);var XA=QR,ZR=class ZR extends w{constructor(e={}){super(e)}};n(ZR,"SettingsPropertyExpr"),ZR.key="settingsProperty",ZR.requiredArgs=new Set(["expressions"]),ZR.availableArgs=new Set(["expressions"]);var Ca=ZR,KR=class KR extends w{constructor(e={}){super(e)}};n(KR,"SortKeyPropertyExpr"),KR.key="sortKeyProperty",KR.requiredArgs=new Set(["this"]),KR.availableArgs=new Set(["this","compound"]);var ba=KR,eO=class eO extends w{constructor(e={}){super(e)}};n(eO,"SqlReadWritePropertyExpr"),eO.key="sqlReadWriteProperty",eO.requiredArgs=new Set(["this"]),eO.availableArgs=new Set(["this"]);var vs=eO,tO=class tO extends w{constructor(e={}){super(e)}};n(tO,"SqlSecurityPropertyExpr"),tO.key="sqlSecurityProperty",tO.requiredArgs=new Set(["this"]),tO.availableArgs=new Set(["this"]);var Pa=tO,sO=class sO extends w{constructor(e={}){super(e)}};n(sO,"StabilityPropertyExpr"),sO.key="stabilityProperty",sO.requiredArgs=new Set(["this"]),sO.availableArgs=new Set(["this"]);var Fs=sO,rO=class rO extends w{constructor(e={}){super(e)}};n(rO,"StorageHandlerPropertyExpr"),rO.key="storageHandlerProperty",rO.requiredArgs=new Set(["this"]),rO.availableArgs=new Set(["this"]);var eh=rO,iO=class iO extends w{constructor(e={}){super(e)}};n(iO,"TemporaryPropertyExpr"),iO.key="temporaryProperty",iO.requiredArgs=new Set,iO.availableArgs=new Set(["this"]);var $s=iO,nO=class nO extends w{constructor(e={}){super(e)}};n(nO,"SecurePropertyExpr"),nO.key="secureProperty",nO.requiredArgs=new Set,nO.availableArgs=new Set;var La=nO,aO=class aO extends w{};n(aO,"ApiPropertyExpr"),aO.key="apiProperty",aO.requiredArgs=new Set,aO.availableArgs=new Set;var JA=aO,oO=class oO extends w{};n(oO,"ApplicationPropertyExpr"),oO.key="applicationProperty",oO.requiredArgs=new Set,oO.availableArgs=new Set;var zA=oO,cO=class cO extends w{};n(cO,"CatalogPropertyExpr"),cO.key="catalogProperty",cO.requiredArgs=new Set,cO.availableArgs=new Set;var QA=cO,pO=class pO extends w{};n(pO,"ComputePropertyExpr"),pO.key="computeProperty",pO.requiredArgs=new Set,pO.availableArgs=new Set;var ZA=pO,lO=class lO extends w{};n(lO,"DatabasePropertyExpr"),lO.key="databaseProperty",lO.requiredArgs=new Set,lO.availableArgs=new Set;var KA=lO,uO=class uO extends w{};n(uO,"HybridPropertyExpr"),uO.key="hybridProperty",uO.requiredArgs=new Set,uO.availableArgs=new Set;var ed=uO,hO=class hO extends w{};n(hO,"MaskingPropertyExpr"),hO.key="maskingProperty",hO.requiredArgs=new Set,hO.availableArgs=new Set;var td=hO,gO=class gO extends w{};n(gO,"NetworkPropertyExpr"),gO.key="networkProperty",gO.requiredArgs=new Set,gO.availableArgs=new Set;var sd=gO,EO=class EO extends w{};n(EO,"RowAccessPropertyExpr"),EO.key="rowAccessProperty",EO.requiredArgs=new Set,EO.availableArgs=new Set;var rd=EO,AO=class AO extends w{};n(AO,"SecurityIntegrationPropertyExpr"),AO.key="securityIntegrationProperty",AO.requiredArgs=new Set,AO.availableArgs=new Set;var id=AO,dO=class dO extends V(oe,w){constructor(e={}){super(e)}};n(dO,"TagsExpr"),dO.key="tags",dO.requiredArgs=new Set(["expressions"]),dO.availableArgs=new Set(["expressions"]);var nd=dO,fO=class fO extends w{constructor(e={}){super(e)}};n(fO,"TransformModelPropertyExpr"),fO.key="transformModelProperty",fO.requiredArgs=new Set(["expressions"]),fO.availableArgs=new Set(["expressions"]);var wa=fO,xO=class xO extends w{constructor(e={}){super(e)}};n(xO,"TransientPropertyExpr"),xO.key="transientProperty",xO.requiredArgs=new Set,xO.availableArgs=new Set(["this"]);var Ma=xO,TO=class TO extends w{constructor(e={}){super(e)}};n(TO,"UnloggedPropertyExpr"),TO.key="unloggedProperty",TO.requiredArgs=new Set,TO.availableArgs=new Set;var ka=TO,SO=class SO extends w{constructor(e={}){super(e)}};n(SO,"UsingTemplatePropertyExpr"),SO.key="usingTemplateProperty",SO.requiredArgs=new Set(["this"]),SO.availableArgs=new Set(["this"]);var ad=SO,RO=class RO extends w{constructor(e={}){super(e)}};n(RO,"ViewAttributePropertyExpr"),RO.key="viewAttributeProperty",RO.requiredArgs=new Set(["this"]),RO.availableArgs=new Set(["this"]);var Da=RO,OO=class OO extends w{constructor(e={}){super(e)}};n(OO,"VolatilePropertyExpr"),OO.key="volatileProperty",OO.requiredArgs=new Set,OO.availableArgs=new Set(["this"]);var qa=OO,mO=class mO extends w{constructor(e={}){super(e)}};n(mO,"WithDataPropertyExpr"),mO.key="withDataProperty",mO.requiredArgs=new Set(["no"]),mO.availableArgs=new Set(["no","statistics"]);var th=mO,NO=class NO extends w{constructor(e={}){super(e)}};n(NO,"WithJournalTablePropertyExpr"),NO.key="withJournalTableProperty",NO.requiredArgs=new Set(["this"]),NO.availableArgs=new Set(["this"]);var Ua=NO,IO=class IO extends w{constructor(e={}){super(e)}};n(IO,"WithSchemaBindingPropertyExpr"),IO.key="withSchemaBindingProperty",IO.requiredArgs=new Set(["this"]),IO.availableArgs=new Set(["this"]);var va=IO,yO=class yO extends w{constructor(e={}){super(e)}};n(yO,"WithSystemVersioningPropertyExpr"),yO.key="withSystemVersioningProperty",yO.requiredArgs=new Set(["with"]),yO.availableArgs=new Set(["on","this","dataConsistency","retentionPeriod","with"]);var sh=yO,CO=class CO extends w{constructor(e={}){super(e)}};n(CO,"WithProcedureOptionsExpr"),CO.key="withProcedureOptions",CO.requiredArgs=new Set(["expressions"]),CO.availableArgs=new Set(["expressions"]);var Fa=CO,bO=class bO extends w{constructor(e={}){super(e)}};n(bO,"EncodePropertyExpr"),bO.key="encodeProperty",bO.requiredArgs=new Set(["this"]),bO.availableArgs=new Set(["this","properties","key"]);var ud=bO,PO=class PO extends w{constructor(e={}){super(e)}};n(PO,"IncludePropertyExpr"),PO.key="includeProperty",PO.requiredArgs=new Set(["this"]),PO.availableArgs=new Set(["this","alias","columnDef"]);var hd=PO,LO=class LO extends w{constructor(e={}){super(e)}};n(LO,"ForcePropertyExpr"),LO.key="forceProperty",LO.requiredArgs=new Set,LO.availableArgs=new Set;var od=LO,Ws=class Ws extends d{constructor(e={}){super(e)}static fromDict(e){let t=[];for(let[s,r]of Object.entries(e)){let i=Ws.NAME_TO_PROPERTY[s.toUpperCase()];i?t.push(new i({this:ht(r)})):t.push(new w({this:N.string(s),value:ht(r)}))}return new Ws({expressions:t})}};n(Ws,"PropertiesExpr"),Ws.key="properties",Ws.requiredArgs=new Set(["expressions"]),Ws.availableArgs=new Set(["expressions"]),Ws.NAME_TO_PROPERTY={ALGORITHM:Wn,AUTO_INCREMENT:jn,"CHARACTER SET":zr,CLUSTERED_BY:Ea,COLLATE:zn,COMMENT:Ia,CREDENTIALS:pd,DEFINER:Zn,DISTKEY:Kn,DISTRIBUTED_BY:ea,DISTSTYLE:ta,ENGINE:sa,"EXECUTE AS":nr,FORMAT:ir,LANGUAGE:Qr,LOCATION:Zr,LOCK:ld,PARTITIONED_BY:ys,RETURNS:Kr,ROW_FORMAT:ma,SORTKEY:ba,ENCODE:ud,INCLUDE:hd},Ws.PROPERTY_TO_NAME=Object.fromEntries(Object.entries(Ws.NAME_TO_PROPERTY).map(([e,t])=>[t.key,e]));var He=Ws,Wa=class Wa extends ee{constructor(e={}){super(e)}select(e,t={}){let{copy:s=!0,...r}=t,i=Array.from(J(e)),o=$e(this,s),c=o.args.this;re(c,ee),ct(c.unnest(),ee)?.select(i,{...r,copy:!1});let p=o.args.expression;return re(p,ee),ct(p.unnest(),ee)?.select(i,{...r,copy:!1,append:t?.append??!0}),o}get namedSelects(){let e=this;for(;e instanceof Wa;){let t=e.args.this?.unnest();re(t,ee),e=t}return e.namedSelects}get isStar(){let e=this.args.this?.isStar,t=this.args.expression?.isStar;return e||t||!1}get selects(){let e=this;for(;e instanceof Wa;){let t=e.args.this?.unnest();re(t,ee),e=t}return e.selects}get left(){return this.args.this}get right(){return this.args.expression}get kind(){return this.args.kind}get side(){return this.text("side").toUpperCase()}};n(Wa,"SetOperationExpr"),Wa.key="setOperation",Wa.requiredArgs=new Set(["this","expression"]),Wa.availableArgs=new Set(["with","this","expression","distinct","byName","side","kind","on","match","laterals","joins","connect","pivots","prewhere","where","group","having","qualify","windows","distribute","sort","cluster","order","limit","offset","locks","sample","settings","format","options"]);var Ge=Wa,wO=class wO extends bs{constructor(e={}){super(e)}table(e,t={}){let{dialect:s,copy:r=!0}=t;return JE(e,{instance:this,arg:"this",into:_,prefix:void 0,dialect:s,copy:r})}set(e,t={}){let{append:s=!0,dialect:r,copy:i=!0}=t,o=Array.from(J(e));return Hh(o,{instance:this,arg:"expressions",append:s,into:d,prefix:void 0,dialect:r,copy:i})}where(e,t={}){let{append:s=!0,dialect:r,copy:i=!0}=t;return vI(e,{instance:this,arg:"where",append:s,into:St,dialect:r,copy:i})}from(e,t={}){let{dialect:s,copy:r=!0}=t;return e?JE(e,{instance:this,arg:"from",into:rt,prefix:"FROM",dialect:s,copy:r}):this}with(e,t,s={}){let{recursive:r=!1,append:i=!0,copy:o=!0,...c}=s;return z$({instance:this,alias:e,as:t,...c,recursive:r,append:i,copy:o})}};n(wO,"UpdateExpr"),wO.key="update",wO.requiredArgs=new Set,wO.availableArgs=new Set(["with","this","expressions","from","where","returning","order","limit","options"]);var us=wO,_h=class _h extends ee{constructor(e={}){super(e)}get namedSelects(){let e=[];for(let t of this.args.expressions||[])t.aliasOrName?e.push(t.outputName):t instanceof Hn&&e.push(...t.aliases.map(s=>s.name));return e}get isStar(){return this.args.expressions?.some(e=>typeof e=="object"&&"isStar"in e&&e.isStar)??!1}get selects(){return this.args.expressions||[]}from(e,t={}){let{dialect:s,copy:r=!0,...i}=t;return JE(e,{...i,instance:this,arg:"from",into:rt,prefix:"FROM",dialect:s,copy:r})}groupBy(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t,c=Array.from(J(e));return c.length===0?i?this.copy():this:dd(c,{...o,instance:this,arg:"group",append:s,copy:i,prefix:"GROUP BY",into:Yr,dialect:r})}sortBy(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return dd(e,{...o,instance:this,arg:"sort",append:s,copy:i,prefix:"SORT BY",into:zl,dialect:r})}clusterBy(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return dd(e,{...o,instance:this,arg:"cluster",append:s,copy:i,prefix:"CLUSTER BY",into:rr,dialect:r})}having(e,t={}){let{append:s=!0,dialect:r=void 0,copy:i=!0,...o}=t;return vI(e,{instance:this,arg:"having",append:s,into:ds,dialect:r,copy:i,...o})}orderBy(e,t={}){let{append:s=!0,dialect:r=void 0,copy:i=!0,...o}=t;return dd(e,{instance:this,arg:"order",append:s,copy:i,prefix:"ORDER BY",into:Ie,dialect:r,...o})}select(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return Hh(e,{instance:this,arg:"expressions",append:s,dialect:r,into:d,copy:i,...o})}lateral(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return Hh(e,{...o,instance:this,arg:"laterals",append:s,into:Ct,prefix:"LATERAL VIEW",dialect:r,copy:i})}join(e,t={}){let{on:s,using:r,append:i=!0,joinType:o,joinAlias:c,dialect:p,copy:u=!0,...h}=t,g={dialect:p},f;try{f=W(e,{...g,into:xe,prefix:"JOIN"})}catch{try{f=W(e,{...g,into:xe})}catch{f=W(e,{...g})}}let x=f instanceof xe?f:new xe({this:f});x.args.this instanceof _h&&x.args.this?.replace(x.args.this?.subquery());let T={left:"left",right:"right",full:"full"};if(o){let y=T[o]??o,C=W(y,{...g,into:"JOIN_TYPE"});C.args.method&&x.setArgKey("method",C.args.method),C.args.side&&x.setArgKey("side",C.args.side),C.args.kind&&x.setArgKey("kind",C.args.kind)}if(s){let y=ve(Array.from(J(s)),{dialect:p,copy:u});x.setArgKey("on",y)}return r&&(x=Hh(Array.from(J(r)),{instance:x,arg:"using",append:i,copy:u,into:v})),c&&x.setArgKey("this",Be(x.args.this,c,{table:!0})),Hh([x],{instance:this,arg:"joins",append:i,copy:u})}window(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return Hh(e,{...o,instance:this,arg:"windows",append:s,into:Ue,dialect:r,copy:i})}qualify(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return vI(e,{...o,instance:this,arg:"qualify",append:s,into:Xs,dialect:r,copy:i})}distinct(e,t={}){let{distinct:s=!0,copy:r=!0,...i}=t,o=$e(this,r),p=(e?e.some(h=>h===!1):!1)?!1:s,u=e?e.filter(h=>h!==void 0&&h!==!1&&h!==!0):[];if(0<u.length){let h=u.map(f=>W(f,{copy:r,into:d})),g=new Ze({expressions:h});o.setArgKey("distinct",p?new et({on:g}):void 0)}else o.setArgKey("distinct",p?new et({}):void 0);return o}ctas(e,t={}){let{properties:s,dialect:r,copy:i=!0}=t,o=$e(this,i),c=W((e instanceof d,e),{dialect:r,into:_}),p;return s&&(p=He.fromDict(s)),new ss({this:c,kind:"table",expression:o,properties:p})}lock(e={}){let{update:t=!0,copy:s=!0}=e,r=$e(this,s);return r.setArgKey("locks",[new BA({update:new N({this:String(Number(t)),isString:!1})})]),r}hint(e,t={}){let{dialect:s,copy:r=!0}=t,o=(e!==void 0?Array.from(J(e)):[]).map(p=>W(p,{dialect:s,into:d})),c=$e(this,r);return c.setArgKey("hint",new Ps({expressions:o})),c}};n(_h,"SelectExpr"),_h.key="select",_h.requiredArgs=new Set,_h.availableArgs=new Set(["with","kind","expressions","hint","distinct","into","from","operationModifiers","exclude","match","laterals","joins","connect","pivots","prewhere","where","group","having","qualify","windows","distribute","sort","cluster","order","limit","offset","locks","sample","settings","format","options","for"]);var se=_h,ja=class ja extends V(An,ee){constructor(e={}){super(e)}unnest(){let e=this;for(;e instanceof ja;){let t=e.args.this;if(!t||(e=t,e===this))break}return e}unwrap(){let e=this;for(;e.sameParent&&e.isWrapper;){let t=e.parent;if(!(t instanceof ja))break;e=t}return e}select(e,t={}){let{copy:s=!0,...r}=t,i=$e(this,s),o=i?.unnest();return o instanceof se&&o.select(e,{...r,copy:!1}),i}get isWrapper(){return Object.entries(this.args).every(([e,t])=>e==="this"||t===void 0)}get isStar(){let e=this.args.this;return e?e.isStar:!1}get outputName(){return this.alias}};n(ja,"SubqueryExpr"),ja.key="subquery",ja.requiredArgs=new Set(["this"]),ja.availableArgs=new Set(["this","alias","with","match","laterals","joins","connect","pivots","prewhere","where","group","having","qualify","windows","distribute","sort","cluster","order","limit","offset","locks","sample","settings","format","options"]);var he=ja,MO=class MO extends Ce{constructor(e={}){super(e)}};n(MO,"WindowExpr"),MO.key="window",MO.requiredArgs=new Set(["this"]),MO.availableArgs=new Set(["this","partitionBy","order","spec","alias","over","first"]);var Ue=MO,Ew=class Ew extends Ce{constructor(e={}){super(e)}};n(Ew,"ParameterExpr"),Ew.key="parameter",Ew.availableArgs=new Set(["this","expression"]);var YC=Ew,Aw=class Aw extends Ce{constructor(e={}){super(e)}};n(Aw,"SessionParameterExpr"),Aw.key="sessionParameter",Aw.availableArgs=new Set(["this","kind"]);var VC=Aw,kO=class kO extends Ce{constructor(e={}){super(e)}get name(){return(this.args.this instanceof d?this.args.this.name:this.args.this)||"?"}};n(kO,"PlaceholderExpr"),kO.key="placeholder",kO.requiredArgs=new Set,kO.availableArgs=new Set(["this","kind","widget","jdbc"]);var ar=kO,DO=class DO extends Ce{constructor(e={}){super(e)}get name(){return"NULL"}toValue(){}};n(DO,"NullExpr"),DO.key="null",DO.requiredArgs=new Set,DO.availableArgs=new Set;var Pt=DO,dk=class dk extends Ce{constructor(e={}){super(e)}toValue(){return!!this.args.this}};n(dk,"BooleanExpr"),dk.key="boolean";var at=dk,dw=class dw extends m{constructor(e={}){super(e)}};n(dw,"PseudoTypeExpr"),dw.key="pseudoType",dw.availableArgs=new Set(["this"]);var HC=dw,fw=class fw extends m{constructor(e={}){super(e)}};n(fw,"ObjectIdentifierExpr"),fw.key="objectIdentifier",fw.availableArgs=new Set(["this"]);var _C=fw,qO=class qO extends Ce{constructor(e={}){super(e)}get left(){return this.args.this}get right(){return this.args.expression}};n(qO,"BinaryExpr"),qO.key="binary",qO.requiredArgs=new Set(["this","expression"]),qO.availableArgs=new Set(["this","expression"]);var U=qO,UO=class UO extends Ce{constructor(e={}){super(e)}};n(UO,"UnaryExpr"),UO.key="unary",UO.requiredArgs=new Set(["this"]),UO.availableArgs=new Set(["this"]);var qs=UO,fk=class fk extends Re{constructor(e={}){super(e)}};n(fk,"PivotAliasExpr"),fk.key="pivotAlias";var WC=fk,vO=class vO extends Ce{constructor(e={}){super(e)}get outputName(){return this.args.expressions?.length===1?this.args.expressions[0].outputName:super.outputName}};n(vO,"BracketExpr"),vO.key="bracket",vO.requiredArgs=new Set,vO.availableArgs=new Set(["this","expressions","offset","safe","returnsListForMaps","jsonAccess"]);var Lt=vO,FO=class FO extends te{constructor(e={}){super(e)}interval(){return new qe({this:this.args.expression?.copy(),unit:this.unit?.copy()})}};n(FO,"IntervalOpExpr"),FO.key="intervalOp",FO.requiredArgs=new Set(["expression"]),FO.availableArgs=new Set(["unit","expression"]);var Zs=FO,BO=class BO extends d{constructor(e={}){super(e)}};n(BO,"IntervalSpanExpr"),BO.key="intervalSpan",BO.requiredArgs=new Set(["this","expression"]),BO.availableArgs=new Set(["this","expression"]);var Wr=BO,$O=class $O extends te{constructor(e={}){super(e)}};n($O,"IntervalExpr"),$O.key="interval",$O.requiredArgs=new Set,$O.availableArgs=new Set(["this","unit"]);var qe=$O,Ir=class Ir extends Ce{constructor(e={}){super(e)}static fromArgList(e){let t=this.argOrder;if(t.length===0&&(t=Array.from(this.availableArgs)),this.isVarLenArgs){let s=t.slice(0,-1),r=s.length,i={};for(let o=0;o<s.length;o++)i[s[o]]=e[o];return i[t[t.length-1]]=e.slice(r),new this(i)}else{let s={};for(let r=0;r<t.length;r++)s[t[r]]=e[r];return new this(s)}}static sqlNames(){if(this===Ir)throw new Error("SQL name is only supported by concrete function implementations");if(!Object.hasOwn(this,"_sqlNames")){let t=this.name.replace(/Expr$/,"").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toUpperCase();this._sqlNames=[t]}return this._sqlNames}static sqlName(){let e=this.sqlNames();if(!e.length)throw new Error(`Expected non-empty 'sql_names' for Func: ${this.name}.`);return e[0]}static defaultParserMappings(){let e={};for(let t of this.sqlNames())e[t]=this.fromArgList.bind(this);return e}static register(){this===Ir||this===q||iV(this)}};n(Ir,"FuncExpr"),Ir.key="func",Ir.requiredArgs=new Set,Ir.isVarLenArgs=!1,Ir.argOrder=[],Ir._sqlNames=[];var E=Ir,xw=class xw extends E{constructor(e={}){super(e)}};n(xw,"AggFuncExpr"),xw.key="aggFunc",xw.argOrder=["this"];var q=xw,GO=class GO extends qt{constructor(e={}){super(e)}};n(GO,"JsonPathFilterExpr"),GO.key="jsonPathFilter",GO.requiredArgs=new Set(["this"]),GO.availableArgs=new Set(["this"]);var Vs=GO,YO=class YO extends qt{constructor(e={}){super(e)}};n(YO,"JsonPathKeyExpr"),YO.key="jsonPathKey",YO.requiredArgs=new Set(["this"]),YO.availableArgs=new Set(["this"]);var Mt=YO,Tw=class Tw extends qt{constructor(e={}){super(e)}};n(Tw,"JsonPathRecursiveExpr"),Tw.key="jsonPathRecursive",Tw.availableArgs=new Set(["this"]);var xr=Tw,VO=class VO extends qt{constructor(e={}){super(e)}};n(VO,"JsonPathRootExpr"),VO.key="jsonPathRoot",VO.requiredArgs=new Set,VO.availableArgs=new Set;var zt=VO,HO=class HO extends qt{constructor(e={}){super(e)}};n(HO,"JsonPathScriptExpr"),HO.key="jsonPathScript",HO.requiredArgs=new Set(["this"]),HO.availableArgs=new Set(["this"]);var Hs=HO,Sw=class Sw extends qt{constructor(e={}){super(e)}};n(Sw,"JsonPathSliceExpr"),Sw.key="jsonPathSlice",Sw.availableArgs=new Set(["start","end","step"]);var Tr=Sw,_O=class _O extends qt{constructor(e={}){super(e)}};n(_O,"JsonPathSelectorExpr"),_O.key="jsonPathSelector",_O.requiredArgs=new Set(["this"]),_O.availableArgs=new Set(["this"]);var ci=_O,WO=class WO extends qt{constructor(e={}){super(e)}};n(WO,"JsonPathSubscriptExpr"),WO.key="jsonPathSubscript",WO.requiredArgs=new Set(["this"]),WO.availableArgs=new Set(["this"]);var ts=WO,jO=class jO extends qt{constructor(e={}){super(e)}};n(jO,"JsonPathUnionExpr"),jO.key="jsonPathUnion",jO.requiredArgs=new Set(["expressions"]),jO.availableArgs=new Set(["expressions"]);var Sr=jO,XO=class XO extends qt{constructor(e={}){super(e)}};n(XO,"JsonPathWildcardExpr"),XO.key="jsonPathWildcard",XO.requiredArgs=new Set,XO.availableArgs=new Set;var Dt=XO,JO=class JO extends bs{constructor(e={}){super(e)}};n(JO,"MergeExpr"),JO.key="merge",JO.requiredArgs=new Set(["this","using","whens"]),JO.availableArgs=new Set(["this","using","on","usingCond","whens","with","returning"]);var GA=JO,Rw=class Rw extends yt{constructor(e={}){super(e)}};n(Rw,"LateralExpr"),Rw.key="lateral",Rw.availableArgs=new Set(["this","view","outer","alias","crossApply","ordinality"]);var Ct=Rw,Ow=class Ow extends yt{constructor(e={}){super(e)}};n(Ow,"TableFromRowsExpr"),Ow.key="tableFromRows",Ow.availableArgs=new Set(["this","alias","joins","pivots","sample"]);var _l=Ow,xk=class xk extends Ge{constructor(e={}){super(e)}};n(xk,"UnionExpr"),xk.key="union";var or=xk,Tk=class Tk extends Ge{constructor(e={}){super(e)}};n(Tk,"ExceptExpr"),Tk.key="except";var cr=Tk,Sk=class Sk extends Ge{constructor(e={}){super(e)}};n(Sk,"IntersectExpr"),Sk.key="intersect";var ei=Sk,zO=class zO extends yt{constructor(e={}){super(e)}};n(zO,"ValuesExpr"),zO.key="values",zO.requiredArgs=new Set(["expressions"]),zO.availableArgs=new Set(["expressions","alias","order","limit","offset"]);var tr=zO,Rk=class Rk extends ke{constructor(e={}){super(e)}};n(Rk,"SubqueryPredicateExpr"),Rk.key="subqueryPredicate";var Us=Rk,Ok=class Ok extends U{constructor(e={}){super(e)}};n(Ok,"AddExpr"),Ok.key="add";var we=Ok,mk=class mk extends U{constructor(e={}){super(e)}};n(mk,"ConnectorExpr"),mk.key="connector";var Ae=mk,mw=class mw extends U{constructor(e={}){super(e)}};n(mw,"BitwiseAndExpr"),mw.key="bitwiseAnd",mw.availableArgs=new Set(["this","expression","padside"]);var rh=mw,Nw=class Nw extends U{constructor(e={}){super(e)}};n(Nw,"BitwiseLeftShiftExpr"),Nw.key="bitwiseLeftShift",Nw.availableArgs=new Set(["this","expression","requiresInt128"]);var jC=Nw,Iw=class Iw extends U{constructor(e={}){super(e)}};n(Iw,"BitwiseOrExpr"),Iw.key="bitwiseOr",Iw.availableArgs=new Set(["this","expression","padside"]);var XC=Iw,yw=class yw extends U{constructor(e={}){super(e)}};n(yw,"BitwiseRightShiftExpr"),yw.key="bitwiseRightShift",yw.availableArgs=new Set(["this","expression","requiresInt128"]);var ih=yw,Cw=class Cw extends U{constructor(e={}){super(e)}};n(Cw,"BitwiseXorExpr"),Cw.key="bitwiseXor",Cw.availableArgs=new Set(["this","expression","padside"]);var JC=Cw,bw=class bw extends U{constructor(e={}){super(e)}get left(){return this.args.this}get right(){return this.args.expression}};n(bw,"DivExpr"),bw.key="div",bw.availableArgs=new Set(["this","expression","typed","safe"]);var wt=bw,Nk=class Nk extends U{constructor(e={}){super(e)}};n(Nk,"OverlapsExpr"),Nk.key="overlaps";var zC=Nk,Ik=class Ik extends U{constructor(e={}){super(e)}};n(Ik,"ExtendsLeftExpr"),Ik.key="extendsLeft";var nh=Ik,yk=class yk extends U{constructor(e={}){super(e)}};n(yk,"ExtendsRightExpr"),yk.key="extendsRight";var ah=yk,Pw=class Pw extends U{constructor(e={}){super(e)}get isStar(){return this.args.expression?.isStar??!1}get name(){return this.args.expression?.name??""}get outputName(){return this.name}static build(e){if(e.length<2)throw new Error("Dot requires >= 2 expressions.");return e.reduce((t,s)=>new Pw({this:t,expression:s}))}get parts(){let[e,...t]=this.flatten(),s=[...t];s.reverse();for(let r of U_){let i=e.args[r];i instanceof d&&s.push(i)}return s.reverse(),s}};n(Pw,"DotExpr"),Pw.key="dot";var ge=Pw,Lw=class Lw extends U{constructor(e={}){super(e)}};n(Lw,"DPipeExpr"),Lw.key="dPipe",Lw.availableArgs=new Set(["this","expression","safe"]);var Wt=Lw,QO=class QO extends V(U,ke){constructor(e={}){super(e)}};n(QO,"EqExpr"),QO.key="eq",QO.requiredArgs=new Set(["this","expression"]),QO.availableArgs=new Set(["this","expression"]);var Me=QO,ZO=class ZO extends V(U,ke){constructor(e={}){super(e)}};n(ZO,"NullSafeEqExpr"),ZO.key="nullSafeEq",ZO.requiredArgs=new Set(["this","expression"]),ZO.availableArgs=new Set(["this","expression"]);var Ks=ZO,KO=class KO extends V(U,ke){constructor(e={}){super(e)}};n(KO,"NullSafeNeqExpr"),KO.key="nullSafeNeq",KO.requiredArgs=new Set(["this","expression"]),KO.availableArgs=new Set(["this","expression"]);var Ur=KO,Ck=class Ck extends U{constructor(e={}){super(e)}};n(Ck,"PropertyEqExpr"),Ck.key="propertyEq";var ot=Ck,bk=class bk extends U{constructor(e={}){super(e)}};n(bk,"DistanceExpr"),bk.key="distance";var QC=bk,Pk=class Pk extends U{constructor(e={}){super(e)}};n(Pk,"EscapeExpr"),Pk.key="escape";var Ba=Pk,em=class em extends V(U,ke){constructor(e={}){super(e)}};n(em,"GlobExpr"),em.key="glob",em.requiredArgs=new Set(["this","expression"]),em.availableArgs=new Set(["this","expression"]);var LA=em,tm=class tm extends V(U,ke){constructor(e={}){super(e)}};n(tm,"GtExpr"),tm.key="gt",tm.requiredArgs=new Set(["this","expression"]),tm.availableArgs=new Set(["this","expression"]);var je=tm,sm=class sm extends V(U,ke){constructor(e={}){super(e)}};n(sm,"GteExpr"),sm.key="gte",sm.requiredArgs=new Set(["this","expression"]),sm.availableArgs=new Set(["this","expression"]);var Je=sm,rm=class rm extends V(U,ke){constructor(e={}){super(e)}};n(rm,"ILikeExpr"),rm.key="iLike",rm.requiredArgs=new Set(["this","expression"]),rm.availableArgs=new Set(["this","expression"]);var Gs=rm,Lk=class Lk extends U{constructor(e={}){super(e)}};n(Lk,"IntDivExpr"),Lk.key="intDiv";var Un=Lk,im=class im extends V(U,ke){constructor(e={}){super(e)}};n(im,"IsExpr"),im.key="is",im.requiredArgs=new Set(["this","expression"]),im.availableArgs=new Set(["this","expression"]);var ze=im,wk=class wk extends U{constructor(e={}){super(e)}};n(wk,"KwargExpr"),wk.key="kwarg";var oh=wk,nm=class nm extends V(U,ke){constructor(e={}){super(e)}};n(nm,"LikeExpr"),nm.key="like",nm.requiredArgs=new Set(["this","expression"]),nm.availableArgs=new Set(["this","expression"]);var Qt=nm,am=class am extends V(U,ke){constructor(e={}){super(e)}};n(am,"MatchExpr"),am.key="match",am.requiredArgs=new Set(["this","expression"]),am.availableArgs=new Set(["this","expression"]);var Fq=am,om=class om extends V(U,ke){constructor(e={}){super(e)}};n(om,"LtExpr"),om.key="lt",om.requiredArgs=new Set(["this","expression"]),om.availableArgs=new Set(["this","expression"]);var Fe=om,cm=class cm extends V(U,ke){constructor(e={}){super(e)}};n(cm,"LteExpr"),cm.key="lte",cm.requiredArgs=new Set(["this","expression"]),cm.availableArgs=new Set(["this","expression"]);var nt=cm,Mk=class Mk extends U{constructor(e={}){super(e)}};n(Mk,"ModExpr"),Mk.key="mod";var jr=Mk,kk=class kk extends U{constructor(e={}){super(e)}};n(kk,"MulExpr"),kk.key="mul";var xs=kk,pm=class pm extends V(U,ke){constructor(e={}){super(e)}};n(pm,"NeqExpr"),pm.key="neq",pm.requiredArgs=new Set(["this","expression"]),pm.availableArgs=new Set(["this","expression"]);var ft=pm,Dk=class Dk extends U{constructor(e={}){super(e)}};n(Dk,"NestedJsonSelectExpr"),Dk.key="nestedJsonSelect";var Bq=Dk,lm=class lm extends U{constructor(e={}){super(e)}};n(lm,"OperatorExpr"),lm.key="operator",lm.requiredArgs=new Set(["this","operator","expression"]),lm.availableArgs=new Set(["this","operator","expression"]);var ch=lm,um=class um extends V(U,ke){constructor(e={}){super(e)}};n(um,"SimilarToExpr"),um.key="similarTo",um.requiredArgs=new Set(["this","expression"]),um.availableArgs=new Set(["this","expression"]);var ZC=um,qk=class qk extends U{constructor(e={}){super(e)}};n(qk,"SubExpr"),qk.key="sub";var ye=qk,Uk=class Uk extends U{constructor(e={}){super(e)}};n(Uk,"AdjacentExpr"),Uk.key="adjacent";var ph=Uk,vk=class vk extends qs{constructor(e={}){super(e)}};n(vk,"BitwiseNotExpr"),vk.key="bitwiseNot";var lh=vk,Fk=class Fk extends qs{constructor(e={}){super(e)}};n(Fk,"NotExpr"),Fk.key="not";var Le=Fk,Bk=class Bk extends qs{constructor(e={}){super(e)}get outputName(){return this.args.this?.name??""}};n(Bk,"ParenExpr"),Bk.key="paren";var Se=Bk,$k=class $k extends qs{constructor(e={}){super(e)}toValue(){return this.isNumber?(this.args.this?.toValue()??0)*-1:super.toValue()}};n($k,"NegExpr"),$k.key="neg";var bt=$k,hm=class hm extends ke{constructor(e={}){super(e)}};n(hm,"BetweenExpr"),hm.key="between",hm.requiredArgs=new Set(["this","low","high"]),hm.availableArgs=new Set(["this","low","high","symmetric"]);var Ts=hm,ww=class ww extends ke{constructor(e={}){super(e)}};n(ww,"InExpr"),ww.key="in",ww.availableArgs=new Set(["this","expressions","query","unnest","field","isGlobal"]);var lt=ww,gm=class gm extends E{constructor(e={}){super(e)}};n(gm,"SafeFuncExpr"),gm.key="safeFunc",gm.argOrder=["this"],gm.register();var Ub=gm,Em=class Em extends E{constructor(e={}){super(e)}};n(Em,"TypeofExpr"),Em.key="typeof",Em.argOrder=["this"],Em.register();var $q=Em,Am=class Am extends E{constructor(e={}){super(e)}};n(Am,"AcosExpr"),Am.key="acos",Am.argOrder=["this"],Am.register();var Wb=Am,dm=class dm extends E{constructor(e={}){super(e)}};n(dm,"AcoshExpr"),dm.key="acosh",dm.argOrder=["this"],dm.register();var jb=dm,fm=class fm extends E{constructor(e={}){super(e)}};n(fm,"AsinExpr"),fm.key="asin",fm.argOrder=["this"],fm.register();var Xb=fm,xm=class xm extends E{constructor(e={}){super(e)}};n(xm,"AsinhExpr"),xm.key="asinh",xm.argOrder=["this"],xm.register();var Jb=xm,Wh=class Wh extends E{constructor(e={}){super(e)}};n(Wh,"AtanExpr"),Wh.key="atan",Wh.availableArgs=new Set(["this","expression"]),Wh.argOrder=["this","expression"],Wh.register();var zb=Wh,Tm=class Tm extends E{constructor(e={}){super(e)}};n(Tm,"AtanhExpr"),Tm.key="atanh",Tm.argOrder=["this"],Tm.register();var Qb=Tm,Xa=class Xa extends E{constructor(e={}){super(e)}};n(Xa,"Atan2Expr"),Xa.key="atan2",Xa.requiredArgs=new Set(["this","expression"]),Xa.availableArgs=new Set(["this","expression"]),Xa.argOrder=["this","expression"],Xa.register();var Gq=Xa,Sm=class Sm extends E{constructor(e={}){super(e)}};n(Sm,"CotExpr"),Sm.key="cot",Sm.argOrder=["this"],Sm.register();var Zb=Sm,Rm=class Rm extends E{constructor(e={}){super(e)}};n(Rm,"CothExpr"),Rm.key="coth",Rm.argOrder=["this"],Rm.register();var Yq=Rm,Om=class Om extends E{constructor(e={}){super(e)}};n(Om,"CosExpr"),Om.key="cos",Om.argOrder=["this"],Om.register();var Kb=Om,mm=class mm extends E{constructor(e={}){super(e)}};n(mm,"CscExpr"),mm.key="csc",mm.argOrder=["this"],mm.register();var Vq=mm,Nm=class Nm extends E{constructor(e={}){super(e)}};n(Nm,"CschExpr"),Nm.key="csch",Nm.argOrder=["this"],Nm.register();var Hq=Nm,Im=class Im extends E{constructor(e={}){super(e)}};n(Im,"SecExpr"),Im.key="sec",Im.argOrder=["this"],Im.register();var _q=Im,ym=class ym extends E{constructor(e={}){super(e)}};n(ym,"SechExpr"),ym.key="sech",ym.argOrder=["this"],ym.register();var Wq=ym,Cm=class Cm extends E{constructor(e={}){super(e)}};n(Cm,"SinExpr"),Cm.key="sin",Cm.argOrder=["this"],Cm.register();var eP=Cm,bm=class bm extends E{constructor(e={}){super(e)}};n(bm,"SinhExpr"),bm.key="sinh",bm.argOrder=["this"],bm.register();var tP=bm,Pm=class Pm extends E{constructor(e={}){super(e)}};n(Pm,"TanExpr"),Pm.key="tan",Pm.argOrder=["this"],Pm.register();var sP=Pm,Lm=class Lm extends E{constructor(e={}){super(e)}};n(Lm,"TanhExpr"),Lm.key="tanh",Lm.argOrder=["this"],Lm.register();var rP=Lm,wm=class wm extends E{constructor(e={}){super(e)}};n(wm,"DegreesExpr"),wm.key="degrees",wm.argOrder=["this"],wm.register();var iP=wm,Mm=class Mm extends E{constructor(e={}){super(e)}};n(Mm,"CoshExpr"),Mm.key="cosh",Mm.argOrder=["this"],Mm.register();var nP=Mm,Ja=class Ja extends E{constructor(e={}){super(e)}};n(Ja,"CosineDistanceExpr"),Ja.key="cosineDistance",Ja.requiredArgs=new Set(["this","expression"]),Ja.availableArgs=new Set(["this","expression"]),Ja.argOrder=["this","expression"],Ja.register();var jq=Ja,za=class za extends E{constructor(e={}){super(e)}};n(za,"DotProductExpr"),za.key="dotProduct",za.requiredArgs=new Set(["this","expression"]),za.availableArgs=new Set(["this","expression"]),za.argOrder=["this","expression"],za.register();var Xq=za,Qa=class Qa extends E{constructor(e={}){super(e)}};n(Qa,"EuclideanDistanceExpr"),Qa.key="euclideanDistance",Qa.requiredArgs=new Set(["this","expression"]),Qa.availableArgs=new Set(["this","expression"]),Qa.argOrder=["this","expression"],Qa.register();var Jq=Qa,Za=class Za extends E{constructor(e={}){super(e)}};n(Za,"ManhattanDistanceExpr"),Za.key="manhattanDistance",Za.requiredArgs=new Set(["this","expression"]),Za.availableArgs=new Set(["this","expression"]),Za.argOrder=["this","expression"],Za.register();var zq=Za,Ka=class Ka extends E{constructor(e={}){super(e)}};n(Ka,"JarowinklerSimilarityExpr"),Ka.key="jarowinklerSimilarity",Ka.requiredArgs=new Set(["this","expression"]),Ka.availableArgs=new Set(["this","expression","caseInsensitive"]),Ka.argOrder=["this","expression"],Ka.register();var Qq=Ka,km=class km extends E{constructor(e={}){super(e)}};n(km,"BitwiseCountExpr"),km.key="bitwiseCount",km.argOrder=["this"],km.register();var Zq=km,Dm=class Dm extends E{constructor(e={}){super(e)}};n(Dm,"BitmapBucketNumberExpr"),Dm.key="bitmapBucketNumber",Dm.argOrder=["this"],Dm.register();var Kq=Dm,qm=class qm extends E{constructor(e={}){super(e)}};n(qm,"BitmapCountExpr"),qm.key="bitmapCount",qm.argOrder=["this"],qm.register();var eU=qm,Um=class Um extends E{constructor(e={}){super(e)}};n(Um,"BitmapBitPositionExpr"),Um.key="bitmapBitPosition",Um.argOrder=["this"],Um.register();var tU=Um,vm=class vm extends E{constructor(e={}){super(e)}};n(vm,"ByteLengthExpr"),vm.key="byteLength",vm.argOrder=["this"],vm.register();var sU=vm,jh=class jh extends E{constructor(e={}){super(e)}};n(jh,"BoolnotExpr"),jh.key="boolnot",jh.availableArgs=new Set(["this","roundInput"]),jh.argOrder=["this","roundInput"],jh.register();var rU=jh,eo=class eo extends E{constructor(e={}){super(e)}};n(eo,"BoolandExpr"),eo.key="booland",eo.requiredArgs=new Set(["this","expression"]),eo.availableArgs=new Set(["this","expression","roundInput"]),eo.argOrder=["this","expression","roundInput"],eo.register();var iU=eo,to=class to extends E{constructor(e={}){super(e)}};n(to,"BoolorExpr"),to.key="boolor",to.requiredArgs=new Set(["this","expression"]),to.availableArgs=new Set(["this","expression","roundInput"]),to.argOrder=["this","expression","roundInput"],to.register();var nU=to,Fm=class Fm extends E{constructor(e={}){super(e)}};n(Fm,"JsonBoolExpr"),Fm.key="jsonBool",Fm.argOrder=["this"],Fm.register();var aU=Fm,so=class so extends E{constructor(e={}){super(e)}};n(so,"ArrayRemoveExpr"),so.key="arrayRemove",so.requiredArgs=new Set(["this","expression"]),so.availableArgs=new Set(["this","expression","nullPropagation"]),so.argOrder=["this","expression","nullPropagation"],so.register();var uh=so,Bm=class Bm extends E{constructor(e={}){super(e)}};n(Bm,"AbsExpr"),Bm.key="abs",Bm.argOrder=["this"],Bm.register();var aP=Bm,Xh=class Xh extends E{constructor(e={}){super(e)}};n(Xh,"ApproxTopKEstimateExpr"),Xh.key="approxTopKEstimate",Xh.availableArgs=new Set(["this","expression"]),Xh.argOrder=["this","expression"],Xh.register();var oU=Xh,Jh=class Jh extends E{constructor(e={}){super(e)}};n(Jh,"CityHash64Expr"),Jh.key="cityHash64",Jh.isVarLenArgs=!0,Jh.availableArgs=new Set(["expressions"]),Jh.register();var cU=Jh,yr=class yr extends E{constructor(e={}){super(e)}};n(yr,"FarmFingerprintExpr"),yr.key="farmFingerprint",yr.isVarLenArgs=!0,yr._sqlNames=["FARM_FINGERPRINT","FARMFINGERPRINT64"],yr.requiredArgs=new Set(["expressions"]),yr.availableArgs=new Set(["expressions"]),yr.argOrder=["expressions"],yr.register();var pU=yr,$m=class $m extends E{constructor(e={}){super(e)}};n($m,"FlattenExpr"),$m.key="flatten",$m.argOrder=["this"],$m.register();var lU=$m,zh=class zh extends E{constructor(e={}){super(e)}};n(zh,"Float64Expr"),zh.key="float64",zh.availableArgs=new Set(["this","expression"]),zh.argOrder=["this","expression"],zh.register();var uU=zh,ro=class ro extends E{constructor(e={}){super(e)}};n(ro,"TransformExpr"),ro.key="transform",ro.requiredArgs=new Set(["this","expression"]),ro.availableArgs=new Set(["this","expression"]),ro.argOrder=["this","expression"],ro.register();var hU=ro,io=class io extends E{constructor(e={}){super(e)}};n(io,"TranslateExpr"),io.key="translate",io.requiredArgs=new Set(["this","from","to"]),io.availableArgs=new Set(["this","from","to"]),io.argOrder=["this","from","to"],io.register();var oP=io,no=class no extends E{constructor(e={}){super(e)}get name(){let e=this.args.this;return e===void 0?"":e instanceof d?e.name:e.toString()}};n(no,"AnonymousExpr"),no.key="anonymous",no.isVarLenArgs=!0,no.availableArgs=new Set(["this","expressions"]),no.argOrder=["this","expressions"],no.register();var Qe=no,ao=class ao extends E{constructor(e={}){super(e)}};n(ao,"ApplyExpr"),ao.key="apply",ao.requiredArgs=new Set(["this","expression"]),ao.availableArgs=new Set(["this","expression"]),ao.argOrder=["this","expression"],ao.register();var gU=ao,gi=class gi extends E{constructor(e={}){super(e)}};n(gi,"ArrayExpr"),gi.key="array",gi.isVarLenArgs=!0,gi.requiredArgs=new Set,gi.availableArgs=new Set(["expressions","bracketNotation","structNameInheritance"]),gi.argOrder=["expressions","bracketNotation","structNameInheritance"],gi.register();var ue=gi,Gm=class Gm extends E{constructor(e={}){super(e)}};n(Gm,"AsciiExpr"),Gm.key="ascii",Gm.argOrder=["this"],Gm.register();var cP=Gm,Ym=class Ym extends E{constructor(e={}){super(e)}};n(Ym,"ToArrayExpr"),Ym.key="toArray",Ym.argOrder=["this"],Ym.register();var EU=Ym,Qh=class Qh extends E{constructor(e={}){super(e)}};n(Qh,"ToBooleanExpr"),Qh.key="toBoolean",Qh.availableArgs=new Set(["this","safe"]),Qh.argOrder=["this","safe"],Qh.register();var AU=Qh,Zh=class Zh extends E{constructor(e={}){super(e)}};n(Zh,"ToVariantExpr"),Zh.key="toVariant",Zh.availableArgs=new Set(["this"]),Zh.argOrder=["this"],Zh.register();var dU=Zh,Ei=class Ei extends E{constructor(e={}){super(e)}};n(Ei,"ListExpr"),Ei.key="list",Ei.requiredArgs=new Set,Ei.isVarLenArgs=!0,Ei.availableArgs=new Set(["expressions"]),Ei.argOrder=["expressions"],Ei.register();var KC=Ei,oo=class oo extends E{constructor(e={}){super(e)}};n(oo,"PadExpr"),oo.key="pad",oo.requiredArgs=new Set(["this","expression","isLeft"]),oo.availableArgs=new Set(["this","expression","fillPattern","isLeft"]),oo.argOrder=["this","expression","fillPattern","isLeft"],oo.register();var eb=oo,Kh=class Kh extends E{constructor(e={}){super(e)}};n(Kh,"ToCharExpr"),Kh.key="toChar",Kh.availableArgs=new Set(["this","format","nlsparam","isNumeric"]),Kh.argOrder=["this","format","nlsparam","isNumeric"],Kh.register();var QL=Kh,Vm=class Vm extends E{constructor(e={}){super(e)}};n(Vm,"ToCodePointsExpr"),Vm.key="toCodePoints",Vm.argOrder=["this"],Vm.register();var fU=Vm,eg=class eg extends E{constructor(e={}){super(e)}};n(eg,"ToNumberExpr"),eg.key="toNumber",eg.availableArgs=new Set(["this","format","nlsparam","precision","scale","safe","safeName"]),eg.argOrder=["this","format","nlsparam","precision","scale","safe","safeName"],eg.register();var xU=eg,tg=class tg extends E{constructor(e={}){super(e)}};n(tg,"ToDoubleExpr"),tg.key="toDouble",tg.availableArgs=new Set(["this","format","safe"]),tg.argOrder=["this","format","safe"],tg.register();var pP=tg,sg=class sg extends E{constructor(e={}){super(e)}};n(sg,"ToDecfloatExpr"),sg.key="toDecfloat",sg.availableArgs=new Set(["this","format"]),sg.argOrder=["this","format"],sg.register();var TU=sg,rg=class rg extends E{constructor(e={}){super(e)}};n(rg,"TryToDecfloatExpr"),rg.key="tryToDecfloat",rg.availableArgs=new Set(["this","format"]),rg.argOrder=["this","format"],rg.register();var SU=rg,ig=class ig extends E{constructor(e={}){super(e)}};n(ig,"ToFileExpr"),ig.key="toFile",ig.availableArgs=new Set(["this","path","safe"]),ig.argOrder=["this","path","safe"],ig.register();var RU=ig,Hm=class Hm extends E{constructor(e={}){super(e)}};n(Hm,"CodePointsToBytesExpr"),Hm.key="codePointsToBytes",Hm.argOrder=["this"],Hm.register();var OU=Hm,ng=class ng extends E{constructor(e={}){super(e)}};n(ng,"ColumnsExpr"),ng.key="columns",ng.availableArgs=new Set(["this","unpack"]),ng.argOrder=["this","unpack"],ng.register();var tb=ng,co=class co extends E{constructor(e={}){super(e)}};n(co,"ConvertExpr"),co.key="convert",co.requiredArgs=new Set(["this","expression"]),co.availableArgs=new Set(["this","expression","style","safe"]),co.argOrder=["this","expression","style","safe"],co.register();var mU=co,po=class po extends E{constructor(e={}){super(e)}};n(po,"ConvertToCharsetExpr"),po.key="convertToCharset",po.requiredArgs=new Set(["this","dest"]),po.availableArgs=new Set(["this","dest","source"]),po.argOrder=["this","dest","source"],po.register();var vb=po,lo=class lo extends E{constructor(e={}){super(e)}};n(lo,"ConvertTimezoneExpr"),lo.key="convertTimezone",lo.requiredArgs=new Set(["targetTz","timestamp"]),lo.availableArgs=new Set(["sourceTz","targetTz","timestamp","options"]),lo.argOrder=["sourceTz","targetTz","timestamp","options"],lo.register();var vn=lo,_m=class _m extends E{constructor(e={}){super(e)}};n(_m,"CodePointsToStringExpr"),_m.key="codePointsToString",_m.argOrder=["this"],_m.register();var NU=_m,uo=class uo extends E{constructor(e={}){super(e)}};n(uo,"GenerateSeriesExpr"),uo.key="generateSeries",uo.requiredArgs=new Set(["start","end"]),uo.availableArgs=new Set(["start","end","step","isEndExclusive"]),uo.argOrder=["start","end","step","isEndExclusive"],uo.register();var As=uo,ho=class ho extends V(E,yt){constructor(e={}){super(e)}};n(ho,"GeneratorExpr"),ho.key="generator",ho.argOrder=["rowcount","timelimit"],ho.requiredArgs=new Set,ho.availableArgs=new Set(["rowcount","timelimit"]),ho.register();var IU=ho,Ai=class Ai extends E{constructor(e={}){super(e)}};n(Ai,"AiClassifyExpr"),Ai.key="aiClassify",Ai._sqlNames=["AI_CLASSIFY"],Ai.requiredArgs=new Set(["this","categories"]),Ai.availableArgs=new Set(["this","categories","config"]),Ai.argOrder=["this","categories","config"],Ai.register();var yU=Ai,go=class go extends E{constructor(e={}){super(e)}};n(go,"ArrayAllExpr"),go.key="arrayAll",go.requiredArgs=new Set(["this","expression"]),go.availableArgs=new Set(["this","expression"]),go.argOrder=["this","expression"],go.register();var CU=go,Eo=class Eo extends E{constructor(e={}){super(e)}};n(Eo,"ArrayAnyExpr"),Eo.key="arrayAny",Eo.requiredArgs=new Set(["this","expression"]),Eo.availableArgs=new Set(["this","expression"]),Eo.argOrder=["this","expression"],Eo.register();var bU=Eo,Ao=class Ao extends E{constructor(e={}){super(e)}};n(Ao,"ArrayAppendExpr"),Ao.key="arrayAppend",Ao.requiredArgs=new Set(["this","expression"]),Ao.availableArgs=new Set(["this","expression","nullPropagation"]),Ao.argOrder=["this","expression","nullPropagation"],Ao.register();var sb=Ao,fo=class fo extends E{constructor(e={}){super(e)}};n(fo,"ArrayPrependExpr"),fo.key="arrayPrepend",fo.requiredArgs=new Set(["this","expression"]),fo.availableArgs=new Set(["this","expression","nullPropagation"]),fo.argOrder=["this","expression","nullPropagation"],fo.register();var rb=fo,di=class di extends E{constructor(e={}){super(e)}};n(di,"ArrayConcatExpr"),di.key="arrayConcat",di._sqlNames=["ARRAY_CONCAT","ARRAY_CAT"],di.isVarLenArgs=!0,di.availableArgs=new Set(["this","expressions","nullPropagation"]),di.argOrder=["this","expressions","nullPropagation"],di.register();var hh=di,Wm=class Wm extends E{constructor(e={}){super(e)}};n(Wm,"ArrayCompactExpr"),Wm.key="arrayCompact",Wm.argOrder=["this"],Wm.register();var PU=Wm,jm=class jm extends E{constructor(e={}){super(e)}};n(jm,"ArrayDistinctExpr"),jm.key="arrayDistinct",jm.argOrder=["this","checkNull"],jm.register();var LU=jm,ag=class ag extends E{constructor(e={}){super(e)}};n(ag,"ArrayExceptExpr"),ag.key="arrayExcept",ag.availableArgs=new Set(["this","expression","isMultiset"]),ag.argOrder=["this","expression"],ag.register();var wU=ag,Xm=class Xm extends E{constructor(e={}){super(e)}};n(Xm,"ArrayMaxExpr"),Xm.key="arrayMax",Xm.argOrder=["this"],Xm.register();var MU=Xm,Jm=class Jm extends E{constructor(e={}){super(e)}};n(Jm,"ArrayMinExpr"),Jm.key="arrayMin",Jm.argOrder=["this"],Jm.register();var kU=Jm,xo=class xo extends E{constructor(e={}){super(e)}};n(xo,"ArrayInsertExpr"),xo.key="arrayInsert",xo.requiredArgs=new Set(["this","position","expression"]),xo.availableArgs=new Set(["this","position","expression","offset"]),xo.argOrder=["this","position","expression","offset"],xo.register();var DU=xo,To=class To extends E{constructor(e={}){super(e)}};n(To,"ArrayRemoveAtExpr"),To.key="arrayRemoveAt",To.requiredArgs=new Set(["this","position"]),To.availableArgs=new Set(["this","position"]),To.argOrder=["this","position"],To.register();var qU=To,fi=class fi extends E{constructor(e={}){super(e)}};n(fi,"ArrayConstructCompactExpr"),fi.key="arrayConstructCompact",fi.requiredArgs=new Set,fi.isVarLenArgs=!0,fi.availableArgs=new Set(["expressions"]),fi.argOrder=["expressions"],fi.register();var UU=fi,xi=class xi extends V(U,E){constructor(e={}){super(e)}};n(xi,"ArrayContainsExpr"),xi.key="arrayContains",xi._sqlNames=["ARRAY_CONTAINS","ARRAY_HAS"],xi.argOrder=["this","expression"],xi.requiredArgs=new Set(["this","expression"]),xi.availableArgs=new Set(["this","expression","ensureVariant","checkNull"]),xi.register();var lP=xi,So=class So extends V(U,E){constructor(e={}){super(e)}};n(So,"ArrayContainsAllExpr"),So.key="arrayContainsAll",So._sqlNames=["ARRAY_CONTAINS_ALL","ARRAY_HAS_ALL"],So.requiredArgs=new Set(["this","expression"]),So.availableArgs=new Set(["this","expression"]),So.register();var Fn=So,Ti=class Ti extends E{constructor(e={}){super(e)}};n(Ti,"ArrayFilterExpr"),Ti.key="arrayFilter",Ti._sqlNames=["FILTER","ARRAY_FILTER"],Ti.requiredArgs=new Set(["this","expression"]),Ti.availableArgs=new Set(["this","expression"]),Ti.argOrder=["this","expression"],Ti.register();var Va=Ti,og=class og extends E{constructor(e={}){super(e)}};n(og,"ArrayFirstExpr"),og.key="arrayFirst",og.availableArgs=new Set(["this","expression"]),og.argOrder=["this","expression"],og.register();var uP=og,zm=class zm extends E{constructor(e={}){super(e)}};n(zm,"ArrayLastExpr"),zm.key="arrayLast",zm.argOrder=["this"],zm.register();var hP=zm,cg=class cg extends V(U,E){constructor(e={}){super(e)}};n(cg,"ArrayPositionExpr"),cg.key="arrayPosition",cg.availableArgs=new Set(["this","expression","zeroBased"]),cg.argOrder=["this","expression"],cg.register();var vU=cg,Qm=class Qm extends E{constructor(e={}){super(e)}};n(Qm,"ArrayReverseExpr"),Qm.key="arrayReverse",Qm.argOrder=["this"],Qm.register();var gP=Qm,Ro=class Ro extends E{constructor(e={}){super(e)}};n(Ro,"ArraySliceExpr"),Ro.key="arraySlice",Ro.requiredArgs=new Set(["this","start"]),Ro.availableArgs=new Set(["this","start","end","step","zeroBased"]),Ro.argOrder=["this","start","end","step"],Ro.register();var EP=Ro,Si=class Si extends E{constructor(e={}){super(e)}};n(Si,"ArrayToStringExpr"),Si.key="arrayToString",Si._sqlNames=["ARRAY_TO_STRING","ARRAY_JOIN"],Si.requiredArgs=new Set(["this","expression"]),Si.availableArgs=new Set(["this","expression","null","nullIsEmpty","nullDelimIsNull"]),Si.argOrder=["this","expression","null"],Si.register();var AP=Si,Cr=class Cr extends E{constructor(e={}){super(e)}};n(Cr,"ArrayIntersectExpr"),Cr.key="arrayIntersect",Cr.isVarLenArgs=!0,Cr._sqlNames=["ARRAY_INTERSECT","ARRAY_INTERSECTION"],Cr.requiredArgs=new Set(["expressions"]),Cr.availableArgs=new Set(["expressions","isMultiset"]),Cr.argOrder=["expressions"],Cr.register();var wA=Cr,Ri=class Ri extends E{constructor(e={}){super(e)}};n(Ri,"StPointExpr"),Ri.key="stPoint",Ri._sqlNames=["ST_POINT","ST_MAKEPOINT"],Ri.requiredArgs=new Set(["this","expression"]),Ri.availableArgs=new Set(["this","expression","null"]),Ri.argOrder=["this","expression","null"],Ri.register();var FU=Ri,Oo=class Oo extends E{constructor(e={}){super(e)}};n(Oo,"StDistanceExpr"),Oo.key="stDistance",Oo.requiredArgs=new Set(["this","expression"]),Oo.availableArgs=new Set(["this","expression","useSpheroid"]),Oo.argOrder=["this","expression","useSpheroid"],Oo.register();var BU=Oo,pg=class pg extends E{constructor(e={}){super(e)}};n(pg,"StringExpr"),pg.key="string",pg.availableArgs=new Set(["this","zone"]),pg.argOrder=["this","zone"],pg.register();var dP=pg,mo=class mo extends E{constructor(e={}){super(e)}};n(mo,"StringToArrayExpr"),mo.key="stringToArray",mo._sqlNames=["STRING_TO_ARRAY","SPLIT_BY_STRING","STRTOK_TO_ARRAY"],mo.availableArgs=new Set(["this","expression","null"]),mo.argOrder=["this","expression","null"],mo.register();var $U=mo,lg=class lg extends V(U,E){constructor(e={}){super(e)}};n(lg,"ArrayOverlapsExpr"),lg.key="arrayOverlaps",lg.requiredArgs=new Set(["this","expression"]),lg.availableArgs=new Set(["this","expression","nullsafe"]),lg.register();var Fb=lg,No=class No extends E{constructor(e={}){super(e)}};n(No,"ArraySizeExpr"),No.key="arraySize",No._sqlNames=["ARRAY_SIZE","ARRAY_LENGTH"],No.availableArgs=new Set(["this","expression"]),No.argOrder=["this","expression"],No.register();var Rr=No,ug=class ug extends E{constructor(e={}){super(e)}};n(ug,"ArraySortExpr"),ug.key="arraySort",ug.availableArgs=new Set(["this","expression"]),ug.argOrder=["this","expression"],ug.register();var GU=ug,hg=class hg extends E{constructor(e={}){super(e)}};n(hg,"ArraySumExpr"),hg.key="arraySum",hg.availableArgs=new Set(["this","expression"]),hg.argOrder=["this","expression"],hg.register();var YU=hg,Oi=class Oi extends E{constructor(e={}){super(e)}};n(Oi,"ArraysZipExpr"),Oi.key="arraysZip",Oi.requiredArgs=new Set,Oi.isVarLenArgs=!0,Oi.availableArgs=new Set(["expressions"]),Oi.argOrder=["expressions"],Oi.register();var VU=Oi,Io=class Io extends E{constructor(e={}){super(e)}when(e,t,s={}){let{copy:r=!0}=s,i=$e(this,r);return i.append("ifs",new fe({this:W(e,s),true:W(t,s)})),i}else(e,t={}){let{copy:s=!0}=t,r=$e(this,s);return r.setArgKey("default",W(e,t)),r}};n(Io,"CaseExpr"),Io.key="case",Io.requiredArgs=new Set(["ifs"]),Io.availableArgs=new Set(["this","ifs","default"]),Io.argOrder=["this","ifs","default"],Io.register();var ut=Io,yo=class yo extends E{constructor(e={}){super(e)}get name(){return this.args.this.name||""}get to(){return this.args.to}get outputName(){return this.name}isType(e,t={}){let s=this.args.to;return s&&s instanceof m?s.isType(e):!1}};n(yo,"CastExpr"),yo.key="cast",yo.requiredArgs=new Set(["this","to"]),yo.availableArgs=new Set(["this","to","format","safe","action","default"]),yo.argOrder=["this","to","format","safe","action","default"],yo.register();var z=yo,Zm=class Zm extends E{constructor(e={}){super(e)}};n(Zm,"JustifyDaysExpr"),Zm.key="justifyDays",Zm.argOrder=["this"],Zm.register();var fP=Zm,Km=class Km extends E{constructor(e={}){super(e)}};n(Km,"JustifyHoursExpr"),Km.key="justifyHours",Km.argOrder=["this"],Km.register();var xP=Km,eN=class eN extends E{constructor(e={}){super(e)}};n(eN,"JustifyIntervalExpr"),eN.key="justifyInterval",eN.argOrder=["this"],eN.register();var TP=eN,tN=class tN extends E{constructor(e={}){super(e)}};n(tN,"TryExpr"),tN.key="try",tN.argOrder=["this"],tN.register();var HU=tN,Co=class Co extends E{constructor(e={}){super(e)}};n(Co,"CastToStrTypeExpr"),Co.key="castToStrType",Co.requiredArgs=new Set(["this","to"]),Co.availableArgs=new Set(["this","to"]),Co.argOrder=["this","to"],Co.register();var ib=Co,sN=class sN extends E{constructor(e={}){super(e)}};n(sN,"CheckJsonExpr"),sN.key="checkJson",sN.argOrder=["this"],sN.register();var _U=sN,gg=class gg extends E{constructor(e={}){super(e)}};n(gg,"CheckXmlExpr"),gg.key="checkXml",gg.availableArgs=new Set(["this","disableAutoConvert"]),gg.argOrder=["this","disableAutoConvert"],gg.register();var WU=gg,Eg=class Eg extends V(U,E){constructor(e={}){super(e)}};n(Eg,"CollateExpr"),Eg.key="collate",Eg.requiredArgs=new Set(["this","expression"]),Eg.availableArgs=new Set(["this","expression"]),Eg.register();var MA=Eg,rN=class rN extends E{constructor(e={}){super(e)}};n(rN,"CollationExpr"),rN.key="collation",rN.argOrder=["this"],rN.register();var jU=rN,bo=class bo extends E{constructor(e={}){super(e)}};n(bo,"CeilExpr"),bo.key="ceil",bo._sqlNames=["CEIL","CEILING"],bo.availableArgs=new Set(["this","decimals","to"]),bo.argOrder=["this","decimals","to"],bo.register();var ti=bo,mi=class mi extends E{constructor(e={}){super(e)}};n(mi,"CoalesceExpr"),mi.key="coalesce",mi._sqlNames=["COALESCE","IFNULL","NVL"],mi.isVarLenArgs=!0,mi.availableArgs=new Set(["this","expressions","isNvl","isNull"]),mi.argOrder=["this","expressions","isNvl","isNull"],mi.register();var tt=mi,br=class br extends E{constructor(e={}){super(e)}};n(br,"ChrExpr"),br.key="chr",br._sqlNames=["CHR","CHAR"],br.isVarLenArgs=!0,br.requiredArgs=new Set(["expressions"]),br.availableArgs=new Set(["expressions","charset"]),br.argOrder=["expressions","charset"],br.register();var gh=br,Ni=class Ni extends E{constructor(e={}){super(e)}static fromArgList(e){let t=super.fromArgList(e);return t.getArgKey("safe")===void 0&&t.setArgKey("safe",!0),t.getArgKey("coalesce")===void 0&&t.setArgKey("coalesce",!1),t}};n(Ni,"ConcatExpr"),Ni.key="concat",Ni.isVarLenArgs=!0,Ni.requiredArgs=new Set(["expressions"]),Ni.availableArgs=new Set(["expressions","safe","coalesce"]),Ni.argOrder=["expressions"],Ni.register();var Bt=Ni,Po=class Po extends E{constructor(e={}){super(e)}};n(Po,"ContainsExpr"),Po.key="contains",Po.requiredArgs=new Set(["this","expression"]),Po.availableArgs=new Set(["this","expression","jsonScope"]),Po.argOrder=["this","expression","jsonScope"],Po.register();var SP=Po,iN=class iN extends E{constructor(e={}){super(e)}};n(iN,"ConnectByRootExpr"),iN.key="connectByRoot",iN.argOrder=["this"],iN.register();var Eh=iN,nN=class nN extends E{constructor(e={}){super(e)}};n(nN,"CbrtExpr"),nN.key="cbrt",nN.argOrder=["this"],nN.register();var Ah=nN,Lo=class Lo extends E{constructor(e={}){super(e)}};n(Lo,"CurrentAccountExpr"),Lo.key="currentAccount",Lo.requiredArgs=new Set,Lo.availableArgs=new Set,Lo.argOrder=["this"],Lo.register();var XU=Lo,wo=class wo extends E{constructor(e={}){super(e)}};n(wo,"CurrentAccountNameExpr"),wo.key="currentAccountName",wo.requiredArgs=new Set,wo.availableArgs=new Set,wo.argOrder=["this"],wo.register();var JU=wo,Mo=class Mo extends E{constructor(e={}){super(e)}};n(Mo,"CurrentAvailableRolesExpr"),Mo.key="currentAvailableRoles",Mo.requiredArgs=new Set,Mo.availableArgs=new Set,Mo.argOrder=["this"],Mo.register();var zU=Mo,ko=class ko extends E{constructor(e={}){super(e)}};n(ko,"CurrentClientExpr"),ko.key="currentClient",ko.requiredArgs=new Set,ko.availableArgs=new Set,ko.argOrder=["this"],ko.register();var QU=ko,Do=class Do extends E{constructor(e={}){super(e)}};n(Do,"CurrentIpAddressExpr"),Do.key="currentIpAddress",Do.requiredArgs=new Set,Do.availableArgs=new Set,Do.argOrder=["this"],Do.register();var ZU=Do,qo=class qo extends E{constructor(e={}){super(e)}};n(qo,"CurrentDatabaseExpr"),qo.key="currentDatabase",qo.requiredArgs=new Set,qo.availableArgs=new Set,qo.argOrder=["this"],qo.register();var KU=qo,Ag=class Ag extends E{constructor(e={}){super(e)}};n(Ag,"CurrentSchemasExpr"),Ag.key="currentSchemas",Ag.requiredArgs=new Set,Ag.argOrder=["this"],Ag.register();var ev=Ag,Uo=class Uo extends E{constructor(e={}){super(e)}};n(Uo,"CurrentSecondaryRolesExpr"),Uo.key="currentSecondaryRoles",Uo.requiredArgs=new Set,Uo.availableArgs=new Set,Uo.argOrder=["this"],Uo.register();var tv=Uo,vo=class vo extends E{constructor(e={}){super(e)}};n(vo,"CurrentSessionExpr"),vo.key="currentSession",vo.requiredArgs=new Set,vo.availableArgs=new Set,vo.argOrder=["this"],vo.register();var sv=vo,Fo=class Fo extends E{constructor(e={}){super(e)}};n(Fo,"CurrentStatementExpr"),Fo.key="currentStatement",Fo.requiredArgs=new Set,Fo.availableArgs=new Set,Fo.argOrder=["this"],Fo.register();var rv=Fo,Bo=class Bo extends E{constructor(e={}){super(e)}};n(Bo,"CurrentVersionExpr"),Bo.key="currentVersion",Bo.requiredArgs=new Set,Bo.availableArgs=new Set,Bo.argOrder=["this"],Bo.register();var RP=Bo,$o=class $o extends E{constructor(e={}){super(e)}};n($o,"CurrentTransactionExpr"),$o.key="currentTransaction",$o.requiredArgs=new Set,$o.availableArgs=new Set,$o.argOrder=["this"],$o.register();var iv=$o,Go=class Go extends E{constructor(e={}){super(e)}};n(Go,"CurrentWarehouseExpr"),Go.key="currentWarehouse",Go.requiredArgs=new Set,Go.availableArgs=new Set,Go.argOrder=["this"],Go.register();var nv=Go,dg=class dg extends E{constructor(e={}){super(e)}};n(dg,"CurrentDateExpr"),dg.key="currentDate",dg.requiredArgs=new Set,dg.argOrder=["this"],dg.register();var pr=dg,fg=class fg extends E{constructor(e={}){super(e)}};n(fg,"CurrentDatetimeExpr"),fg.key="currentDatetime",fg.requiredArgs=new Set,fg.argOrder=["this"],fg.register();var OP=fg,xg=class xg extends E{constructor(e={}){super(e)}};n(xg,"CurrentTimeExpr"),xg.key="currentTime",xg.requiredArgs=new Set,xg.argOrder=["this"],xg.register();var si=xg,Tg=class Tg extends E{constructor(e={}){super(e)}};n(Tg,"LocaltimeExpr"),Tg.key="localtime",Tg.requiredArgs=new Set,Tg.argOrder=["this"],Tg.register();var dh=Tg,Sg=class Sg extends E{constructor(e={}){super(e)}};n(Sg,"LocaltimestampExpr"),Sg.key="localtimestamp",Sg.requiredArgs=new Set,Sg.argOrder=["this"],Sg.register();var nb=Sg,Rg=class Rg extends E{constructor(e={}){super(e)}};n(Rg,"SystimestampExpr"),Rg.key="systimestamp",Rg.requiredArgs=new Set,Rg.argOrder=["this"],Rg.register();var av=Rg,Ii=class Ii extends E{constructor(e={}){super(e)}};n(Ii,"CurrentTimestampExpr"),Ii.key="currentTimestamp",Ii._sqlNames=["CURRENT_TIMESTAMP"],Ii.requiredArgs=new Set,Ii.availableArgs=new Set(["this","sysdate"]),Ii.argOrder=["this","sysdate"],Ii.register();var ri=Ii,Yo=class Yo extends E{constructor(e={}){super(e)}};n(Yo,"CurrentTimestampLtzExpr"),Yo.key="currentTimestampLtz",Yo.requiredArgs=new Set,Yo.availableArgs=new Set,Yo.argOrder=["this"],Yo.register();var mP=Yo,Vo=class Vo extends E{constructor(e={}){super(e)}};n(Vo,"CurrentTimezoneExpr"),Vo.key="currentTimezone",Vo.requiredArgs=new Set,Vo.availableArgs=new Set,Vo.argOrder=["this"],Vo.register();var ov=Vo,Ho=class Ho extends E{constructor(e={}){super(e)}};n(Ho,"CurrentOrganizationNameExpr"),Ho.key="currentOrganizationName",Ho.requiredArgs=new Set,Ho.availableArgs=new Set,Ho.argOrder=["this"],Ho.register();var cv=Ho,Og=class Og extends E{constructor(e={}){super(e)}};n(Og,"CurrentSchemaExpr"),Og.key="currentSchema",Og.requiredArgs=new Set,Og.argOrder=["this"],Og.register();var NP=Og,mg=class mg extends E{constructor(e={}){super(e)}};n(mg,"CurrentUserExpr"),mg.key="currentUser",mg.requiredArgs=new Set,mg.argOrder=["this"],mg.register();var fh=mg,_o=class _o extends E{constructor(e={}){super(e)}};n(_o,"CurrentCatalogExpr"),_o.key="currentCatalog",_o.requiredArgs=new Set,_o.availableArgs=new Set,_o.argOrder=["this"],_o.register();var Mh=_o,Wo=class Wo extends E{constructor(e={}){super(e)}};n(Wo,"CurrentRegionExpr"),Wo.key="currentRegion",Wo.requiredArgs=new Set,Wo.availableArgs=new Set,Wo.argOrder=["this"],Wo.register();var pv=Wo,jo=class jo extends E{constructor(e={}){super(e)}};n(jo,"CurrentRoleExpr"),jo.key="currentRole",jo.requiredArgs=new Set,jo.availableArgs=new Set,jo.argOrder=["this"],jo.register();var ab=jo,Xo=class Xo extends E{constructor(e={}){super(e)}};n(Xo,"CurrentRoleTypeExpr"),Xo.key="currentRoleType",Xo.requiredArgs=new Set,Xo.availableArgs=new Set,Xo.argOrder=["this"],Xo.register();var lv=Xo,Jo=class Jo extends E{constructor(e={}){super(e)}};n(Jo,"CurrentOrganizationUserExpr"),Jo.key="currentOrganizationUser",Jo.requiredArgs=new Set,Jo.availableArgs=new Set,Jo.argOrder=["this"],Jo.register();var uv=Jo,zo=class zo extends E{constructor(e={}){super(e)}};n(zo,"SessionUserExpr"),zo.key="sessionUser",zo.requiredArgs=new Set,zo.availableArgs=new Set,zo.argOrder=["this"],zo.register();var kh=zo,Qo=class Qo extends E{constructor(e={}){super(e)}};n(Qo,"UtcDateExpr"),Qo.key="utcDate",Qo.requiredArgs=new Set,Qo.availableArgs=new Set,Qo.argOrder=["this"],Qo.register();var Bb=Qo,Ng=class Ng extends E{constructor(e={}){super(e)}};n(Ng,"UtcTimeExpr"),Ng.key="utcTime",Ng.requiredArgs=new Set,Ng.argOrder=["this"],Ng.register();var $b=Ng,Ig=class Ig extends E{constructor(e={}){super(e)}};n(Ig,"UtcTimestampExpr"),Ig.key="utcTimestamp",Ig.requiredArgs=new Set,Ig.argOrder=["this"],Ig.register();var Gb=Ig,Zo=class Zo extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(Zo,"DateAddExpr"),Zo.key="dateAdd",Zo.argOrder=["this","expression","unit"],Zo.requiredArgs=new Set(["this","expression"]),Zo.availableArgs=new Set(["this","expression","unit"]),Zo.register();var xt=Zo,Ko=class Ko extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(Ko,"DateBinExpr"),Ko.key="dateBin",Ko.argOrder=["this","expression","unit","zone","origin"],Ko.requiredArgs=new Set(["this","expression"]),Ko.availableArgs=new Set(["this","expression","unit","zone","origin"]),Ko.register();var hv=Ko,ec=class ec extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(ec,"DateSubExpr"),ec.key="dateSub",ec.argOrder=["this","expression","unit"],ec.requiredArgs=new Set(["this","expression"]),ec.availableArgs=new Set(["this","expression","unit"]),ec.register();var jt=ec,yi=class yi extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(yi,"DateDiffExpr"),yi.key="dateDiff",yi.argOrder=["this","expression","unit","zone","bigInt","datePartBoundary"],yi._sqlNames=["DATEDIFF","DATE_DIFF"],yi.requiredArgs=new Set(["this","expression"]),yi.availableArgs=new Set(["this","expression","unit","zone","bigInt","datePartBoundary"]),yi.register();var _s=yi,Ci=class Ci extends E{constructor(e={}){let t=e.unabbreviate??!0,s=e.unit;if(te.isVarLike(s)&&!(s instanceof $&&s.parts.length!==1)){let r=s.name.toUpperCase();t&&r in te.UNABBREVIATED_UNIT_NAME&&(r=te.UNABBREVIATED_UNIT_NAME[r]),e.unit=N.string(r)}delete e.unabbreviate,super(e)}get unit(){return this.args.unit}};n(Ci,"DateTruncExpr"),Ci.key="dateTrunc",Ci._sqlNames=["DATE_TRUNC"],Ci.requiredArgs=new Set(["unit","this"]),Ci.availableArgs=new Set(["unit","this","zone","inputTypePreserved"]),Ci.argOrder=["unit","this","zone","inputTypePreserved"],Ci.register();var ls=Ci,yg=class yg extends E{constructor(e={}){super(e)}};n(yg,"DatetimeExpr"),yg.key="datetime",yg.availableArgs=new Set(["this","expression"]),yg.argOrder=["this","expression"],yg.register();var IP=yg,tc=class tc extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(tc,"DatetimeAddExpr"),tc.key="datetimeAdd",tc.argOrder=["this","expression","unit"],tc.requiredArgs=new Set(["this","expression"]),tc.availableArgs=new Set(["this","expression","unit"]),tc.register();var Ds=tc,sc=class sc extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(sc,"DatetimeSubExpr"),sc.key="datetimeSub",sc.argOrder=["this","expression","unit"],sc.requiredArgs=new Set(["this","expression"]),sc.availableArgs=new Set(["this","expression","unit"]),sc.register();var Qs=sc,rc=class rc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(rc,"DatetimeDiffExpr"),rc.key="datetimeDiff",rc.argOrder=["this","expression","unit"],rc.requiredArgs=new Set(["this","expression"]),rc.availableArgs=new Set(["this","expression","unit"]),rc.register();var yP=rc,ic=class ic extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(ic,"DatetimeTruncExpr"),ic.key="datetimeTrunc",ic.argOrder=["this","unit","zone"],ic.requiredArgs=new Set(["this","unit"]),ic.availableArgs=new Set(["this","unit","zone"]),ic.register();var gv=ic,aN=class aN extends E{constructor(e={}){super(e)}};n(aN,"DateFromUnixDateExpr"),aN.key="dateFromUnixDate",aN.argOrder=["this"],aN.register();var Ev=aN,Cg=class Cg extends E{constructor(e={}){super(e)}};n(Cg,"DayOfWeekExpr"),Cg.key="dayOfWeek",Cg._sqlNames=["DAY_OF_WEEK","DAYOFWEEK"],Cg.argOrder=["this"],Cg.register();var CP=Cg,bg=class bg extends E{constructor(e={}){super(e)}};n(bg,"DayOfWeekIsoExpr"),bg.key="dayOfWeekIso",bg._sqlNames=["DAYOFWEEK_ISO","ISODOW"],bg.argOrder=["this"],bg.register();var bP=bg,Pg=class Pg extends E{constructor(e={}){super(e)}};n(Pg,"DayOfMonthExpr"),Pg.key="dayOfMonth",Pg.argOrder=["this"],Pg._sqlNames=["DAY_OF_MONTH","DAYOFMONTH"],Pg.register();var PP=Pg,Lg=class Lg extends E{constructor(e={}){super(e)}};n(Lg,"DayOfYearExpr"),Lg.key="dayOfYear",Lg.argOrder=["this"],Lg._sqlNames=["DAY_OF_YEAR","DAYOFYEAR"],Lg.register();var LP=Lg,wg=class wg extends E{constructor(e={}){super(e)}};n(wg,"DaynameExpr"),wg.key="dayname",wg.availableArgs=new Set(["this","abbreviated"]),wg.argOrder=["this","abbreviated"],wg.register();var wP=wg,oN=class oN extends E{constructor(e={}){super(e)}};n(oN,"ToDaysExpr"),oN.key="toDays",oN.argOrder=["this"],oN.register();var Av=oN,cN=class cN extends E{static sqlNames(){return["WEEK_OF_YEAR","WEEKOFYEAR"]}constructor(e={}){super(e)}};n(cN,"WeekOfYearExpr"),cN.key="weekOfYear",cN.argOrder=["this"],cN.register();var MP=cN,Mg=class Mg extends E{constructor(e={}){super(e)}};n(Mg,"YearOfWeekExpr"),Mg.key="yearOfWeek",Mg.argOrder=["this"],Mg._sqlNames=["YEAR_OF_WEEK","YEAROFWEEK"],Mg.register();var kP=Mg,kg=class kg extends E{constructor(e={}){super(e)}};n(kg,"YearOfWeekIsoExpr"),kg.key="yearOfWeekIso",kg.argOrder=["this"],kg._sqlNames=["YEAR_OF_WEEK_ISO","YEAROFWEEKISO"],kg.register();var DP=kg,nc=class nc extends E{constructor(e={}){super(e)}};n(nc,"MonthsBetweenExpr"),nc.key="monthsBetween",nc.requiredArgs=new Set(["this","expression"]),nc.availableArgs=new Set(["this","expression","roundoff"]),nc.argOrder=["this","expression","roundoff"],nc.register();var dv=nc,ac=class ac extends E{constructor(e={}){super(e)}};n(ac,"MakeIntervalExpr"),ac.key="makeInterval",ac.requiredArgs=new Set,ac.availableArgs=new Set(["year","month","week","day","hour","minute","second"]),ac.argOrder=["year","month","week","day","hour","minute","second"],ac.register();var qP=ac,bi=class bi extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(bi,"LastDayExpr"),bi.key="lastDay",bi._sqlNames=["LAST_DAY","LAST_DAY_OF_MONTH"],bi.argOrder=["this","unit"],bi.requiredArgs=new Set(["this"]),bi.availableArgs=new Set(["this","unit"]),bi.register();var _a=bi,oc=class oc extends E{constructor(e={}){super(e)}};n(oc,"PreviousDayExpr"),oc.key="previousDay",oc.requiredArgs=new Set(["this","expression"]),oc.availableArgs=new Set(["this","expression"]),oc.argOrder=["this","expression"],oc.register();var fv=oc,pN=class pN extends E{constructor(e={}){super(e)}};n(pN,"LaxBoolExpr"),pN.key="laxBool",pN.argOrder=["this"],pN.register();var xv=pN,lN=class lN extends E{constructor(e={}){super(e)}};n(lN,"LaxFloat64Expr"),lN.key="laxFloat64",lN.argOrder=["this"],lN.register();var Tv=lN,uN=class uN extends E{constructor(e={}){super(e)}};n(uN,"LaxInt64Expr"),uN.key="laxInt64",uN.argOrder=["this"],uN.register();var Sv=uN,hN=class hN extends E{constructor(e={}){super(e)}};n(hN,"LaxStringExpr"),hN.key="laxString",hN.argOrder=["this"],hN.register();var Rv=hN,cc=class cc extends E{constructor(e={}){super(e)}};n(cc,"ExtractExpr"),cc.key="extract",cc.requiredArgs=new Set(["this","expression"]),cc.availableArgs=new Set(["this","expression"]),cc.argOrder=["this","expression"],cc.register();var lr=cc,pc=class pc extends V(E,Us){constructor(e={}){super(e)}};n(pc,"ExistsExpr"),pc.key="exists",pc.argOrder=["this","expression"],pc.requiredArgs=new Set(["this"]),pc.availableArgs=new Set(["this","expression"]),pc.register();var Ys=pc,Pi=class Pi extends E{constructor(e={}){super(e)}};n(Pi,"EltExpr"),Pi.key="elt",Pi.isVarLenArgs=!0,Pi.requiredArgs=new Set(["this","expressions"]),Pi.availableArgs=new Set(["this","expressions"]),Pi.argOrder=["this","expressions"],Pi.register();var Ov=Pi,lc=class lc extends E{constructor(e={}){super(e)}};n(lc,"TimestampExpr"),lc.key="timestamp",lc.requiredArgs=new Set,lc.availableArgs=new Set(["this","zone","withTz"]),lc.argOrder=["this","zone","withTz"],lc.register();var Lh=lc,uc=class uc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(uc,"TimestampAddExpr"),uc.key="timestampAdd",uc.argOrder=["this","expression","unit"],uc.requiredArgs=new Set(["this","expression"]),uc.availableArgs=new Set(["this","expression","unit"]),uc.register();var Fh=uc,hc=class hc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(hc,"TimestampSubExpr"),hc.key="timestampSub",hc.argOrder=["this","expression","unit"],hc.requiredArgs=new Set(["this","expression"]),hc.availableArgs=new Set(["this","expression","unit"]),hc.register();var UP=hc,gc=class gc extends V(E,te){static sqlNames(){return["TIMESTAMPDIFF","TIMESTAMP_DIFF"]}constructor(e={}){super(te.initTimeArgs(e))}};n(gc,"TimestampDiffExpr"),gc.key="timestampDiff",gc.argOrder=["this","expression","unit"],gc.requiredArgs=new Set(["this","expression"]),gc.availableArgs=new Set(["this","expression","unit"]),gc.register();var Dh=gc,Ec=class Ec extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(Ec,"TimestampTruncExpr"),Ec.key="timestampTrunc",Ec.argOrder=["this","unit","zone","inputTypePreserved"],Ec.requiredArgs=new Set(["this","unit"]),Ec.availableArgs=new Set(["this","unit","zone","inputTypePreserved"]),Ec.register();var Sn=Ec,Ac=class Ac extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(Ac,"TimeSliceExpr"),Ac.key="timeSlice",Ac.argOrder=["this","expression","unit","kind"],Ac.requiredArgs=new Set(["this","expression","unit"]),Ac.availableArgs=new Set(["this","expression","unit","kind"]),Ac.register();var mv=Ac,dc=class dc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(dc,"TimeAddExpr"),dc.key="timeAdd",dc.argOrder=["this","expression","unit"],dc.requiredArgs=new Set(["this","expression"]),dc.availableArgs=new Set(["this","expression","unit"]),dc.register();var Bh=dc,fc=class fc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(fc,"TimeSubExpr"),fc.key="timeSub",fc.argOrder=["this","expression","unit"],fc.requiredArgs=new Set(["this","expression"]),fc.availableArgs=new Set(["this","expression","unit"]),fc.register();var vP=fc,xc=class xc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(xc,"TimeDiffExpr"),xc.key="timeDiff",xc.argOrder=["this","expression","unit"],xc.requiredArgs=new Set(["this","expression"]),xc.availableArgs=new Set(["this","expression","unit"]),xc.register();var FP=xc,Tc=class Tc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(Tc,"TimeTruncExpr"),Tc.key="timeTrunc",Tc.argOrder=["this","unit","zone"],Tc.requiredArgs=new Set(["this","unit"]),Tc.availableArgs=new Set(["this","unit","zone"]),Tc.register();var Nv=Tc,Li=class Li extends E{constructor(e={}){super(e)}};n(Li,"DateFromPartsExpr"),Li.key="dateFromParts",Li._sqlNames=["DATE_FROM_PARTS","DATEFROMPARTS"],Li.requiredArgs=new Set(["year"]),Li.availableArgs=new Set(["year","month","day","allowOverflow"]),Li.argOrder=["year","month","day","allowOverflow"],Li.register();var BP=Li,Sc=class Sc extends E{static sqlNames(){return["TIME_FROM_PARTS","TIMEFROMPARTS"]}constructor(e={}){super(e)}};n(Sc,"TimeFromPartsExpr"),Sc.key="timeFromParts",Sc.requiredArgs=new Set(["hour","min","sec"]),Sc.availableArgs=new Set(["hour","min","sec","nano","fractions","precision","overflow"]),Sc.argOrder=["hour","min","sec","nano","fractions","precision","overflow"],Sc.register();var Iv=Sc,gN=class gN extends E{constructor(e={}){super(e)}};n(gN,"DateStrToDateExpr"),gN.key="dateStrToDate",gN.argOrder=["this"],gN.register();var $P=gN,EN=class EN extends E{constructor(e={}){super(e)}};n(EN,"DateToDateStrExpr"),EN.key="dateToDateStr",EN.argOrder=["this"],EN.register();var GP=EN,AN=class AN extends E{constructor(e={}){super(e)}};n(AN,"DateToDiExpr"),AN.key="dateToDi",AN.argOrder=["this"],AN.register();var YP=AN,wi=class wi extends E{constructor(e={}){super(e)}};n(wi,"DateExpr"),wi.key="date",wi.requiredArgs=new Set,wi.isVarLenArgs=!0,wi.availableArgs=new Set(["this","zone","expressions"]),wi.argOrder=["this","zone","expressions"],wi.register();var pi=wi,dN=class dN extends E{constructor(e={}){super(e)}};n(dN,"DayExpr"),dN.key="day",dN.argOrder=["this"],dN.register();var Nr=dN,Rc=class Rc extends E{constructor(e={}){super(e)}};n(Rc,"DecodeExpr"),Rc.key="decode",Rc.requiredArgs=new Set(["this","charset"]),Rc.availableArgs=new Set(["this","charset","replace"]),Rc.argOrder=["this","charset","replace"],Rc.register();var ob=Rc,Mi=class Mi extends E{constructor(e={}){super(e)}};n(Mi,"DecodeCaseExpr"),Mi.key="decodeCase",Mi.isVarLenArgs=!0,Mi.requiredArgs=new Set(["expressions"]),Mi.availableArgs=new Set(["expressions"]),Mi.argOrder=["expressions"],Mi.register();var cb=Mi,Oc=class Oc extends E{constructor(e={}){super(e)}};n(Oc,"DecryptExpr"),Oc.key="decrypt",Oc.requiredArgs=new Set(["this","passphrase"]),Oc.availableArgs=new Set(["this","passphrase","aad","encryptionMethod","safe"]),Oc.argOrder=["this","passphrase","aad","encryptionMethod","safe"],Oc.register();var yv=Oc,mc=class mc extends E{constructor(e={}){super(e)}};n(mc,"DecryptRawExpr"),mc.key="decryptRaw",mc.requiredArgs=new Set(["this","key","iv"]),mc.availableArgs=new Set(["this","key","iv","aad","encryptionMethod","aead","safe"]),mc.argOrder=["this","key","iv","aad","encryptionMethod","aead","safe"],mc.register();var Cv=mc,fN=class fN extends E{constructor(e={}){super(e)}};n(fN,"DiToDateExpr"),fN.key="diToDate",fN.argOrder=["this"],fN.register();var VP=fN,Nc=class Nc extends E{constructor(e={}){super(e)}};n(Nc,"EncodeExpr"),Nc.key="encode",Nc.requiredArgs=new Set(["this","charset"]),Nc.availableArgs=new Set(["this","charset"]),Nc.argOrder=["this","charset"],Nc.register();var bv=Nc,Ic=class Ic extends E{constructor(e={}){super(e)}};n(Ic,"EncryptExpr"),Ic.key="encrypt",Ic.requiredArgs=new Set(["this","passphrase"]),Ic.availableArgs=new Set(["this","passphrase","aad","encryptionMethod"]),Ic.argOrder=["this","passphrase","aad","encryptionMethod"],Ic.register();var Pv=Ic,yc=class yc extends E{constructor(e={}){super(e)}};n(yc,"EncryptRawExpr"),yc.key="encryptRaw",yc.requiredArgs=new Set(["this","key","iv"]),yc.availableArgs=new Set(["this","key","iv","aad","encryptionMethod"]),yc.argOrder=["this","key","iv","aad","encryptionMethod"],yc.register();var Lv=yc,Cc=class Cc extends E{constructor(e={}){super(e)}};n(Cc,"EqualNullExpr"),Cc.key="equalNull",Cc.requiredArgs=new Set(["this","expression"]),Cc.availableArgs=new Set(["this","expression"]),Cc.argOrder=["this","expression"],Cc.register();var wv=Cc,xN=class xN extends E{constructor(e={}){super(e)}};n(xN,"ExpExpr"),xN.key="exp",xN.argOrder=["this"],xN.register();var HP=xN,TN=class TN extends E{constructor(e={}){super(e)}};n(TN,"FactorialExpr"),TN.key="factorial",TN.argOrder=["this"],TN.register();var Mv=TN,ki=class ki extends V(E,yt){constructor(e={}){super(e)}};n(ki,"ExplodeExpr"),ki.key="explode",ki.argOrder=["this","expressions"],ki.isVarLenArgs=!0,ki.requiredArgs=new Set(["this"]),ki.availableArgs=new Set(["this","expressions"]),ki.register();var Xt=ki,SN=class SN extends E{constructor(e={}){super(e)}};n(SN,"InlineExpr"),SN.key="inline",SN.argOrder=["this"],SN.register();var Ib=SN,bc=class bc extends V(E,yt){constructor(e={}){super(e)}get selects(){let e=super.selects,t=this.args.offset;if(t){let s=t===!0?K("offset"):t;return[...e,s]}return e}};n(bc,"UnnestExpr"),bc.key="unnest",bc.argOrder=["expressions","alias","offset","explodeArray"],bc.requiredArgs=new Set(["expressions"]),bc.availableArgs=new Set(["expressions","alias","offset","explodeArray"]),bc.register();var Ee=bc,Dg=class Dg extends E{constructor(e={}){super(e)}};n(Dg,"FloorExpr"),Dg.key="floor",Dg.availableArgs=new Set(["this","decimals","to"]),Dg.argOrder=["this","decimals","to"],Dg.register();var xh=Dg,RN=class RN extends E{constructor(e={}){super(e)}};n(RN,"FromBase32Expr"),RN.key="fromBase32",RN.argOrder=["this"],RN.register();var _P=RN,ON=class ON extends E{constructor(e={}){super(e)}};n(ON,"FromBase64Expr"),ON.key="fromBase64",ON.argOrder=["this"],ON.register();var WP=ON,mN=class mN extends E{constructor(e={}){super(e)}};n(mN,"ToBase32Expr"),mN.key="toBase32",mN.argOrder=["this"],mN.register();var jP=mN,NN=class NN extends E{constructor(e={}){super(e)}};n(NN,"ToBase64Expr"),NN.key="toBase64",NN.argOrder=["this"],NN.register();var XP=NN,qg=class qg extends E{constructor(e={}){super(e)}};n(qg,"ToBinaryExpr"),qg.key="toBinary",qg.availableArgs=new Set(["this","format","safe"]),qg.argOrder=["this","format","safe"],qg.register();var kv=qg,Ug=class Ug extends E{constructor(e={}){super(e)}};n(Ug,"Base64DecodeBinaryExpr"),Ug.key="base64DecodeBinary",Ug.availableArgs=new Set(["this","alphabet"]),Ug.argOrder=["this","alphabet"],Ug.register();var Dv=Ug,vg=class vg extends E{constructor(e={}){super(e)}};n(vg,"Base64DecodeStringExpr"),vg.key="base64DecodeString",vg.availableArgs=new Set(["this","alphabet"]),vg.argOrder=["this","alphabet"],vg.register();var qv=vg,Fg=class Fg extends E{constructor(e={}){super(e)}};n(Fg,"Base64EncodeExpr"),Fg.key="base64Encode",Fg.availableArgs=new Set(["this","maxLineLength","alphabet"]),Fg.argOrder=["this","maxLineLength","alphabet"],Fg.register();var Uv=Fg,Bg=class Bg extends E{constructor(e={}){super(e)}};n(Bg,"TryBase64DecodeBinaryExpr"),Bg.key="tryBase64DecodeBinary",Bg.availableArgs=new Set(["this","alphabet"]),Bg.argOrder=["this","alphabet"],Bg.register();var vv=Bg,$g=class $g extends E{constructor(e={}){super(e)}};n($g,"TryBase64DecodeStringExpr"),$g.key="tryBase64DecodeString",$g.availableArgs=new Set(["this","alphabet"]),$g.argOrder=["this","alphabet"],$g.register();var Fv=$g,IN=class IN extends E{constructor(e={}){super(e)}};n(IN,"TryHexDecodeBinaryExpr"),IN.key="tryHexDecodeBinary",IN.argOrder=["this"],IN.register();var Bv=IN,yN=class yN extends E{constructor(e={}){super(e)}};n(yN,"TryHexDecodeStringExpr"),yN.key="tryHexDecodeString",yN.argOrder=["this"],yN.register();var $v=yN,Gg=class Gg extends E{constructor(e={}){super(e)}};n(Gg,"FromIso8601TimestampExpr"),Gg.key="fromIso8601Timestamp",Gg.argOrder=["this"],Gg._sqlNames=["FROM_ISO8601_TIMESTAMP"],Gg.register();var Gv=Gg,Pc=class Pc extends E{constructor(e={}){super(e)}};n(Pc,"GapFillExpr"),Pc.key="gapFill",Pc.requiredArgs=new Set(["this","tsColumn","bucketWidth"]),Pc.availableArgs=new Set(["this","tsColumn","bucketWidth","partitioningColumns","valueColumns","origin","ignoreNulls"]),Pc.argOrder=["this","tsColumn","bucketWidth","partitioningColumns","valueColumns","origin","ignoreNulls"],Pc.register();var pb=Pc,Lc=class Lc extends E{constructor(e={}){super(e)}};n(Lc,"GenerateDateArrayExpr"),Lc.key="generateDateArray",Lc.requiredArgs=new Set(["start","end"]),Lc.availableArgs=new Set(["start","end","step"]),Lc.argOrder=["start","end","step"],Lc.register();var ii=Lc,wc=class wc extends E{constructor(e={}){super(e)}};n(wc,"GenerateTimestampArrayExpr"),wc.key="generateTimestampArray",wc.requiredArgs=new Set(["start","end","step"]),wc.availableArgs=new Set(["start","end","step"]),wc.argOrder=["start","end","step"],wc.register();var JP=wc,Mc=class Mc extends E{constructor(e={}){super(e)}};n(Mc,"GetExtractExpr"),Mc.key="getExtract",Mc.requiredArgs=new Set(["this","expression"]),Mc.availableArgs=new Set(["this","expression"]),Mc.argOrder=["this","expression"],Mc.register();var Yv=Mc,kc=class kc extends E{static sqlNames(){return["GETBIT","GET_BIT"]}constructor(e={}){super(e)}};n(kc,"GetbitExpr"),kc.key="getbit",kc.requiredArgs=new Set(["this","expression"]),kc.availableArgs=new Set(["this","expression","zeroIsMsb"]),kc.argOrder=["this","expression","zeroIsMsb"],kc.register();var zP=kc,Di=class Di extends E{constructor(e={}){super(e)}};n(Di,"GreatestExpr"),Di.key="greatest",Di.isVarLenArgs=!0,Di.requiredArgs=new Set(["this","ignoreNulls"]),Di.availableArgs=new Set(["this","expressions","ignoreNulls"]),Di.argOrder=["this","expressions","ignoreNulls"],Di.register();var ni=Di,CN=class CN extends E{constructor(e={}){super(e)}};n(CN,"HexExpr"),CN.key="hex",CN.argOrder=["this"],CN.register();var $a=CN,bN=class bN extends E{constructor(e={}){super(e)}};n(bN,"HexDecodeStringExpr"),bN.key="hexDecodeString",bN.argOrder=["this"],bN.register();var Vv=bN,Yg=class Yg extends E{constructor(e={}){super(e)}};n(Yg,"HexEncodeExpr"),Yg.key="hexEncode",Yg.availableArgs=new Set(["this","case"]),Yg.argOrder=["this","case"],Yg.register();var Hv=Yg,PN=class PN extends E{constructor(e={}){super(e)}};n(PN,"HourExpr"),PN.key="hour",PN.argOrder=["this"],PN.register();var QP=PN,LN=class LN extends E{constructor(e={}){super(e)}};n(LN,"MinuteExpr"),LN.key="minute",LN.argOrder=["this"],LN.register();var _v=LN,wN=class wN extends E{constructor(e={}){super(e)}};n(wN,"SecondExpr"),wN.key="second",wN.argOrder=["this"],wN.register();var Wv=wN,Vg=class Vg extends E{constructor(e={}){super(e)}};n(Vg,"CompressExpr"),Vg.key="compress",Vg.availableArgs=new Set(["this","method"]),Vg.argOrder=["this","method"],Vg.register();var jv=Vg,Dc=class Dc extends E{constructor(e={}){super(e)}};n(Dc,"DecompressBinaryExpr"),Dc.key="decompressBinary",Dc.requiredArgs=new Set(["this","method"]),Dc.availableArgs=new Set(["this","method"]),Dc.argOrder=["this","method"],Dc.register();var Xv=Dc,qc=class qc extends E{constructor(e={}){super(e)}};n(qc,"DecompressStringExpr"),qc.key="decompressString",qc.requiredArgs=new Set(["this","method"]),qc.availableArgs=new Set(["this","method"]),qc.argOrder=["this","method"],qc.register();var Jv=qc,qi=class qi extends E{constructor(e={}){super(e)}};n(qi,"IfExpr"),qi.key="if",qi._sqlNames=["IF","IIF"],qi.requiredArgs=new Set(["this","true"]),qi.availableArgs=new Set(["this","true","false"]),qi.argOrder=["this","true","false"],qi.register();var fe=qi,Uc=class Uc extends E{constructor(e={}){super(e)}};n(Uc,"NullifExpr"),Uc.key="nullif",Uc.requiredArgs=new Set(["this","expression"]),Uc.availableArgs=new Set(["this","expression"]),Uc.argOrder=["this","expression"],Uc.register();var qh=Uc,Hg=class Hg extends E{constructor(e={}){super(e)}};n(Hg,"InitcapExpr"),Hg.key="initcap",Hg.availableArgs=new Set(["this","expression"]),Hg.argOrder=["this","expression"],Hg.register();var Th=Hg,MN=class MN extends E{constructor(e={}){super(e)}};n(MN,"IsAsciiExpr"),MN.key="isAscii",MN.argOrder=["this"],MN.register();var zv=MN,_g=class _g extends E{constructor(e={}){super(e)}};n(_g,"IsNanExpr"),_g.key="isNan",_g.argOrder=["this"],_g._sqlNames=["IS_NAN","ISNAN"],_g.register();var ZP=_g,kN=class kN extends E{constructor(e={}){super(e)}};n(kN,"Int64Expr"),kN.key="int64",kN.argOrder=["this"],kN.register();var Uh=kN,Wg=class Wg extends E{constructor(e={}){super(e)}};n(Wg,"IsInfExpr"),Wg.key="isInf",Wg.argOrder=["this"],Wg._sqlNames=["IS_INF","ISINF"],Wg.register();var KP=Wg,DN=class DN extends E{constructor(e={}){super(e)}};n(DN,"IsNullValueExpr"),DN.key="isNullValue",DN.argOrder=["this"],DN.register();var Qv=DN,qN=class qN extends E{constructor(e={}){super(e)}};n(qN,"IsArrayExpr"),qN.key="isArray",qN.argOrder=["this"],qN.register();var Zv=qN,vc=class vc extends E{constructor(e={}){super(e)}};n(vc,"FormatExpr"),vc.key="format",vc.isVarLenArgs=!0,vc.availableArgs=new Set(["this","expressions"]),vc.argOrder=["this","expressions"],vc.register();var Kv=vc,Fc=class Fc extends E{constructor(e={}){super(e)}};n(Fc,"JsonKeysExpr"),Fc.key="jsonKeys",Fc.isVarLenArgs=!0,Fc.availableArgs=new Set(["this","expression","expressions"]),Fc.argOrder=["this","expression","expressions"],Fc.register();var lb=Fc,jg=class jg extends E{constructor(e={}){super(e)}};n(jg,"JsonKeysAtDepthExpr"),jg.key="jsonKeysAtDepth",jg.availableArgs=new Set(["this","expression","mode"]),jg.argOrder=["this","expression","mode"],jg.register();var eF=jg,Xg=class Xg extends E{constructor(e={}){super(e)}};n(Xg,"JsonObjectExpr"),Xg.key="jsonObject",Xg.availableArgs=new Set(["expressions","nullHandling","uniqueKeys","returnType","encoding"]),Xg.argOrder=["nullHandling","uniqueKeys","returnType","encoding"],Xg.register();var Sh=Xg,Jg=class Jg extends E{constructor(e={}){super(e)}static fromArgList(e){return new this({expressions:e})}};n(Jg,"JsonArrayExpr"),Jg.key="jsonArray",Jg.availableArgs=new Set(["expressions","nullHandling","returnType","strict"]),Jg.argOrder=["nullHandling","returnType","strict"],Jg.register();var tF=Jg,Bc=class Bc extends E{constructor(e={}){super(e)}};n(Bc,"JsonExistsExpr"),Bc.key="jsonExists",Bc.requiredArgs=new Set(["this","path"]),Bc.availableArgs=new Set(["this","path","passing","onCondition","fromDcolonqmark"]),Bc.argOrder=["path","passing","onCondition","fromDcolonqmark"],Bc.register();var sF=Bc,Pr=class Pr extends E{constructor(e={}){super(e)}};n(Pr,"JsonSetExpr"),Pr.key="jsonSet",Pr.isVarLenArgs=!0,Pr._sqlNames=["JSON_SET"],Pr.requiredArgs=new Set(["this","expressions"]),Pr.availableArgs=new Set(["this","expressions"]),Pr.argOrder=["this","expressions"],Pr.register();var rF=Pr,$c=class $c extends E{constructor(e={}){super(e)}};n($c,"JsonStripNullsExpr"),$c.key="jsonStripNulls",$c._sqlNames=["JSON_STRIP_NULLS"],$c.availableArgs=new Set(["this","expression","includeArrays","removeEmpty"]),$c.argOrder=["this","expression","includeArrays","removeEmpty"],$c.register();var iF=$c,zg=class zg extends E{constructor(e={}){super(e)}};n(zg,"JsonValueArrayExpr"),zg.key="jsonValueArray",zg.availableArgs=new Set(["this","expression"]),zg.argOrder=["this","expression"],zg.register();var nF=zg,Lr=class Lr extends E{constructor(e={}){super(e)}};n(Lr,"JsonRemoveExpr"),Lr.key="jsonRemove",Lr.isVarLenArgs=!0,Lr._sqlNames=["JSON_REMOVE"],Lr.requiredArgs=new Set(["this","expressions"]),Lr.availableArgs=new Set(["this","expressions"]),Lr.argOrder=["this","expressions"],Lr.register();var aF=Lr,Gc=class Gc extends E{constructor(e={}){super(e)}};n(Gc,"JsonTableExpr"),Gc.key="jsonTable",Gc.requiredArgs=new Set(["this","schema"]),Gc.availableArgs=new Set(["this","schema","path","errorHandling","emptyHandling"]),Gc.argOrder=["this","schema","path","errorHandling","emptyHandling"],Gc.register();var ub=Gc,Yc=class Yc extends E{constructor(e={}){super(e)}};n(Yc,"JsonTypeExpr"),Yc.key="jsontype",Yc._sqlNames=["JSON_TYPE"],Yc.availableArgs=new Set(["this","expression"]),Yc.argOrder=["this","expression"],Yc.register();var oF=Yc,Vc=class Vc extends E{constructor(e={}){super(e)}};n(Vc,"ObjectInsertExpr"),Vc.key="objectInsert",Vc.requiredArgs=new Set(["this","key","value"]),Vc.availableArgs=new Set(["this","key","value","updateFlag"]),Vc.argOrder=["this","key","value","updateFlag"],Vc.register();var cF=Vc,Qg=class Qg extends E{constructor(e={}){super(e)}};n(Qg,"ObjectIdExpr"),Qg.key="objectId",Qg.availableArgs=new Set(["this","expression"]),Qg.argOrder=["this","expression"],Qg.register();var pF=Qg,Zg=class Zg extends E{constructor(e={}){super(e)}};n(Zg,"OpenJsonExpr"),Zg.key="openJson",Zg.availableArgs=new Set(["this","path","expressions"]),Zg.argOrder=["this","path","expressions"],Zg.register();var hb=Zg,Hc=class Hc extends V(U,E){constructor(e={}){super(e)}};n(Hc,"JsonbContainsExpr"),Hc.key="jsonbContains",Hc._sqlNames=["JSONB_CONTAINS"],Hc.requiredArgs=new Set(["this","expression"]),Hc.availableArgs=new Set(["this","expression"]),Hc.register();var gb=Hc,UN=class UN extends V(U,E){constructor(e={}){super(e)}};n(UN,"JsonbContainsAnyTopKeysExpr"),UN.key="jsonbContainsAnyTopKeys",UN.requiredArgs=new Set(["this","expression"]),UN.availableArgs=new Set(["this","expression"]);var Rh=UN,vN=class vN extends V(U,E){constructor(e={}){super(e)}};n(vN,"JsonbContainsAllTopKeysExpr"),vN.key="jsonbContainsAllTopKeys",vN.requiredArgs=new Set(["this","expression"]),vN.availableArgs=new Set(["this","expression"]);var Oh=vN,Ui=class Ui extends E{constructor(e={}){super(e)}};n(Ui,"JsonbExistsExpr"),Ui.key="jsonbExists",Ui._sqlNames=["JSONB_EXISTS"],Ui.requiredArgs=new Set(["this","path"]),Ui.availableArgs=new Set(["this","path"]),Ui.argOrder=["this","path"],Ui.register();var lF=Ui,FN=class FN extends V(U,E){constructor(e={}){super(e)}};n(FN,"JsonbDeleteAtPathExpr"),FN.key="jsonbDeleteAtPath",FN.requiredArgs=new Set(["this","expression"]),FN.availableArgs=new Set(["this","expression"]);var mh=FN,vi=class vi extends V(U,E){constructor(e={}){super(e)}get outputName(){return this.args.expressions?"":this.args.expression?.outputName??""}};n(vi,"JsonExtractExpr"),vi.key="jsonExtract",vi.isVarLenArgs=!0,vi._sqlNames=["JSON_EXTRACT"],vi.requiredArgs=new Set(["this","expression"]),vi.availableArgs=new Set(["this","expression","onlyJsonTypes","expressions","variantExtract","jsonQuery","option","quote","onCondition","requiresJson"]),vi.register();var ms=vi,_c=class _c extends E{constructor(e={}){super(e)}};n(_c,"JsonExtractArrayExpr"),_c.key="jsonExtractArray",_c._sqlNames=["JSON_EXTRACT_ARRAY"],_c.availableArgs=new Set(["this","expression"]),_c.argOrder=["this","expression"],_c.register();var uF=_c,Fi=class Fi extends V(U,E){constructor(e={}){super(e)}get outputName(){return this.args.expression?.outputName??""}};n(Fi,"JsonExtractScalarExpr"),Fi.key="jsonExtractScalar",Fi.isVarLenArgs=!0,Fi._sqlNames=["JSON_EXTRACT_SCALAR"],Fi.requiredArgs=new Set(["this","expression"]),Fi.availableArgs=new Set(["this","expression","onlyJsonTypes","expressions","jsonType","scalarOnly"]),Fi.register();var bn=Fi,Wc=class Wc extends V(U,E){constructor(e={}){super(e)}};n(Wc,"JsonbExtractExpr"),Wc.key="jsonbExtract",Wc._sqlNames=["JSONB_EXTRACT"],Wc.requiredArgs=new Set(["this","expression"]),Wc.availableArgs=new Set(["this","expression"]),Wc.register();var Nh=Wc,jc=class jc extends V(U,E){constructor(e={}){super(e)}};n(jc,"JsonbExtractScalarExpr"),jc.key="jsonbExtractScalar",jc._sqlNames=["JSONB_EXTRACT_SCALAR"],jc.requiredArgs=new Set(["this","expression"]),jc.availableArgs=new Set(["this","expression","jsonType"]),jc.register();var Eb=jc,Xc=class Xc extends E{constructor(e={}){super(e)}};n(Xc,"JsonFormatExpr"),Xc.key="jsonFormat",Xc._sqlNames=["JSON_FORMAT"],Xc.availableArgs=new Set(["this","options","isJson","toJson"]),Xc.argOrder=["this","options","isJson","toJson"],Xc.register();var hF=Xc,wr=class wr extends E{constructor(e={}){super(e)}};n(wr,"JsonArrayAppendExpr"),wr.key="jsonArrayAppend",wr.isVarLenArgs=!0,wr._sqlNames=["JSON_ARRAY_APPEND"],wr.requiredArgs=new Set(["this","expressions"]),wr.availableArgs=new Set(["this","expressions"]),wr.argOrder=["this","expressions"],wr.register();var gF=wr,Jc=class Jc extends V(U,ke,E){constructor(e={}){super(e)}};n(Jc,"JsonArrayContainsExpr"),Jc.key="jsonArrayContains",Jc._sqlNames=["JSON_ARRAY_CONTAINS"],Jc.requiredArgs=new Set(["this","expression"]),Jc.availableArgs=new Set(["this","expression","jsonType"]),Jc.register();var EF=Jc,Mr=class Mr extends E{constructor(e={}){super(e)}};n(Mr,"JsonArrayInsertExpr"),Mr.key="jsonArrayInsert",Mr.isVarLenArgs=!0,Mr._sqlNames=["JSON_ARRAY_INSERT"],Mr.requiredArgs=new Set(["this","expressions"]),Mr.availableArgs=new Set(["this","expressions"]),Mr.argOrder=["this","expressions"],Mr.register();var AF=Mr,BN=class BN extends E{constructor(e={}){super(e)}};n(BN,"ParseBignumericExpr"),BN.key="parseBignumeric",BN.argOrder=["this"],BN.register();var dF=BN,$N=class $N extends E{constructor(e={}){super(e)}};n($N,"ParseNumericExpr"),$N.key="parseNumeric",$N.argOrder=["this"],$N.register();var fF=$N,zc=class zc extends E{constructor(e={}){super(e)}};n(zc,"ParseJsonExpr"),zc.key="parseJson",zc._sqlNames=["PARSE_JSON","JSON_PARSE"],zc.availableArgs=new Set(["this","expression","safe"]),zc.argOrder=["this","expression","safe"],zc.register();var ai=zc,Kg=class Kg extends E{constructor(e={}){super(e)}};n(Kg,"ParseUrlExpr"),Kg.key="parseUrl",Kg.availableArgs=new Set(["this","partToExtract","key","permissive"]),Kg.argOrder=["this","partToExtract","key","permissive"],Kg.register();var xF=Kg,Qc=class Qc extends E{constructor(e={}){super(e)}};n(Qc,"ParseIpExpr"),Qc.key="parseIp",Qc.requiredArgs=new Set(["this","type"]),Qc.availableArgs=new Set(["this","type","permissive"]),Qc.argOrder=["this","type","permissive"],Qc.register();var TF=Qc,Zc=class Zc extends E{constructor(e={}){super(e)}};n(Zc,"ParseTimeExpr"),Zc.key="parseTime",Zc.requiredArgs=new Set(["this","format"]),Zc.availableArgs=new Set(["this","format"]),Zc.argOrder=["this","format"],Zc.register();var SF=Zc,eE=class eE extends E{constructor(e={}){super(e)}};n(eE,"ParseDatetimeExpr"),eE.key="parseDatetime",eE.availableArgs=new Set(["this","format","zone"]),eE.argOrder=["this","format","zone"],eE.register();var RF=eE,Bi=class Bi extends E{constructor(e={}){super(e)}};n(Bi,"LeastExpr"),Bi.key="least",Bi.isVarLenArgs=!0,Bi.requiredArgs=new Set(["this","ignoreNulls"]),Bi.availableArgs=new Set(["this","expressions","ignoreNulls"]),Bi.argOrder=["this","expressions","ignoreNulls"],Bi.register();var Ih=Bi,Kc=class Kc extends E{constructor(e={}){super(e)}};n(Kc,"LeftExpr"),Kc.key="left",Kc.requiredArgs=new Set(["this","expression"]),Kc.availableArgs=new Set(["this","expression"]),Kc.argOrder=["this","expression"],Kc.register();var OF=Kc,ep=class ep extends E{constructor(e={}){super(e)}};n(ep,"RightExpr"),ep.key="right",ep.requiredArgs=new Set(["this","expression"]),ep.availableArgs=new Set(["this","expression"]),ep.argOrder=["this","expression"],ep.register();var mF=ep,GN=class GN extends E{constructor(e={}){super(e)}};n(GN,"ReverseExpr"),GN.key="reverse",GN.argOrder=["this"],GN.register();var NF=GN,tp=class tp extends E{constructor(e={}){super(e)}};n(tp,"LengthExpr"),tp.key="length",tp._sqlNames=["LENGTH","LEN","CHAR_LENGTH","CHARACTER_LENGTH"],tp.availableArgs=new Set(["this","binary","encoding"]),tp.argOrder=["this","binary","encoding"],tp.register();var $h=tp,YN=class YN extends E{constructor(e={}){super(e)}};n(YN,"RtrimmedLengthExpr"),YN.key="rtrimmedLength",YN.argOrder=["this"],YN.register();var IF=YN,VN=class VN extends E{constructor(e={}){super(e)}};n(VN,"BitLengthExpr"),VN.key="bitLength",VN.argOrder=["this"],VN.register();var eL=VN,tE=class tE extends E{constructor(e={}){super(e)}};n(tE,"LevenshteinExpr"),tE.key="levenshtein",tE.availableArgs=new Set(["this","expression","insCost","delCost","subCost","maxDist"]),tE.argOrder=["this","expression","insCost","delCost","subCost","maxDist"],tE.register();var tL=tE,HN=class HN extends E{constructor(e={}){super(e)}};n(HN,"LnExpr"),HN.key="ln",HN.argOrder=["this"],HN.register();var yh=HN,sE=class sE extends E{constructor(e={}){super(e)}};n(sE,"LogExpr"),sE.key="log",sE.availableArgs=new Set(["this","expression"]),sE.argOrder=["this","expression"],sE.register();var ur=sE,rE=class rE extends E{constructor(e={}){super(e)}};n(rE,"LowerExpr"),rE.key="lower",rE.argOrder=["this"],rE._sqlNames=["LOWER","LCASE"],rE.register();var Ar=rE,sp=class sp extends E{constructor(e={}){super(e)}get keys(){return this.args.keys?.args?.expressions||[]}get values(){return this.args.values?.args?.expressions||[]}};n(sp,"MapExpr"),sp.key="map",sp.requiredArgs=new Set,sp.availableArgs=new Set(["keys","values"]),sp.argOrder=["keys","values"],sp.register();var mn=sp,_N=class _N extends E{constructor(e={}){super(e)}};n(_N,"ToMapExpr"),_N.key="toMap",_N.argOrder=["this"],_N.register();var vh=_N,WN=class WN extends E{constructor(e={}){super(e)}};n(WN,"MapFromEntriesExpr"),WN.key="mapFromEntries",WN.argOrder=["this"],WN.register();var yF=WN,rp=class rp extends E{constructor(e={}){super(e)}};n(rp,"MapCatExpr"),rp.key="mapCat",rp.requiredArgs=new Set(["this","expression"]),rp.availableArgs=new Set(["this","expression"]),rp.argOrder=["this","expression"],rp.register();var CF=rp,ip=class ip extends E{constructor(e={}){super(e)}};n(ip,"MapContainsKeyExpr"),ip.key="mapContainsKey",ip.requiredArgs=new Set(["this","key"]),ip.availableArgs=new Set(["this","key"]),ip.argOrder=["this","key"],ip.register();var bF=ip,$i=class $i extends E{constructor(e={}){super(e)}};n($i,"MapDeleteExpr"),$i.key="mapDelete",$i.isVarLenArgs=!0,$i.requiredArgs=new Set(["this","expressions"]),$i.availableArgs=new Set(["this","expressions"]),$i.argOrder=["this","expressions"],$i.register();var PF=$i,np=class np extends E{constructor(e={}){super(e)}};n(np,"MapInsertExpr"),np.key="mapInsert",np.requiredArgs=new Set(["this","value"]),np.availableArgs=new Set(["this","key","value","updateFlag"]),np.argOrder=["this","key","value","updateFlag"],np.register();var LF=np,jN=class jN extends E{constructor(e={}){super(e)}};n(jN,"MapKeysExpr"),jN.key="mapkeys",jN.argOrder=["this"],jN.register();var wF=jN,Gi=class Gi extends E{constructor(e={}){super(e)}};n(Gi,"MapPickExpr"),Gi.key="mapPick",Gi.isVarLenArgs=!0,Gi.requiredArgs=new Set(["this","expressions"]),Gi.availableArgs=new Set(["this","expressions"]),Gi.argOrder=["this","expressions"],Gi.register();var MF=Gi,XN=class XN extends E{constructor(e={}){super(e)}};n(XN,"MapSizeExpr"),XN.key="mapSize",XN.argOrder=["this"],XN.register();var kF=XN,JN=class JN extends E{constructor(e={}){super(e)}};n(JN,"StarMapExpr"),JN.key="starMap",JN.argOrder=["this"],JN.register();var Ab=JN,Yi=class Yi extends E{constructor(e={}){super(e)}get keys(){return this.args.keys?.args.expressions??[]}get values(){return this.args.values?.args.expressions??[]}};n(Yi,"VarMapExpr"),Yi.key="varMap",Yi.isVarLenArgs=!0,Yi.requiredArgs=new Set(["keys","values"]),Yi.availableArgs=new Set(["keys","values"]),Yi.argOrder=["keys","values"],Yi.register();var Ss=Yi,ap=class ap extends E{constructor(e={}){super(e)}};n(ap,"MatchAgainstExpr"),ap.key="matchAgainst",ap.requiredArgs=new Set(["this","expressions"]),ap.availableArgs=new Set(["this","expressions","modifier"]),ap.argOrder=["this","expressions","modifier"],ap.register();var db=ap,iE=class iE extends E{constructor(e={}){super(e)}};n(iE,"Md5Expr"),iE.key="md5",iE._sqlNames=["MD5"],iE.argOrder=["this"],iE.register();var sL=iE,Vi=class Vi extends E{constructor(e={}){super(e)}};n(Vi,"Md5DigestExpr"),Vi.key="md5Digest",Vi.isVarLenArgs=!0,Vi._sqlNames=["MD5_DIGEST"],Vi.availableArgs=new Set(["this","expressions"]),Vi.argOrder=["this","expressions"],Vi.register();var DF=Vi,zN=class zN extends E{constructor(e={}){super(e)}};n(zN,"Md5NumberLower64Expr"),zN.key="md5NumberLower64",zN.argOrder=["this"],zN.register();var qF=zN,QN=class QN extends E{constructor(e={}){super(e)}};n(QN,"Md5NumberUpper64Expr"),QN.key="md5NumberUpper64",QN.argOrder=["this"],QN.register();var UF=QN,ZN=class ZN extends E{constructor(e={}){super(e)}};n(ZN,"MonthExpr"),ZN.key="month",ZN.argOrder=["this"],ZN.register();var rL=ZN,nE=class nE extends E{constructor(e={}){super(e)}};n(nE,"MonthnameExpr"),nE.key="monthname",nE.availableArgs=new Set(["this","abbreviated"]),nE.argOrder=["this","abbreviated"],nE.register();var iL=nE,op=class op extends E{constructor(e={}){super(e)}};n(op,"AddMonthsExpr"),op.key="addMonths",op.requiredArgs=new Set(["this","expression"]),op.availableArgs=new Set(["this","expression","preserveEndOfMonth"]),op.argOrder=["this","expression","preserveEndOfMonth"],op.register();var vF=op,cp=class cp extends E{constructor(e={}){super(e)}};n(cp,"Nvl2Expr"),cp.key="nvl2",cp.requiredArgs=new Set(["this","true"]),cp.availableArgs=new Set(["this","true","false"]),cp.argOrder=["this","true","false"],cp.register();var FF=cp,aE=class aE extends E{constructor(e={}){super(e)}};n(aE,"NormalizeExpr"),aE.key="normalize",aE.availableArgs=new Set(["this","form","isCasefold"]),aE.argOrder=["this","form","isCasefold"],aE.register();var fb=aE,pp=class pp extends E{constructor(e={}){super(e)}};n(pp,"NormalExpr"),pp.key="normal",pp.requiredArgs=new Set(["this","stddev","gen"]),pp.availableArgs=new Set(["this","stddev","gen"]),pp.argOrder=["this","stddev","gen"],pp.register();var BF=pp,KN=class KN extends E{constructor(e={}){super(e)}};n(KN,"NetFuncExpr"),KN.key="netFunc",KN.argOrder=["this"],KN.register();var Yb=KN,eI=class eI extends E{constructor(e={}){super(e)}};n(eI,"HostExpr"),eI.key="host",eI.argOrder=["this"],eI.register();var $F=eI,tI=class tI extends E{constructor(e={}){super(e)}};n(tI,"RegDomainExpr"),tI.key="regDomain",tI.argOrder=["this"],tI.register();var GF=tI,lp=class lp extends E{constructor(e={}){super(e)}};n(lp,"OverlayExpr"),lp.key="overlay",lp.requiredArgs=new Set(["this","expression","from"]),lp.availableArgs=new Set(["this","expression","from","for"]),lp.argOrder=["this","expression","from","for"],lp.register();var xb=lp,up=class up extends E{constructor(e={}){super(e)}};n(up,"PredictExpr"),up.key="predict",up.requiredArgs=new Set(["this","expression"]),up.availableArgs=new Set(["this","expression","paramsStruct"]),up.argOrder=["this","expression","paramsStruct"],up.register();var YF=up,hp=class hp extends E{constructor(e={}){super(e)}};n(hp,"MlTranslateExpr"),hp.key="mlTranslate",hp.requiredArgs=new Set(["this","expression","paramsStruct"]),hp.availableArgs=new Set(["this","expression","paramsStruct"]),hp.argOrder=["this","expression","paramsStruct"],hp.register();var VF=hp,oE=class oE extends E{constructor(e={}){super(e)}};n(oE,"FeaturesAtTimeExpr"),oE.key="featuresAtTime",oE.availableArgs=new Set(["this","time","numRows","ignoreFeatureNulls"]),oE.argOrder=["this","time","numRows","ignoreFeatureNulls"],oE.register();var HF=oE,gp=class gp extends E{constructor(e={}){super(e)}};n(gp,"GenerateEmbeddingExpr"),gp.key="generateEmbedding",gp.requiredArgs=new Set(["this","expression"]),gp.availableArgs=new Set(["this","expression","paramsStruct","isText"]),gp.argOrder=["this","expression","paramsStruct","isText"],gp.register();var _F=gp,cE=class cE extends E{constructor(e={}){super(e)}};n(cE,"MlForecastExpr"),cE.key="mlForecast",cE.availableArgs=new Set(["this","expression","paramsStruct"]),cE.argOrder=["this","expression","paramsStruct"],cE.register();var WF=cE,Ep=class Ep extends E{constructor(e={}){super(e)}};n(Ep,"VectorSearchExpr"),Ep.key="vectorSearch",Ep.requiredArgs=new Set(["this","columnToSearch","queryTable"]),Ep.availableArgs=new Set(["this","columnToSearch","queryTable","queryColumnToSearch","topK","distanceType","options"]),Ep.argOrder=["columnToSearch","queryTable","queryColumnToSearch","topK","distanceType","options"],Ep.register();var jF=Ep,Ap=class Ap extends E{constructor(e={}){super(e)}};n(Ap,"PiExpr"),Ap.key="pi",Ap.requiredArgs=new Set,Ap.availableArgs=new Set,Ap.argOrder=["this"],Ap.register();var nL=Ap,Hi=class Hi extends V(U,E){constructor(e={}){super(e)}};n(Hi,"PowExpr"),Hi.key="pow",Hi._sqlNames=["POWER","POW"],Hi.argOrder=["this","expression"],Hi.requiredArgs=new Set(["this","expression"]),Hi.availableArgs=new Set(["this","expression"]),Hi.register();var Gh=Hi,dp=class dp extends E{constructor(e={}){super(e)}};n(dp,"ApproxPercentileEstimateExpr"),dp.key="approxPercentileEstimate",dp.requiredArgs=new Set(["this","percentile"]),dp.availableArgs=new Set(["this","percentile"]),dp.argOrder=["this","percentile"],dp.register();var XF=dp,sI=class sI extends E{constructor(e={}){super(e)}};n(sI,"QuarterExpr"),sI.key="quarter",sI.argOrder=["this"],sI.register();var aL=sI,fp=class fp extends E{constructor(e={}){super(e)}};n(fp,"RandExpr"),fp.key="rand",fp._sqlNames=["RAND","RANDOM"],fp.availableArgs=new Set(["this","lower","upper"]),fp.argOrder=["this","lower","upper"],fp.register();var vr=fp,pE=class pE extends E{constructor(e={}){super(e)}};n(pE,"RandnExpr"),pE.key="randn",pE.requiredArgs=new Set,pE.argOrder=["this"],pE.register();var XI=pE,lE=class lE extends E{constructor(e={}){super(e)}};n(lE,"RandstrExpr"),lE.key="randstr",lE.availableArgs=new Set(["this","generator"]),lE.argOrder=["this","generator"],lE.register();var JF=lE,xp=class xp extends E{constructor(e={}){super(e)}};n(xp,"RangeNExpr"),xp.key="rangeN",xp.requiredArgs=new Set(["this","expressions"]),xp.availableArgs=new Set(["this","expressions","each"]),xp.argOrder=["this","expressions","each"],xp.register();var zF=xp,Tp=class Tp extends E{constructor(e={}){super(e)}};n(Tp,"RangeBucketExpr"),Tp.key="rangeBucket",Tp.requiredArgs=new Set(["this","expression"]),Tp.availableArgs=new Set(["this","expression"]),Tp.argOrder=["this","expression"],Tp.register();var QF=Tp,_i=class _i extends E{constructor(e={}){super(e)}};n(_i,"ReadCsvExpr"),_i.key="readCsv",_i.isVarLenArgs=!0,_i._sqlNames=["READ_CSV"],_i.availableArgs=new Set(["this","expressions"]),_i.argOrder=["this","expressions"],_i.register();var ZF=_i,Wi=class Wi extends E{constructor(e={}){super(e)}};n(Wi,"ReadParquetExpr"),Wi.key="readParquet",Wi.isVarLenArgs=!0,Wi.requiredArgs=new Set(["expressions"]),Wi.availableArgs=new Set(["expressions"]),Wi.argOrder=["expressions"],Wi.register();var KF=Wi,Sp=class Sp extends E{constructor(e={}){super(e)}};n(Sp,"ReduceExpr"),Sp.key="reduce",Sp.requiredArgs=new Set(["this","initial","merge"]),Sp.availableArgs=new Set(["this","initial","merge","finish"]),Sp.argOrder=["this","initial","merge","finish"],Sp.register();var eB=Sp,Rp=class Rp extends E{constructor(e={}){super(e)}};n(Rp,"RegexpExtractExpr"),Rp.key="regexpExtract",Rp.requiredArgs=new Set(["this","expression"]),Rp.availableArgs=new Set(["this","expression","position","occurrence","parameters","group","nullIfPosOverflow"]),Rp.argOrder=["this","expression","position","occurrence","parameters","group","nullIfPosOverflow"],Rp.register();var ZL=Rp,Op=class Op extends E{constructor(e={}){super(e)}};n(Op,"RegexpExtractAllExpr"),Op.key="regexpExtractAll",Op.requiredArgs=new Set(["this","expression"]),Op.availableArgs=new Set(["this","expression","group","parameters","position","occurrence"]),Op.argOrder=["this","expression","group","parameters","position","occurrence"],Op.register();var tB=Op,mp=class mp extends E{constructor(e={}){super(e)}};n(mp,"RegexpReplaceExpr"),mp.key="regexpReplace",mp.requiredArgs=new Set(["this","expression"]),mp.availableArgs=new Set(["this","expression","replacement","position","occurrence","modifiers","singleReplace"]),mp.argOrder=["this","expression","replacement","position","occurrence","modifiers","singleReplace"],mp.register();var sB=mp,Np=class Np extends V(U,E){constructor(e={}){super(e)}};n(Np,"RegexpLikeExpr"),Np.key="regexpLike",Np.argOrder=["this","expression","flag"],Np.requiredArgs=new Set(["this","expression"]),Np.availableArgs=new Set(["this","expression","flag","fullMatch"]),Np.register();var Ga=Np,Ip=class Ip extends V(U,E){constructor(e={}){super(e)}};n(Ip,"RegexpILikeExpr"),Ip.key="regexpIlike",Ip.argOrder=["this","expression"],Ip.requiredArgs=new Set(["this","expression"]),Ip.availableArgs=new Set(["this","expression","flag"]),Ip.register();var Tb=Ip,yp=class yp extends V(U,E){constructor(e={}){super(e)}};n(yp,"RegexpFullMatchExpr"),yp.key="regexpFullMatch",yp.argOrder=["this","expression","options"],yp.requiredArgs=new Set(["this","expression"]),yp.availableArgs=new Set(["this","expression","options"]),yp.register();var rB=yp,Cp=class Cp extends E{constructor(e={}){super(e)}};n(Cp,"RegexpInstrExpr"),Cp.key="regexpInstr",Cp.requiredArgs=new Set(["this","expression"]),Cp.availableArgs=new Set(["this","expression","position","occurrence","option","parameters","group"]),Cp.argOrder=["this","expression","position","occurrence","option","parameters","group"],Cp.register();var iB=Cp,bp=class bp extends E{constructor(e={}){super(e)}};n(bp,"RegexpSplitExpr"),bp.key="regexpSplit",bp.requiredArgs=new Set(["this","expression"]),bp.availableArgs=new Set(["this","expression","limit"]),bp.argOrder=["this","expression","limit"],bp.register();var nB=bp,Pp=class Pp extends E{constructor(e={}){super(e)}};n(Pp,"RegexpCountExpr"),Pp.key="regexpCount",Pp.requiredArgs=new Set(["this","expression"]),Pp.availableArgs=new Set(["this","expression","position","parameters"]),Pp.argOrder=["this","expression","position","parameters"],Pp.register();var aB=Pp,Lp=class Lp extends E{constructor(e={}){super(e)}};n(Lp,"RepeatExpr"),Lp.key="repeat",Lp.requiredArgs=new Set(["this","times"]),Lp.availableArgs=new Set(["this","times"]),Lp.argOrder=["this","times"],Lp.register();var oB=Lp,wp=class wp extends E{constructor(e={}){super(e)}};n(wp,"ReplaceExpr"),wp.key="replace",wp.requiredArgs=new Set(["this","expression"]),wp.availableArgs=new Set(["this","expression","replacement"]),wp.argOrder=["this","expression","replacement"],wp.register();var KL=wp,rI=class rI extends E{constructor(e={}){super(e)}};n(rI,"RadiansExpr"),rI.key="radians",rI.argOrder=["this"],rI.register();var oL=rI,uE=class uE extends E{constructor(e={}){super(e)}};n(uE,"RoundExpr"),uE.key="round",uE.availableArgs=new Set(["this","decimals","truncate","castsNonIntegerDecimals"]),uE.argOrder=["this","decimals","truncate","castsNonIntegerDecimals"],uE.register();var cL=uE,Mp=class Mp extends E{constructor(e={}){super(e)}};n(Mp,"TruncExpr"),Mp.key="trunc",Mp._sqlNames=["TRUNC","TRUNCATE"],Mp.availableArgs=new Set(["this","decimals"]),Mp.argOrder=["this","decimals"],Mp.register();var ew=Mp,kp=class kp extends E{constructor(e={}){super(e)}};n(kp,"RowNumberExpr"),kp.key="rowNumber",kp.argOrder=["this"],kp.requiredArgs=new Set,kp.availableArgs=new Set(["this"]),kp.register();var yb=kp,Dp=class Dp extends E{constructor(e={}){super(e)}};n(Dp,"Seq1Expr"),Dp.key="seq1",Dp.argOrder=["this"],Dp.requiredArgs=new Set,Dp.availableArgs=new Set(["this"]),Dp.register();var cB=Dp,qp=class qp extends E{constructor(e={}){super(e)}};n(qp,"Seq2Expr"),qp.key="seq2",qp.argOrder=["this"],qp.requiredArgs=new Set,qp.availableArgs=new Set(["this"]),qp.register();var pB=qp,Up=class Up extends E{constructor(e={}){super(e)}};n(Up,"Seq4Expr"),Up.key="seq4",Up.argOrder=["this"],Up.requiredArgs=new Set,Up.availableArgs=new Set(["this"]),Up.register();var lB=Up,vp=class vp extends E{constructor(e={}){super(e)}};n(vp,"Seq8Expr"),vp.key="seq8",vp.argOrder=["this"],vp.requiredArgs=new Set,vp.availableArgs=new Set(["this"]),vp.register();var uB=vp,Fp=class Fp extends E{constructor(e={}){super(e)}};n(Fp,"SafeAddExpr"),Fp.key="safeAdd",Fp.requiredArgs=new Set(["this","expression"]),Fp.availableArgs=new Set(["this","expression"]),Fp.argOrder=["this","expression"],Fp.register();var hB=Fp,Bp=class Bp extends E{constructor(e={}){super(e)}};n(Bp,"SafeDivideExpr"),Bp.key="safeDivide",Bp.requiredArgs=new Set(["this","expression"]),Bp.availableArgs=new Set(["this","expression"]),Bp.argOrder=["this","expression"],Bp.register();var pL=Bp,$p=class $p extends E{constructor(e={}){super(e)}};n($p,"SafeMultiplyExpr"),$p.key="safeMultiply",$p.requiredArgs=new Set(["this","expression"]),$p.availableArgs=new Set(["this","expression"]),$p.argOrder=["this","expression"],$p.register();var gB=$p,iI=class iI extends E{constructor(e={}){super(e)}};n(iI,"SafeNegateExpr"),iI.key="safeNegate",iI.argOrder=["this"],iI.register();var EB=iI,Gp=class Gp extends E{constructor(e={}){super(e)}};n(Gp,"SafeSubtractExpr"),Gp.key="safeSubtract",Gp.requiredArgs=new Set(["this","expression"]),Gp.availableArgs=new Set(["this","expression"]),Gp.argOrder=["this","expression"],Gp.register();var AB=Gp,nI=class nI extends E{constructor(e={}){super(e)}};n(nI,"SafeConvertBytesToStringExpr"),nI.key="safeConvertBytesToString",nI.argOrder=["this"],nI.register();var dB=nI,hE=class hE extends E{constructor(e={}){super(e)}};n(hE,"ShaExpr"),hE.key="sha",hE.argOrder=["this"],hE._sqlNames=["SHA","Sha1"],hE.register();var lL=hE,Yp=class Yp extends E{constructor(e={}){super(e)}};n(Yp,"Sha2Expr"),Yp.key="sha2",Yp._sqlNames=["Sha2"],Yp.availableArgs=new Set(["this","length"]),Yp.argOrder=["this","length"],Yp.register();var uL=Yp,aI=class aI extends E{constructor(e={}){super(e)}};n(aI,"Sha1DigestExpr"),aI.key="sha1Digest",aI.argOrder=["this"],aI.register();var fB=aI,gE=class gE extends E{constructor(e={}){super(e)}};n(gE,"Sha2DigestExpr"),gE.key="sha2Digest",gE.availableArgs=new Set(["this","length"]),gE.argOrder=["this","length"],gE.register();var xB=gE,EE=class EE extends E{constructor(e={}){super(e)}};n(EE,"SignExpr"),EE.key="sign",EE.argOrder=["this"],EE._sqlNames=["SIGN","SIGNUM"],EE.register();var hL=EE,AE=class AE extends E{constructor(e={}){super(e)}};n(AE,"SortArrayExpr"),AE.key="sortArray",AE.availableArgs=new Set(["this","asc","nullsFirst"]),AE.argOrder=["this","asc","nullsFirst"],AE.register();var gL=AE,oI=class oI extends E{constructor(e={}){super(e)}};n(oI,"SoundexExpr"),oI.key="soundex",oI.argOrder=["this"],oI.register();var TB=oI,cI=class cI extends E{constructor(e={}){super(e)}};n(cI,"SoundexP123Expr"),cI.key="soundexP123",cI.argOrder=["this"],cI.register();var SB=cI,Vp=class Vp extends E{constructor(e={}){super(e)}};n(Vp,"SplitExpr"),Vp.key="split",Vp.requiredArgs=new Set(["this","expression"]),Vp.availableArgs=new Set(["this","expression","limit","nullReturnsNull","emptyDelimiterReturnsWhole"]),Vp.argOrder=["this","expression","limit"],Vp.register();var RB=Vp,dE=class dE extends E{constructor(e={}){super(e)}};n(dE,"SplitPartExpr"),dE.key="splitPart",dE.availableArgs=new Set(["this","delimiter","partIndex","partIndexZeroAsOne","emptyDelimiterReturnsWhole"]),dE.argOrder=["this","delimiter","partIndex"],dE.register();var OB=dE,pI=class pI extends E{constructor(e={}){super(e)}};n(pI,"StrtokExpr"),pI.key="strtok",pI.requiredArgs=new Set(["this"]),pI.availableArgs=new Set(["this","delimiter","partIndex"]);var mB=pI,Hp=class Hp extends E{constructor(e={}){super(e)}};n(Hp,"SubstringExpr"),Hp.key="substring",Hp._sqlNames=["SUBSTRING","SUBSTR"],Hp.availableArgs=new Set(["this","start","length"]),Hp.argOrder=["this","start","length"],Hp.register();var Ns=Hp,_p=class _p extends E{constructor(e={}){super(e)}};n(_p,"SubstringIndexExpr"),_p.key="substringIndex",_p.requiredArgs=new Set(["this","delimiter","count"]),_p.availableArgs=new Set(["this","delimiter","count"]),_p.argOrder=["this","delimiter","count"],_p.register();var NB=_p,fE=class fE extends E{constructor(e={}){super(e)}};n(fE,"StandardHashExpr"),fE.key="standardHash",fE.availableArgs=new Set(["this","expression"]),fE.argOrder=["this","expression"],fE.register();var IB=fE,ji=class ji extends E{constructor(e={}){super(e)}};n(ji,"StartsWithExpr"),ji.key="startsWith",ji._sqlNames=["STARTS_WITH","STARTSWITH"],ji.requiredArgs=new Set(["this","expression"]),ji.availableArgs=new Set(["this","expression"]),ji.argOrder=["this","expression"],ji.register();var Vl=ji,Xi=class Xi extends E{constructor(e={}){super(e)}};n(Xi,"EndsWithExpr"),Xi.key="endsWith",Xi._sqlNames=["ENDS_WITH","ENDSWITH"],Xi.requiredArgs=new Set(["this","expression"]),Xi.availableArgs=new Set(["this","expression"]),Xi.argOrder=["this","expression"],Xi.register();var EL=Xi,Wp=class Wp extends E{constructor(e={}){super(e)}};n(Wp,"StrPositionExpr"),Wp.key="strPosition",Wp.requiredArgs=new Set(["this","substr"]),Wp.availableArgs=new Set(["this","substr","position","occurrence","clampPosition"]),Wp.argOrder=["this","substr","position","occurrence"],Wp.register();var Bs=Wp,jp=class jp extends E{constructor(e={}){super(e)}};n(jp,"SearchExpr"),jp.key="search",jp.requiredArgs=new Set(["this","expression"]),jp.availableArgs=new Set(["this","expression","jsonScope","analyzer","analyzerOptions","searchMode"]),jp.argOrder=["this","expression","jsonScope","analyzer","analyzerOptions","searchMode"],jp.register();var yB=jp,Xp=class Xp extends E{constructor(e={}){super(e)}};n(Xp,"SearchIpExpr"),Xp.key="searchIp",Xp.requiredArgs=new Set(["this","expression"]),Xp.availableArgs=new Set(["this","expression"]),Xp.argOrder=["this","expression"],Xp.register();var CB=Xp,xE=class xE extends E{constructor(e={}){super(e)}};n(xE,"StrToDateExpr"),xE.key="strToDate",xE.availableArgs=new Set(["this","format","safe"]),xE.argOrder=["this","format","safe"],xE.register();var oi=xE,Jp=class Jp extends E{constructor(e={}){super(e)}};n(Jp,"StrToTimeExpr"),Jp.key="strToTime",Jp.requiredArgs=new Set(["this","format"]),Jp.availableArgs=new Set(["this","format","zone","safe","targetType"]),Jp.argOrder=["this","format","zone","safe","targetType"],Jp.register();var Is=Jp,zp=class zp extends E{constructor(e={}){super(e)}};n(zp,"StrToUnixExpr"),zp.key="strToUnix",zp.requiredArgs=new Set,zp.availableArgs=new Set(["this","format"]),zp.argOrder=["this","format"],zp.register();var bB=zp,TE=class TE extends E{constructor(e={}){super(e)}};n(TE,"StrToMapExpr"),TE.key="strToMap",TE.availableArgs=new Set(["this","pairDelim","keyValueDelim","duplicateResolutionCallback"]),TE.argOrder=["this","pairDelim","keyValueDelim","duplicateResolutionCallback"],TE.register();var PB=TE,Qp=class Qp extends E{constructor(e={}){super(e)}};n(Qp,"NumberToStrExpr"),Qp.key="numberToStr",Qp.requiredArgs=new Set(["this","format"]),Qp.availableArgs=new Set(["this","format","culture"]),Qp.argOrder=["this","format","culture"],Qp.register();var LB=Qp,Zp=class Zp extends E{constructor(e={}){super(e)}};n(Zp,"FromBaseExpr"),Zp.key="fromBase",Zp.requiredArgs=new Set(["this","expression"]),Zp.availableArgs=new Set(["this","expression"]),Zp.argOrder=["this","expression"],Zp.register();var wB=Zp,lI=class lI extends E{constructor(e={}){super(e)}};n(lI,"SpaceExpr"),lI.key="space",lI.argOrder=["this"],lI.register();var AL=lI,Ji=class Ji extends E{constructor(e={}){super(e)}};n(Ji,"StructExpr"),Ji.key="struct",Ji.isVarLenArgs=!0,Ji.requiredArgs=new Set([]),Ji.availableArgs=new Set(["expressions"]),Ji.argOrder=["expressions"],Ji.register();var Es=Ji,Kp=class Kp extends E{constructor(e={}){super(e)}};n(Kp,"StructExtractExpr"),Kp.key="structExtract",Kp.requiredArgs=new Set(["this","expression"]),Kp.availableArgs=new Set(["this","expression"]),Kp.argOrder=["this","expression"],Kp.register();var MB=Kp,zi=class zi extends E{constructor(e={}){super(e)}};n(zi,"StuffExpr"),zi.key="stuff",zi._sqlNames=["STUFF","INSERT"],zi.requiredArgs=new Set(["this","start","length","expression"]),zi.availableArgs=new Set(["this","start","length","expression"]),zi.argOrder=["this","start","length","expression"],zi.register();var kB=zi,uI=class uI extends E{constructor(e={}){super(e)}};n(uI,"SqrtExpr"),uI.key="sqrt",uI.argOrder=["this"],uI.register();var Ch=uI,el=class el extends E{constructor(e={}){super(e)}};n(el,"TimeExpr"),el.key="time",el.requiredArgs=new Set,el.availableArgs=new Set(["this","zone"]),el.argOrder=["this","zone"],el.register();var dL=el,tl=class tl extends E{constructor(e={}){super(e)}};n(tl,"TimeToStrExpr"),tl.key="timeToStr",tl.requiredArgs=new Set(["this","format"]),tl.availableArgs=new Set(["this","format","culture","zone"]),tl.argOrder=["this","format","culture","zone"],tl.register();var Or=tl,hI=class hI extends E{constructor(e={}){super(e)}};n(hI,"TimeToTimeStrExpr"),hI.key="timeToTimeStr",hI.argOrder=["this"],hI.register();var fL=hI,gI=class gI extends E{constructor(e={}){super(e)}};n(gI,"TimeToUnixExpr"),gI.key="timeToUnix",gI.argOrder=["this"],gI.register();var DB=gI,EI=class EI extends E{constructor(e={}){super(e)}};n(EI,"TimeStrToDateExpr"),EI.key="timeStrToDate",EI.argOrder=["this"],EI.register();var xL=EI,SE=class SE extends E{constructor(e={}){super(e)}};n(SE,"TimeStrToTimeExpr"),SE.key="timeStrToTime",SE.availableArgs=new Set(["this","zone"]),SE.argOrder=["this","zone"],SE.register();var Yh=SE,AI=class AI extends E{constructor(e={}){super(e)}};n(AI,"TimeStrToUnixExpr"),AI.key="timeStrToUnix",AI.argOrder=["this"],AI.register();var qB=AI,RE=class RE extends E{constructor(e={}){super(e)}};n(RE,"TrimExpr"),RE.key="trim",RE.availableArgs=new Set(["this","expression","position","collation"]),RE.argOrder=["this","expression","position","collation"],RE.register();var Ya=RE,sl=class sl extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}get returnType(){let e=this.args.returnType;return e instanceof m?e:m.build("date")}};n(sl,"TsOrDsAddExpr"),sl.key="tsOrDsAdd",sl.argOrder=["this","expression","unit","returnType"],sl.requiredArgs=new Set(["this","expression"]),sl.availableArgs=new Set(["this","expression","unit","returnType"]),sl.register();var Vh=sl,rl=class rl extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(rl,"TsOrDsDiffExpr"),rl.key="tsOrDsDiff",rl.argOrder=["this","expression","unit"],rl.requiredArgs=new Set(["this","expression"]),rl.availableArgs=new Set(["this","expression","unit"]),rl.register();var UB=rl,dI=class dI extends E{constructor(e={}){super(e)}};n(dI,"TsOrDsToDateStrExpr"),dI.key="tsOrDsToDateStr",dI.argOrder=["this"],dI.register();var TL=dI,OE=class OE extends E{constructor(e={}){super(e)}};n(OE,"TsOrDsToDateExpr"),OE.key="tsOrDsToDate",OE.availableArgs=new Set(["this","format","safe"]),OE.argOrder=["this","format","safe"],OE.register();var os=OE,fI=class fI extends E{constructor(e={}){super(e)}};n(fI,"TsOrDsToDatetimeExpr"),fI.key="tsOrDsToDatetime",fI.argOrder=["this"],fI.register();var Vb=fI,mE=class mE extends E{constructor(e={}){super(e)}};n(mE,"TsOrDsToTimeExpr"),mE.key="tsOrDsToTime",mE.availableArgs=new Set(["this","format","safe"]),mE.argOrder=["format","safe","this"],mE.register();var Hb=mE,xI=class xI extends E{constructor(e={}){super(e)}};n(xI,"TsOrDsToTimestampExpr"),xI.key="tsOrDsToTimestamp",xI.argOrder=["this"],xI.register();var _b=xI,TI=class TI extends E{constructor(e={}){super(e)}};n(TI,"TsOrDiToDiExpr"),TI.key="tsOrDiToDi",TI.argOrder=["this"],TI.register();var SL=TI,NE=class NE extends E{constructor(e={}){super(e)}};n(NE,"UnhexExpr"),NE.key="unhex",NE.availableArgs=new Set(["this","expression"]),NE.argOrder=["this","expression"],NE.register();var vB=NE,SI=class SI extends E{constructor(e={}){super(e)}};n(SI,"UnicodeExpr"),SI.key="unicode",SI.argOrder=["this"],SI.register();var RL=SI,il=class il extends E{constructor(e={}){super(e)}};n(il,"UniformExpr"),il.key="uniform",il.requiredArgs=new Set(["this","expression"]),il.availableArgs=new Set(["this","expression","gen","seed"]),il.argOrder=["this","expression","gen","seed"],il.register();var FB=il,RI=class RI extends E{constructor(e={}){super(e)}};n(RI,"UnixDateExpr"),RI.key="unixDate",RI.argOrder=["this"],RI.register();var OL=RI,IE=class IE extends E{constructor(e={}){super(e)}};n(IE,"UnixToStrExpr"),IE.key="unixToStr",IE.availableArgs=new Set(["this","format"]),IE.argOrder=["this","format"],IE.register();var mL=IE,Ut=class Ut extends E{constructor(e={}){super(e)}};n(Ut,"UnixToTimeExpr"),Ut.key="unixToTime",Ut.availableArgs=new Set(["this","scale","zone","hours","minutes","format","targetType"]),Ut.argOrder=["this","scale","zone","hours","minutes","format","targetType"],Ut.SECONDS=N.number(0),Ut.DECIS=N.number(1),Ut.CENTIS=N.number(2),Ut.MILLIS=N.number(3),Ut.DECIMILLIS=N.number(4),Ut.CENTIMILLIS=N.number(5),Ut.MICROS=N.number(6),Ut.DECIMICROS=N.number(7),Ut.CENTIMICROS=N.number(8),Ut.NANOS=N.number(9),Ut.register();var NL=Ut,OI=class OI extends E{constructor(e={}){super(e)}};n(OI,"UnixToTimeStrExpr"),OI.key="unixToTimeStr",OI.argOrder=["this"],OI.register();var IL=OI,mI=class mI extends E{constructor(e={}){super(e)}};n(mI,"UnixSecondsExpr"),mI.key="unixSeconds",mI.argOrder=["this"],mI.register();var yL=mI,NI=class NI extends E{constructor(e={}){super(e)}};n(NI,"UnixMicrosExpr"),NI.key="unixMicros",NI.argOrder=["this"],NI.register();var CL=NI,II=class II extends E{constructor(e={}){super(e)}};n(II,"UnixMillisExpr"),II.key="unixMillis",II.argOrder=["this"],II.register();var bL=II,nl=class nl extends E{constructor(e={}){super(e)}};n(nl,"UuidExpr"),nl.key="uuid",nl._sqlNames=["UUID","GEN_RANDOM_UUID","GENERATE_UUID","UUID_STRING"],nl.availableArgs=new Set(["this","name","isString"]),nl.argOrder=["this","name","isString"],nl.register();var kA=nl,Ij={year:!1,month:!1,day:!1,hour:!1,min:!1,sec:!1,nano:!1},Qi=class Qi extends E{constructor(e={}){super(e)}};n(Qi,"TimestampFromPartsExpr"),Qi.key="timestampFromParts",Qi._sqlNames=["TIMESTAMP_FROM_PARTS","TIMESTAMPFROMPARTS"],Qi.requiredArgs=new Set,Qi.availableArgs=new Set(["year","month","day","hour","min","sec","nano","zone","milli","this","expression"]),Qi.argOrder=["year","month","day","hour","min","sec","nano","zone","milli","this","expression"],Qi.register();var vM=Qi,al=class al extends E{constructor(e={}){super(e)}};n(al,"TimestampLtzFromPartsExpr"),al.key="timestampLtzFromParts",al.argOrder=["year","month","day","hour","min","sec","nano"],al._sqlNames=["TIMESTAMP_LTZ_FROM_PARTS","TIMESTAMPLTZFROMPARTS"],al.availableArgs=new Set(["year","month","day","hour","min","sec","nano"]),al.register();var PL=al,ol=class ol extends E{constructor(e={}){super(e)}};n(ol,"TimestampTzFromPartsExpr"),ol.key="timestampTzFromParts",ol._sqlNames=["TIMESTAMP_TZ_FROM_PARTS","TIMESTAMPTZFROMPARTS"],ol.argOrder=["year","month","day","hour","min","sec","nano","zone"],ol.availableArgs=new Set(["year","month","day","hour","min","sec","nano","zone"]),ol.register();var LL=ol,yE=class yE extends E{constructor(e={}){super(e)}};n(yE,"UpperExpr"),yE.key="upper",yE.argOrder=["this"],yE._sqlNames=["UPPER","UCASE"],yE.register();var dr=yE,cl=class cl extends V(U,q){constructor(e={}){super(e)}};n(cl,"CorrExpr"),cl.key="corr",cl.requiredArgs=new Set(["this","expression"]),cl.availableArgs=new Set(["this","expression","nullOnZeroVariance"]),cl.argOrder=["this","expression","nullOnZeroVariance"],cl.register();var BB=cl,CE=class CE extends E{constructor(e={}){super(e)}};n(CE,"WidthBucketExpr"),CE.key="widthBucket",CE.availableArgs=new Set(["this","minValue","maxValue","numBuckets","threshold"]),CE.argOrder=["this","minValue","maxValue","numBuckets","threshold"],CE.register();var $B=CE,pl=class pl extends E{constructor(e={}){super(e)}};n(pl,"WeekExpr"),pl.key="week",pl.requiredArgs=new Set,pl.availableArgs=new Set(["this","mode"]),pl.argOrder=["this","mode"],pl.register();var Ed=pl,ll=class ll extends E{constructor(e={}){super(e)}};n(ll,"NextDayExpr"),ll.key="nextDay",ll.requiredArgs=new Set(["this","expression"]),ll.availableArgs=new Set(["this","expression"]),ll.argOrder=["this","expression"],ll.register();var GB=ll,ul=class ul extends E{constructor(e={}){super(e)}};n(ul,"XmlElementExpr"),ul.key="xmlElement",ul._sqlNames=["XmlELEMENT"],ul.availableArgs=new Set(["this","expressions","evalname"]),ul.argOrder=["evalname","this","expressions"],ul.register();var Sb=ul,Zi=class Zi extends E{constructor(e={}){super(e)}};n(Zi,"XmlGetExpr"),Zi.key="xmlGet",Zi._sqlNames=["XmlGET"],Zi.requiredArgs=new Set(["this","expression"]),Zi.availableArgs=new Set(["this","expression","instance"]),Zi.argOrder=["this","expression","instance"],Zi.register();var YB=Zi,bE=class bE extends E{constructor(e={}){super(e)}};n(bE,"XmlTableExpr"),bE.key="xmlTable",bE.availableArgs=new Set(["this","namespaces","passing","columns","byRef"]),bE.argOrder=["this","namespaces","passing","columns","byRef"],bE.register();var Rb=bE,yI=class yI extends E{constructor(e={}){super(e)}};n(yI,"YearExpr"),yI.key="year",yI.argOrder=["this"],yI.register();var wL=yI,hl=class hl extends E{constructor(e={}){super(e)}};n(hl,"ZipfExpr"),hl.key="zipf",hl.requiredArgs=new Set(["this","elementcount","gen"]),hl.availableArgs=new Set(["this","elementcount","gen"]),hl.argOrder=["this","elementcount","gen"],hl.register();var VB=hl,PE=class PE extends E{constructor(e={}){super(e)}};n(PE,"NextValueForExpr"),PE.key="nextValueFor",PE.availableArgs=new Set(["this","order"]),PE.argOrder=["order","this"],PE.register();var Ob=PE,Gk=class Gk extends Us{constructor(e={}){super(e)}};n(Gk,"AllExpr"),Gk.key="all";var cs=Gk,Yk=class Yk extends Us{constructor(e={}){super(e)}};n(Yk,"AnyExpr"),Yk.key="any";var Tt=Yk,Mw=class Mw extends q{constructor(e={}){super(e)}};n(Mw,"BitwiseAndAggExpr"),Mw.key="bitwiseAndAgg",Mw.register();var HB=Mw,kw=class kw extends q{constructor(e={}){super(e)}};n(kw,"BitwiseOrAggExpr"),kw.key="bitwiseOrAgg",kw.register();var _B=kw,Dw=class Dw extends q{constructor(e={}){super(e)}};n(Dw,"BitwiseXorAggExpr"),Dw.key="bitwiseXorAgg",Dw.register();var WB=Dw,qw=class qw extends q{constructor(e={}){super(e)}};n(qw,"BoolxorAggExpr"),qw.key="boolxorAgg",qw.register();var jB=qw,Uw=class Uw extends q{constructor(e={}){super(e)}};n(Uw,"BitmapConstructAggExpr"),Uw.key="bitmapConstructAgg",Uw.register();var XB=Uw,vw=class vw extends q{constructor(e={}){super(e)}};n(vw,"BitmapOrAggExpr"),vw.key="bitmapOrAgg",vw.register();var JB=vw,gl=class gl extends q{constructor(e={}){super(e)}};n(gl,"ParameterizedAggExpr"),gl.key="parameterizedAgg",gl.argOrder=["this","expressions","params"],gl.requiredArgs=new Set(["this","expressions","params"]),gl.availableArgs=new Set(["this","expressions","params"]),gl.register();var $M=gl,Ki=class Ki extends q{constructor(e={}){super(e)}};n(Ki,"ArgMaxExpr"),Ki.key="argMax",Ki.argOrder=["this","expression","count"],Ki._sqlNames=["ARG_MAX","ARGMAX","MAX_BY"],Ki.requiredArgs=new Set(["this","expression"]),Ki.availableArgs=new Set(["this","expression","count"]),Ki.register();var DA=Ki,en=class en extends q{constructor(e={}){super(e)}};n(en,"ArgMinExpr"),en.key="argMin",en.argOrder=["this","expression","count"],en._sqlNames=["ARG_MIN","ARGMIN","MIN_BY"],en.requiredArgs=new Set(["this","expression"]),en.availableArgs=new Set(["this","expression","count"]),en.register();var qA=en,LE=class LE extends q{constructor(e={}){super(e)}};n(LE,"ApproxTopKExpr"),LE.key="approxTopK",LE.argOrder=["this","expression","counters"],LE.availableArgs=new Set(["this","expression","counters"]),LE.register();var zB=LE,wE=class wE extends q{constructor(e={}){super(e)}};n(wE,"ApproxTopKAccumulateExpr"),wE.key="approxTopKAccumulate",wE.argOrder=["this","expression"],wE.availableArgs=new Set(["this","expression"]),wE.register();var QB=wE,ME=class ME extends q{constructor(e={}){super(e)}};n(ME,"ApproxTopKCombineExpr"),ME.key="approxTopKCombine",ME.argOrder=["this","expression"],ME.availableArgs=new Set(["this","expression"]),ME.register();var ZB=ME,El=class El extends q{constructor(e={}){super(e)}};n(El,"ApproxTopSumExpr"),El.key="approxTopSum",El.argOrder=["this","expression","count"],El.requiredArgs=new Set(["this","expression","count"]),El.availableArgs=new Set(["this","expression","count"]),El.register();var KB=El,kE=class kE extends q{constructor(e={}){super(e)}};n(kE,"ApproxQuantilesExpr"),kE.key="approxQuantiles",kE.argOrder=["this","expression"],kE.availableArgs=new Set(["this","expression"]),kE.register();var e$=kE,Fw=class Fw extends q{constructor(e={}){super(e)}};n(Fw,"ApproxPercentileCombineExpr"),Fw.key="approxPercentileCombine",Fw.register();var t$=Fw,tn=class tn extends q{constructor(e={}){super(e)}};n(tn,"MinhashExpr"),tn.key="minhash",tn.argOrder=["this","expressions"],tn.isVarLenArgs=!0,tn.requiredArgs=new Set(["this","expressions"]),tn.availableArgs=new Set(["this","expressions"]),tn.register();var s$=tn,Bw=class Bw extends q{constructor(e={}){super(e)}};n(Bw,"MinhashCombineExpr"),Bw.key="minhashCombine",Bw.register();var r$=Bw,CI=class CI extends q{constructor(e={}){super(e)}};n(CI,"ApproximateSimilarityExpr"),CI.key="approximateSimilarity",CI._sqlNames=["APPROXIMATE_SIMILARITY","APPROXIMATE_JACCARD_INDEX"],CI.register();var i$=CI,sn=class sn extends q{constructor(e={}){super(e)}};n(sn,"GroupingExpr"),sn.key="grouping",sn.isVarLenArgs=!0,sn.argOrder=["expressions"],sn.requiredArgs=new Set(["expressions"]),sn.availableArgs=new Set(["expressions"]),sn.register();var n$=sn,rn=class rn extends q{constructor(e={}){super(e)}};n(rn,"GroupingIdExpr"),rn.key="groupingId",rn.requiredArgs=new Set,rn.isVarLenArgs=!0,rn.argOrder=["expressions"],rn.availableArgs=new Set(["expressions"]),rn.register();var a$=rn,Al=class Al extends q{constructor(e={}){super(e)}};n(Al,"AnonymousAggFuncExpr"),Al.key="anonymousAggFunc",Al.argOrder=["this","expressions"],Al.isVarLenArgs=!0,Al.availableArgs=new Set(["this","expressions"]),Al.register();var GM=Al,dl=class dl extends q{constructor(e={}){super(e)}};n(dl,"HashAggExpr"),dl.key="hashAgg",dl.argOrder=["this","expressions"],dl.isVarLenArgs=!0,dl.availableArgs=new Set(["this","expressions"]),dl.register();var o$=dl,fl=class fl extends q{constructor(e={}){super(e)}};n(fl,"HllExpr"),fl.key="hll",fl.argOrder=["this","expressions"],fl.isVarLenArgs=!0,fl.availableArgs=new Set(["this","expressions"]),fl.register();var c$=fl,xl=class xl extends q{constructor(e={}){super(e)}};n(xl,"ApproxDistinctExpr"),xl.key="approxDistinct",xl.argOrder=["this","accuracy"],xl._sqlNames=["APPROX_DISTINCT","APPROX_COUNT_DISTINCT"],xl.availableArgs=new Set(["this","accuracy"]),xl.register();var ML=xl,$w=class $w extends As{};n($w,"ExplodingGenerateSeriesExpr"),$w.key="explodingGenerateSeries",$w.register();var p$=$w,DE=class DE extends q{constructor(e={}){super(e)}};n(DE,"ArrayAggExpr"),DE.key="arrayAgg",DE.argOrder=["this","nullsExcluded"],DE.availableArgs=new Set(["this","nullsExcluded"]),DE.register();var Bn=DE,Gw=class Gw extends q{constructor(e={}){super(e)}};n(Gw,"ArrayUniqueAggExpr"),Gw.key="arrayUniqueAgg",Gw.register();var l$=Gw,nn=class nn extends q{constructor(e={}){super(e)}};n(nn,"AiAggExpr"),nn.key="aiAgg",nn.argOrder=["this","expression"],nn._sqlNames=["AI_AGG"],nn.requiredArgs=new Set(["this","expression"]),nn.availableArgs=new Set(["this","expression"]),nn.register();var u$=nn,bI=class bI extends q{constructor(e={}){super(e)}};n(bI,"AiSummarizeAggExpr"),bI.key="aiSummarizeAgg",bI._sqlNames=["AI_SUMMARIZE_AGG"],bI.register();var h$=bI,Yw=class Yw extends q{constructor(e={}){super(e)}};n(Yw,"ArrayConcatAggExpr"),Yw.key="arrayConcatAgg",Yw.register();var kL=Yw,Vw=class Vw extends q{constructor(e={}){super(e)}};n(Vw,"ArrayUnionAggExpr"),Vw.key="arrayUnionAgg",Vw.register();var g$=Vw,Hw=class Hw extends q{constructor(e={}){super(e)}};n(Hw,"AvgExpr"),Hw.key="avg",Hw.register();var DL=Hw,_w=class _w extends q{constructor(e={}){super(e)}};n(_w,"AnyValueExpr"),_w.key="anyValue",_w.register();var qL=_w,qE=class qE extends q{constructor(e={}){super(e)}};n(qE,"LagExpr"),qE.key="lag",qE.argOrder=["this","offset","default"],qE.availableArgs=new Set(["this","offset","default"]),qE.register();var E$=qE,UE=class UE extends q{constructor(e={}){super(e)}};n(UE,"LeadExpr"),UE.key="lead",UE.argOrder=["this","offset","default"],UE.availableArgs=new Set(["this","offset","default"]),UE.register();var A$=UE,vE=class vE extends q{constructor(e={}){super(e)}};n(vE,"FirstExpr"),vE.key="first",vE.argOrder=["this","expression"],vE.availableArgs=new Set(["this","expression"]),vE.register();var d$=vE,FE=class FE extends q{constructor(e={}){super(e)}};n(FE,"LastExpr"),FE.key="last",FE.argOrder=["this","expression"],FE.availableArgs=new Set(["this","expression"]),FE.register();var f$=FE,Ww=class Ww extends q{constructor(e={}){super(e)}};n(Ww,"FirstValueExpr"),Ww.key="firstValue",Ww.register();var x$=Ww,jw=class jw extends q{constructor(e={}){super(e)}};n(jw,"LastValueExpr"),jw.key="lastValue",jw.register();var UL=jw,Tl=class Tl extends q{constructor(e={}){super(e)}};n(Tl,"NthValueExpr"),Tl.key="nthValue",Tl.argOrder=["this","offset","fromFirst"],Tl.requiredArgs=new Set(["this","offset"]),Tl.availableArgs=new Set(["this","offset","fromFirst"]),Tl.register();var T$=Tl,Sl=class Sl extends q{constructor(e={}){super(e)}};n(Sl,"ObjectAggExpr"),Sl.key="objectAgg",Sl.argOrder=["this","expression"],Sl.requiredArgs=new Set(["this","expression"]),Sl.availableArgs=new Set(["this","expression"]),Sl.register();var S$=Sl,BE=class BE extends z{constructor(e={}){super(e)}};n(BE,"TryCastExpr"),BE.key="tryCast",BE.requiredArgs=new Set,BE.availableArgs=new Set(["this","to","format","safe","action","default","requiresString"]),BE.register();var $t=BE,Vk=class Vk extends z{constructor(e={}){super(e)}};n(Vk,"JsonCastExpr"),Vk.key="jsonCast";var mb=Vk,Xw=class Xw extends Bt{constructor(e={}){super(e)}};n(Xw,"ConcatWsExpr"),Xw.key="concatWs",Xw._sqlNames=["CONCAT_WS"];var _t=Xw,an=class an extends q{constructor(e={}){super(e)}};n(an,"CountExpr"),an.key="count",an.argOrder=["this","expressions","bigInt"],an.requiredArgs=new Set,an.isVarLenArgs=!0,an.availableArgs=new Set(["this","expressions","bigInt"]),an.register();var bh=an,PI=class PI extends q{constructor(e={}){super(e)}};n(PI,"CountIfExpr"),PI.key="countIf",PI._sqlNames=["COUNT_IF","COUNTIF"],PI.register();var vL=PI,on=class on extends q{constructor(e={}){super(e)}};n(on,"DenseRankExpr"),on.key="denseRank",on.argOrder=[],on.requiredArgs=new Set,on.isVarLenArgs=!0,on.availableArgs=new Set(["expressions"]),on.register();var R$=on,Jw=class Jw extends Xt{constructor(e={}){super(e)}};n(Jw,"ExplodeOuterExpr"),Jw.key="explodeOuter",Jw.register();var _A=Jw,zw=class zw extends Xt{constructor(e={}){super(e)}};n(zw,"PosexplodeExpr"),zw.key="posexplode",zw.register();var li=zw,$E=class $E extends q{constructor(e={}){super(e)}};n($E,"GroupConcatExpr"),$E.key="groupConcat",$E.argOrder=["this","separator","onOverflow"],$E.availableArgs=new Set(["this","separator","onOverflow"]),$E.register();var sr=$E,Hk=class Hk extends $a{constructor(e={}){super(e)}};n(Hk,"LowerHexExpr"),Hk.key="lowerHex";var Ph=Hk,GE=class GE extends V(Ae,E){constructor(e={}){super(e)}};n(GE,"AndExpr"),GE.key="and",GE.requiredArgs=new Set(["this","expression"]),GE.availableArgs=new Set(["this","expression"]),GE.register();var Te=GE,YE=class YE extends V(Ae,E){constructor(e={}){super(e)}};n(YE,"OrExpr"),YE.key="or",YE.requiredArgs=new Set(["this","expression"]),YE.availableArgs=new Set(["this","expression"]),YE.register();var pt=YE,Rl=class Rl extends V(Ae,E){constructor(e={}){super(e)}};n(Rl,"XorExpr"),Rl.key="xor",Rl.requiredArgs=new Set,Rl.isVarLenArgs=!0,Rl.availableArgs=new Set(["this","expression","expressions","roundInput"]),Rl.register();var hA=Rl,VE=class VE extends q{constructor(e={}){super(e)}};n(VE,"JsonObjectAggExpr"),VE.key="jsonObjectAgg",VE.argOrder=["expressions","nullHandling","uniqueKeys","returnType","encoding"],VE.availableArgs=new Set(["expressions","nullHandling","uniqueKeys","returnType","encoding"]),VE.register();var Nb=VE,Ol=class Ol extends q{constructor(e={}){super(e)}};n(Ol,"JsonbObjectAggExpr"),Ol.key="jsonbObjectAgg",Ol.argOrder=["this","expression"],Ol.requiredArgs=new Set(["this","expression"]),Ol.availableArgs=new Set(["this","expression"]),Ol.register();var O$=Ol,HE=class HE extends q{constructor(e={}){super(e)}};n(HE,"JsonArrayAggExpr"),HE.key="jsonArrayAgg",HE.argOrder=["this","order","nullHandling","returnType","strict"],HE.availableArgs=new Set(["this","order","nullHandling","returnType","strict"]),HE.register();var m$=HE,LI=class LI extends q{constructor(e={}){super(e)}};n(LI,"LogicalOrExpr"),LI.key="logicalOr",LI._sqlNames=["LOGICAL_OR","BOOL_OR","BOOLOR_AGG"],LI.register();var FL=LI,wI=class wI extends q{constructor(e={}){super(e)}};n(wI,"LogicalAndExpr"),wI.key="logicalAnd",wI._sqlNames=["LOGICAL_AND","BOOL_AND","BOOLAND_AGG"],wI.register();var BL=wI,ml=class ml extends q{constructor(e={}){super(e)}};n(ml,"MaxExpr"),ml.key="max",ml.argOrder=["this","expressions"],ml.isVarLenArgs=!0,ml.availableArgs=new Set(["this","expressions"]),ml.register();var $L=ml,Qw=class Qw extends q{constructor(e={}){super(e)}};n(Qw,"MedianExpr"),Qw.key="median",Qw.register();var N$=Qw,Nl=class Nl extends q{constructor(e={}){super(e)}};n(Nl,"ModeExpr"),Nl.key="mode",Nl.argOrder=["this","deterministic"],Nl.requiredArgs=new Set,Nl.availableArgs=new Set(["this","deterministic"]),Nl.register();var I$=Nl,Il=class Il extends q{constructor(e={}){super(e)}};n(Il,"MinExpr"),Il.key="min",Il.argOrder=["this","expressions"],Il.isVarLenArgs=!0,Il.availableArgs=new Set(["this","expressions"]),Il.register();var GL=Il,MI=class MI extends q{constructor(e={}){super(e)}};n(MI,"NtileExpr"),MI.key="ntile",MI.requiredArgs=new Set,MI.register();var y$=MI,_E=class _E extends q{constructor(e={}){super(e)}};n(_E,"PercentileContExpr"),_E.key="percentileCont",_E.argOrder=["this","expression"],_E.availableArgs=new Set(["this","expression"]),_E.register();var gd=_E,WE=class WE extends q{constructor(e={}){super(e)}};n(WE,"PercentileDiscExpr"),WE.key="percentileDisc",WE.argOrder=["this","expression"],WE.availableArgs=new Set(["this","expression"]),WE.register();var YM=WE,cn=class cn extends q{constructor(e={}){super(e)}};n(cn,"PercentRankExpr"),cn.key="percentRank",cn.argOrder=[],cn.requiredArgs=new Set,cn.isVarLenArgs=!0,cn.availableArgs=new Set(["expressions"]),cn.register();var C$=cn,yl=class yl extends q{constructor(e={}){super(e)}};n(yl,"QuantileExpr"),yl.key="quantile",yl.argOrder=["this","quantile"],yl.requiredArgs=new Set(["this","quantile"]),yl.availableArgs=new Set(["this","quantile"]),yl.register();var Ad=yl,Zw=class Zw extends q{constructor(e={}){super(e)}};n(Zw,"ApproxPercentileAccumulateExpr"),Zw.key="approxPercentileAccumulate",Zw.register();var b$=Zw,pn=class pn extends q{constructor(e={}){super(e)}};n(pn,"RankExpr"),pn.key="rank",pn.argOrder=[],pn.requiredArgs=new Set,pn.isVarLenArgs=!0,pn.availableArgs=new Set(["expressions"]),pn.register();var P$=pn,Cl=class Cl extends q{constructor(e={}){super(e)}};n(Cl,"RegrValxExpr"),Cl.key="regrValx",Cl.argOrder=["this","expression"],Cl.requiredArgs=new Set(["this","expression"]),Cl.availableArgs=new Set(["this","expression"]),Cl.register();var L$=Cl,bl=class bl extends q{constructor(e={}){super(e)}};n(bl,"RegrValyExpr"),bl.key="regrValy",bl.argOrder=["this","expression"],bl.requiredArgs=new Set(["this","expression"]),bl.availableArgs=new Set(["this","expression"]),bl.register();var w$=bl,Pl=class Pl extends q{constructor(e={}){super(e)}};n(Pl,"RegrAvgyExpr"),Pl.key="regrAvgy",Pl.argOrder=["this","expression"],Pl.requiredArgs=new Set(["this","expression"]),Pl.availableArgs=new Set(["this","expression"]),Pl.register();var M$=Pl,Ll=class Ll extends q{constructor(e={}){super(e)}};n(Ll,"RegrAvgxExpr"),Ll.key="regrAvgx",Ll.argOrder=["this","expression"],Ll.requiredArgs=new Set(["this","expression"]),Ll.availableArgs=new Set(["this","expression"]),Ll.register();var k$=Ll,wl=class wl extends q{constructor(e={}){super(e)}};n(wl,"RegrCountExpr"),wl.key="regrCount",wl.argOrder=["this","expression"],wl.requiredArgs=new Set(["this","expression"]),wl.availableArgs=new Set(["this","expression"]),wl.register();var D$=wl,Ml=class Ml extends q{constructor(e={}){super(e)}};n(Ml,"RegrInterceptExpr"),Ml.key="regrIntercept",Ml.argOrder=["this","expression"],Ml.requiredArgs=new Set(["this","expression"]),Ml.availableArgs=new Set(["this","expression"]),Ml.register();var q$=Ml,kl=class kl extends q{constructor(e={}){super(e)}};n(kl,"RegrR2Expr"),kl.key="regrR2",kl.argOrder=["this","expression"],kl.requiredArgs=new Set(["this","expression"]),kl.availableArgs=new Set(["this","expression"]),kl.register();var U$=kl,Dl=class Dl extends q{constructor(e={}){super(e)}};n(Dl,"RegrSxxExpr"),Dl.key="regrSxx",Dl.argOrder=["this","expression"],Dl.requiredArgs=new Set(["this","expression"]),Dl.availableArgs=new Set(["this","expression"]),Dl.register();var v$=Dl,ql=class ql extends q{constructor(e={}){super(e)}};n(ql,"RegrSxyExpr"),ql.key="regrSxy",ql.argOrder=["this","expression"],ql.requiredArgs=new Set(["this","expression"]),ql.availableArgs=new Set(["this","expression"]),ql.register();var F$=ql,Ul=class Ul extends q{constructor(e={}){super(e)}};n(Ul,"RegrSyyExpr"),Ul.key="regrSyy",Ul.argOrder=["this","expression"],Ul.requiredArgs=new Set(["this","expression"]),Ul.availableArgs=new Set(["this","expression"]),Ul.register();var B$=Ul,vl=class vl extends q{constructor(e={}){super(e)}};n(vl,"RegrSlopeExpr"),vl.key="regrSlope",vl.argOrder=["this","expression"],vl.requiredArgs=new Set(["this","expression"]),vl.availableArgs=new Set(["this","expression"]),vl.register();var $$=vl,Kw=class Kw extends q{constructor(e={}){super(e)}};n(Kw,"SumExpr"),Kw.key="sum",Kw.register();var YL=Kw,kI=class kI extends q{constructor(e={}){super(e)}};n(kI,"StddevExpr"),kI.key="stddev",kI._sqlNames=["STDDEV","STDEV"],kI.register();var VL=kI,eM=class eM extends q{constructor(e={}){super(e)}};n(eM,"StddevPopExpr"),eM.key="stddevPop",eM.register();var HL=eM,tM=class tM extends q{constructor(e={}){super(e)}};n(tM,"StddevSampExpr"),tM.key="stddevSamp",tM.register();var _L=tM,ln=class ln extends q{constructor(e={}){super(e)}};n(ln,"CumeDistExpr"),ln.key="cumeDist",ln.argOrder=[],ln.requiredArgs=new Set,ln.isVarLenArgs=!0,ln.availableArgs=new Set(["expressions"]),ln.register();var G$=ln,DI=class DI extends q{constructor(e={}){super(e)}};n(DI,"VarianceExpr"),DI.key="variance",DI._sqlNames=["VARIANCE","VARIANCE_SAMP","VAR_SAMP"],DI.register();var WL=DI,qI=class qI extends q{constructor(e={}){super(e)}};n(qI,"VariancePopExpr"),qI.key="variancePop",qI._sqlNames=["VARIANCE_POP","VAR_POP"],qI.register();var jL=qI,sM=class sM extends q{constructor(e={}){super(e)}};n(sM,"KurtosisExpr"),sM.key="kurtosis",sM.register();var XL=sM,rM=class rM extends q{constructor(e={}){super(e)}};n(rM,"SkewnessExpr"),rM.key="skewness",rM.register();var JL=rM,Fl=class Fl extends q{constructor(e={}){super(e)}};n(Fl,"CovarSampExpr"),Fl.key="covarSamp",Fl.argOrder=["this","expression"],Fl.requiredArgs=new Set(["this","expression"]),Fl.availableArgs=new Set(["this","expression"]),Fl.register();var Y$=Fl,Bl=class Bl extends q{constructor(e={}){super(e)}};n(Bl,"CovarPopExpr"),Bl.key="covarPop",Bl.argOrder=["this","expression"],Bl.requiredArgs=new Set(["this","expression"]),Bl.availableArgs=new Set(["this","expression"]),Bl.register();var V$=Bl,iM=class iM extends GM{constructor(e={}){super(e)}};n(iM,"CombinedAggFuncExpr"),iM.key="combinedAggFunc",iM.register();var H$=iM,nM=class nM extends $M{constructor(e={}){super(e)}};n(nM,"CombinedParameterizedAggExpr"),nM.key="combinedParameterizedAgg",nM.register();var _$=nM,jE=class jE extends V(li,_A){constructor(e={}){super(e)}};n(jE,"PosexplodeOuterExpr"),jE.key="posexplodeOuter",jE.requiredArgs=new Set(["this"]),jE.availableArgs=new Set(["this","expressions"]),jE.register();var W$=jE,XE=class XE extends Ad{constructor(e={}){super(e)}};n(XE,"ApproxQuantileExpr"),XE.key="approxQuantile",XE.argOrder=["this","quantile","accuracy","weight","errorTolerance"],XE.availableArgs=new Set(["this","quantile","accuracy","weight","errorTolerance"]),XE.register();var wh=XE;function $n(a,e={}){let{col:t,table:s,db:r,catalog:i}=a,{fields:o,quoted:c,copy:p=!0}=e,u;t instanceof Ne?u=t:u=K(t,{quoted:c,copy:p});let h=new $({this:u,table:s!==void 0?K(s,{quoted:c,copy:p}):void 0,db:r!==void 0?K(r,{quoted:c,copy:p}):void 0,catalog:i!==void 0?K(i,{quoted:c,copy:p}):void 0});if(o&&0<o.length){let g=o.map(f=>K(f,{quoted:c,copy:p})).filter(f=>f!==void 0);return ge.build([h,...g])}return h}n($n,"column");function yj(a,e={}){let{db:t,catalog:s,quoted:r,alias:i}=e;return new _({this:a?K(a,{quoted:r}):void 0,db:t?K(t,{quoted:r}):void 0,catalog:s?K(s,{quoted:r}):void 0,alias:i?new pe({this:K(i)}):void 0})}n(yj,"table_");function F_(a,e,t){let s={this:new v({this:a})};return e&&(s.db=new v({this:e})),t&&(s.catalog=new v({this:t})),new _(s)}n(F_,"table");function ve(a,e={}){let{dialect:t,copy:s=!0,wrap:r=!0,...i}=e;return VA(a,Te,{dialect:t,copy:s,wrap:r,...i})}n(ve,"and");function Vt(a,e={}){let{dialect:t,copy:s=!0,wrap:r=!0,...i}=e;return VA(a,pt,{dialect:t,copy:s,wrap:r,...i})}n(Vt,"or");function ED(a,e={}){let{dialect:t,copy:s=!0,wrap:r=!0,...i}=e;return VA(a,hA,{dialect:t,copy:s,wrap:r,...i})}n(ED,"xor");function ks(a,e={}){let t=G_(a,e);return new Le({this:mr(t,Ae)||t})}n(ks,"not");function zs(a,e={}){let{copy:t=!0,...s}=e;return new Se({this:W(a,{copy:t,...s})})}n(zs,"paren");var tw=/^[_a-zA-Z][\w]*$/;function K(a,e={}){let{quoted:t,copy:s=!0}=e;if(a!==void 0)return a instanceof v?$e(a,s):new v({this:a,quoted:t!==void 0?t:!tw.test(a.toString())})}n(K,"toIdentifier");function ty(a,e={}){let{dialect:t,...s}=e;try{return W(a,{dialect:t,into:v,...s})}catch{return K(a)}}n(ty,"parseIdentifier");var ID=/\s*(-?[0-9]+(?:\.[0-9]+)?)\s*([a-zA-Z]+)\s*/,yD=/\s*-?\s*\d+(?:\.\d+)?\s+(?:-?(?:\d+:)?\d+:\d+(?:\.\d+)?|-?(?:\d+:){1,2}|:)\s*/;function Cj(a){let e;if(a instanceof N){if(!a.args.isString)throw new Error("Invalid interval string.");e=a.args.this}else e=a;let t=W(`INTERVAL ${e}`);if(!(t instanceof qe))throw new Error("Failed to parse interval expression");return t}n(Cj,"toInterval");function Be(a,e,t={}){let{table:s,quoted:r,dialect:i,copy:o=!0,...c}=t,p=W(a,{dialect:i,copy:o,...c}),u=e!==void 0?K(e instanceof v?e:e.toString(),{quoted:r}):void 0;if(s){let h=new pe({this:u});if(p.setArgKey("alias",h),Array.isArray(s))for(let g of s){let f=K(g,{quoted:r});f&&h.append("columns",f)}return p}return p._constructor.availableArgs.has("alias")&&!(p instanceof Ue)?(u&&p.setArgKey("alias",u),p):new Re({this:p,alias:u})}n(Be,"alias");function DD(a,e,t={}){let{dialect:s,...r}=t,i=W(a,{dialect:s,...r});if(!(i instanceof ee))throw new Error("The input sql is not a QueryExpr");let o=i.subquery(e,r);return new se({}).from(o,{dialect:s,...r})}n(DD,"subquery");function Ye(a,e={}){return new se().select(a,e)}n(Ye,"select");function bj(a,e={}){return new se({}).from(a,e)}n(bj,"from");function qD(a,e={}){let t;return a!==void 0&&(t=W(a,e)),new ut({this:t,ifs:[]})}n(qD,"case_");function X(a,e,t={}){let{copy:s=!0,dialect:r,...i}=t,o=W(a,{copy:s,dialect:r,...i}),c=m.build(e,{copy:s,dialect:r,...i});if(o instanceof z){let h=ae.getOrRaise(r)._constructor.generatorClass.TYPE_MAPPING,g=o.args.to?.args.this,f=c?.args.this,x=(h.get(g?.toString()??"")||g?.toString())?.toUpperCase(),T=(h.get(f?.toString()??"")||f?.toString())?.toUpperCase(),y=g!=null&&x===T;if(c!==void 0&&o.isType([c])||y)return o}let p=new z({this:o,to:c});return p.type=c,p}n(X,"cast");function Pj(a,e={}){let{alias:t,columns:s}=e;if(s&&!t)throw new Error("Alias is required when providing columns");let r=a.map(o=>new Ze({expressions:o.map(c=>ht(c))})),i;return s?i=new pe({this:t!==void 0?K(t):void 0,columns:s.map(o=>K(o)).filter(o=>o!==void 0)}):t&&(i=new pe({this:K(t)})),new tr({expressions:r,alias:i})}n(Pj,"values");function HA(a,...e){let t=e.map(r=>typeof r=="string"?W(r):ht(r)),s=jl.get(a.toUpperCase());return s?s.fromArgList(t):new Qe({this:a,expressions:t})}n(HA,"func");function J$(a,e,t={}){let{distinct:s=!0,dialect:r,copy:i=!0,...o}=t;return a?.map(p=>W(p,{dialect:r,copy:i,...o}))?.reduce((p,u)=>new e({this:p,expression:u,distinct:s,...o}))}n(J$,"applySetOperation");function WA(a,e={}){let t=Array.from(J(a)).filter(s=>s!==void 0);if(t.length<2)throw new Error("At least two expressions are required by `union`.");return J$(t,or,e)}n(WA,"union");function B_(a,e={}){let t=Array.from(J(a)).filter(s=>s!==void 0);if(t.length<2)throw new Error("At least two expressions are required by `intersect`.");return J$(t,ei,e)}n(B_,"intersect");function $_(a,e={}){let t=Array.from(J(a)).filter(s=>s!==void 0);if(t.length<2)throw new Error("At least two expressions are required by `except`.");return J$(t,cr,e)}n($_,"except");function Lj(a,e,t={}){let{columns:s,overwrite:r,returning:i,dialect:o,copy:c=!0,...p}=t,u=W(a,{dialect:o,copy:c,...p}),h=W(e,{into:_,dialect:o,copy:c,...p});s&&(h=new Rt({this:h,expressions:s.map(f=>typeof f=="string"?K(f):f)}));let g=new es({this:h,expression:u,overwrite:r});return i&&(g=g.returning(i,{dialect:o,copy:!1,...p})),g}n(Lj,"insert");function wj(a,e={}){let{where:t,returning:s,dialect:r,...i}=e,o=new Gr({}).delete(a,{dialect:r,copy:!1,...i});return t&&(o=o.where(t,{dialect:r,copy:!1,...i})),s&&(o=o.returning(s,{dialect:r,copy:!1,...i})),o}n(wj,"delete_");function Mj(a,e,t={}){let{where:s,from:r,with:i,dialect:o,...c}=t,p=new us({this:W(a,{into:_,dialect:o})});if(e&&p.setArgKey("expressions",Object.entries(e).map(([u,h])=>new Me({this:W(u,{dialect:o,...c}),expression:ht(h)}))),r&&p.setArgKey("from",W(r,{into:rt,dialect:o,prefix:"FROM",...c})),s){let u=s;s instanceof Ce&&(u=new St({this:s})),p.setArgKey("where",W(u,{into:St,dialect:o,prefix:"WHERE",...c}))}if(i){let u=Object.entries(i).map(([h,g])=>Be(new Ft({this:W(g,{dialect:o,...c})}),h,{table:!0}));p.setArgKey("with",new dt({expressions:u}))}return p}n(Mj,"update");function kj(a,e={}){let{into:t,using:s,on:r,returning:i,dialect:o,copy:c=!0,...p}=e,u=a!==void 0?Array.from(J(a)):[],h=[];for(let x of u){let T=W(x,{dialect:o,copy:c,into:Au,...p});T instanceof _n?h.push(T):h.push(...T.args.expressions)}let g=new GA({this:W(t,{dialect:o,copy:c,...p}),using:W(s,{dialect:o,copy:c,...p}),on:W(r,{dialect:o,copy:c,...p}),whens:new Au({expressions:h})});i&&(g=g.returning(i,{dialect:o,copy:!1,...p}));let f=g.args.using;if(f instanceof Re){let x=f.args.alias,T=typeof x=="string"||Y(x,v)?x:void 0;f.replace(Be(f.args.this,T,{table:!0}))}return g}n(kj,"merge");function G_(a,e={}){return W(a,{into:Ce,...e})}n(G_,"condition");function W(a,e){if(a instanceof d)return e?.copy?a.copy():a;if(a===void 0)throw new Ke("SQL cannot be null or undefined");let t=String(a);e?.prefix&&(t=`${e.prefix} ${t}`);let{dialect:s,...r}=e||{};return mD(t,{...r,read:s||r.read})}n(W,"maybeParse");function UI(a,e={}){let{dialect:t,copy:s=!0,...r}=e;if(a instanceof _)return $e(a,s);try{let i=W(a,{into:_,dialect:t,...r});for(let[o,c]of Object.entries(r))i.setArgKey(o,c);return i}catch{let[i,o,c]=BY(a,".",3);if(!c)throw new Error(`Invalid table path: ${a}`);let p=F_(c,o,i);for(let[u,h]of Object.entries(r))p.setArgKey(u,h);return p}}n(UI,"toTable");function j$(a,e={}){let{quoted:t,dialect:s,copy:r=!0,...i}=e;if(a instanceof $)return $e(a,r);try{let o=W(a,{into:$,dialect:s,...i});for(let[c,p]of Object.entries(i))o.setArgKey(c,p);if(t)for(let c of o.findAll(v))c.setArgKey("quoted",!0);return o}catch{let o=a.split(".").reverse(),[c,p]=o,u={this:K(c,{quoted:t})};p&&(u.table=K(p,{quoted:t}));let h=new $(u);for(let[g,f]of Object.entries(i))h.setArgKey(g,f);return h}}n(j$,"toColumn");function Dj(a){let e=new Set;for(let t of sA(a))for(let s of t.tables)s.name&&!t.cteSources.has(s.name)&&e.add(s);return e}n(Dj,"findTables");function $e(a,e=!0){return e&&a?a.copy():a}n($e,"maybeCopy");function Y_(a,e){return a instanceof d&&!(a instanceof e)}n(Y_,"isWrongExpression");function JE(a,e){let{instance:t,arg:s,copy:r=!0,prefix:i,into:o,dialect:c,intoArg:p="this",...u}=e;o&&Y_(a,o)&&(a=new o({[p]:a}));let h=$e(t,r),g=W(a,{prefix:i,into:o,dialect:c,...u});return s!==void 0&&h.setArgKey(s,g),h}n(JE,"applyBuilder");function dd(a,e={}){let{instance:t,arg:s,append:r=!0,copy:i=!0,prefix:o,into:c,dialect:p,properties:u,...h}=e,g=$e(t,i),f=[],x=u||{},T=J(a);for(let b of T){if(b===void 0)continue;let k=b;c&&Y_(k,c)&&(k=new c({expressions:[k]}));let B=W(k,{into:c,dialect:p,prefix:o,...h});for(let[j,Q]of Object.entries(B.args))j==="expressions"?f.push(...Q):x[j]=Q}let y=g.getArgKey(s),C=f;r&&y&&y.args.expressions&&(C=[...y.args.expressions,...f]);let I=c?new c({expressions:C}):new d({expressions:C});for(let[b,k]of Object.entries(x))I.setArgKey(b,k);return s!==void 0&&g.setArgKey(s,I),g}n(dd,"applyChildListBuilder");function Hh(a,e){let{instance:t,arg:s,append:r=!0,copy:i=!0,prefix:o,into:c,dialect:p,...u}=e,h=$e(t,i),f=J(a).filter(T=>T!==void 0).map(T=>W(T,{into:c,prefix:o,dialect:p,...u})),x=h?.getArgKey(s);return s!==void 0&&(r&&x?h?.setArgKey(s,[...x,...f]):h?.setArgKey(s,f)),h}n(Hh,"applyListBuilder");function vI(a,e={}){let{instance:t,arg:s,into:r,append:i=!0,copy:o=!0,dialect:c,...p}=e,h=Array.from(J(a)).filter(I=>I!==void 0&&I!=="");if(h.length===0)return t;let g=$e(t,o),f=g.getArgKey(s),x=[...h];i&&f instanceof d&&(x=[r&&"this"in f.args?f.args.this:f,...h]);let T=n(I=>I instanceof Ae?new Se({this:I}):I,"wrapConnector"),y;if(0<x.length){let I=x.map(j=>W(j,{dialect:c,copy:o,...p})),[b,...k]=I,B=b;0<k.length&&(B=T(b)),y=k.reduce((j,Q)=>new Te({this:j,expression:T(Q)}),B)}let C=r&&y?new r({this:y}):y;return C&&s!==void 0&&g.setArgKey(s,C),g}n(vI,"applyConjunctionBuilder");function z$(a){let{instance:e,alias:t,as:s,recursive:r,materialized:i,append:o=!0,dialect:c,copy:p=!0,scalar:u,...h}=a,g=W(t,{dialect:c,into:pe,...h}),f=W(s,{dialect:c,copy:p,...h});u&&!(f instanceof he)&&(f=new he({this:f}));let x=new Ft({this:f,alias:g,materialized:i,scalar:u});return dd([x],{instance:e,arg:"with",append:o,copy:p,into:dt,properties:r?{recursive:r}:{}})}n(z$,"applyCteBuilder");function VA(a,e,t={}){let{dialect:s,copy:r=!0,wrap:i=!0,...o}=t,p=Array.from(J(a)).filter(f=>f!==void 0&&f!=="").map(f=>W(f,{dialect:s,copy:r,...o})),[u,...h]=p,g=u;0<h.length&&i&&(g=mr(g,Ae)||g);for(let f of h)g=new e({this:g,expression:i&&mr(f,Ae)||f});return g}n(VA,"combine");function mr(a,e){return a instanceof e?new Se({this:a}):a}n(mr,"wrap");function Hl(a){return typeof a=="string"?N.string(a):typeof a=="number"?N.number(a):N.string(String(a))}n(Hl,"literal");function le(){return new Pt({})}n(le,"null_");function We(){return new at({this:!0})}n(We,"true_");function it(){return new at({this:!1})}n(it,"false_");function ht(a,e={}){let{copy:t=!1}=e;if(a instanceof d){let s=$e(a,t);if(s)return s}if(typeof a=="string")return N.string(a);if(typeof a=="boolean")return new at({this:a});if(a===void 0||typeof a=="number"&&isNaN(a))return le();if(typeof a=="number")return N.number(a);if(D_.isDateTime(a)){let s=a.toFormat("yyyy-MM-dd HH:mm:ss");if(0<a.millisecond){let o=(a.millisecond*1e3).toString().padStart(6,"0");s+=`.${o}`}let r=N.string(s),i;return a.zone.isUniversal&&(i=N.string(a.zoneName)),new Yh({this:r,zone:i})}if(a instanceof Date){let r=D_.fromJSDate(a).toFormat("yyyy-MM-dd HH:mm:ss"),i=N.string(r);return new Yh({this:i,zone:void 0})}if(Array.isArray(a))return new ue({expressions:a.map(s=>ht(s,{copy:t}))});if(a!==null&&typeof a=="object"){let s=Object.entries(a);return new mn({keys:new ue({expressions:s.map(([r])=>N.string(r))}),values:new ue({expressions:s.map(([,r])=>ht(r,{copy:t}))})})}throw new Error(`Cannot convert ${a}`)}n(ht,"convert");function Z(a){if(!a)throw new Error("Cannot convert empty name into var.");return a instanceof d&&(a=a.name),new Ve({this:a})}n(Z,"var_");function UA(a,e={}){let{copy:t=!0,dialect:s,...r}=e,i=Array.from(J(a));return new ue({expressions:i.map(o=>W(o,{copy:t,dialect:s,...r}))})}n(UA,"array");function qj(a,e={}){let{copy:t=!0,dialect:s,...r}=e,i=Array.from(J(a));return new Ze({expressions:i.map(o=>W(o,{copy:t,dialect:s,...r}))})}n(qj,"tuple");function Uj(a,e,t={}){let{dialect:s}=t,r=UI(a,{dialect:s}),i=UI(e,{dialect:s});return new lu({this:r,kind:"table",actions:[new Yn({this:i})]})}n(Uj,"renameTable");function vj(a,e,t,s={}){let{exists:r,dialect:i}=s,o=UI(a,{dialect:i}),c=j$(e,{dialect:i}),p=j$(t,{dialect:i});return new lu({this:o,kind:"table",actions:[new vA({this:c,to:p,exists:r})]})}n(vj,"renameColumn");function wM(a,e={}){let{exclude:t=""}=e,s=new Set;for(let r of a.findAll($)){let i=r.table;i&&i!==t&&s.add(i)}return s}n(wM,"columnTableNames");function Fj(a,e={}){let{dialect:t,identify:s=!1}=e,r=W(a,{into:_,dialect:t});if(!r)throw new Error(`Cannot parse ${a}`);return r.parts.map(i=>s||!tw.test(i.name)?i.sql({dialect:t,identify:!0,copy:!1,comments:!1}):i.name).join(".")}n(Fj,"tableName");function SM(a,e,...t){for(let[s,r]of Object.entries(a.args)){let i=Array.isArray(r),o=i?r:[r],c=[];for(let p of o)if(p instanceof d){let u=e(p,...t),h=Array.isArray(u)?u:[u];c.push(...h)}else c.push(p);i?a.setArgKey(s,c):a.setArgKey(s,c[0])}}n(SM,"replaceChildren");function Bj(a,e,t){let s=Array.from(a.dfs({prune:t})),r=a;for(;0<s.length;){let i=s.pop();r=e(i),r!==i&&(i.replace(r),r instanceof d&&s.push(r))}return r}n(Bj,"replaceTree");function aM(a,e={}){let{dialect:t,copy:s=!0}=e;return ey(UI(a,{dialect:t,copy:s}),{dialect:t}).parts.map(r=>r.name).join(".")}n(aM,"normalizeTableName");function $j(a,e,t={}){let{dialect:s,copy:r=!0}=t,i={};for(let[c,p]of Object.entries(e))i[aM(c,{dialect:s})]=p;function o(c){if(c instanceof _&&c.meta.replace!==!1){let p=aM(c,{dialect:s}),u=i[p];if(u){let h=UI(u,{dialect:s});for(let[g,f]of Object.entries(c.args))["this","db","catalog"].includes(g)||h.setArgKey(g,f);return h.addComments([p]),h}}return c}return n(o,"replaceTablesTransform"),a.transform(o,{copy:r})}n($j,"replaceTables");function Gj(a,e=[],t={}){let s=0;function r(i){if(i instanceof ar){if(typeof i.args.this=="string"){let o=t[i.args.this];if(o!==void 0)return ht(o)}else if(s<e.length)return ht(e[s++])}return i}return n(r,"replacePlaceholder"),a.transform(r)}n(Gj,"replacePlaceholders");function Yj(a,e,t={}){let{dialect:s,copy:r=!0}=t,i={};for(let[c,p]of Object.entries(e))i[aM(c,{dialect:s})]=p;function o(c){if(c instanceof _){let p=aM(c,{dialect:s}),u=i[p];if(u){let h=typeof u=="function"?u():u,g=c.alias||p,f=h.subquery(g);return f.comments=[`source: ${p}`],f.transform(o,{copy:!1})}}return c}return n(o,"expandTransform"),a.transform(o,{copy:r})}n(Yj,"expand");var Ls=[se,Ge],MM=[gd,YM],AD=[N,at],dD=[N,at,Pt],Vj=new Set([Vs,Mt,xr,zt,Hs,Tr,ts,Sr,Dt]);function Rn(a,e){if(!Y(a,"string",d)||a===void 0)return!1;if(a instanceof d)return a.isType(e);let t=typeof e!="string"&&$I(e)?e:[e];for(let r of t)if(r.toLowerCase()===a.toLowerCase())return!0;let s=st(At,a.toString());if(s===void 0)return!1;for(let r of t)if(r===s)return!0;return!1}n(Rn,"isType");function QE(a,e,t=[]){let s=[],r=e??gA(a)-1;for(let[i,o]of Object.entries(a))r===1||typeof o!="object"||o===void 0?s.push([...t,i]):2<=r&&s.push(...QE(o,r-1,[...t,i]));return s}n(QE,"flattenSchema");function cM(a,e,t={}){let{raiseOnMissing:s=!0}=t,r=a;for(let[i,o]of e){if(typeof r!="object"||r===void 0){if(s)throw new is(`Unknown ${i==="this"?"table":i}: ${o}`);return}let c=r[o];if(c===void 0||c===void 0){if(s)throw new is(`Unknown ${i==="this"?"table":i}: ${o}`);return}r=c}return r}n(cM,"nestedGet");function Q$(a,e,t){if(!e.length)return a;if(e.length===1)return a[e[0]]=t,a;let s=a;for(let r=0;r<e.length-1;r++)(!(e[r]in s)||typeof s[e[r]]!="object"||s[e[r]]===void 0)&&(s[e[r]]={}),s=s[e[r]];return s[e[e.length-1]]=t,a}n(Q$,"nestedSet");function Hj(a){if(a==null)return{};if(typeof a=="object"&&!Array.isArray(a))return a;if(typeof a=="string")return Object.fromEntries(a.split(",").map(e=>{let[t,s]=e.split(":").map(r=>r.trim());return[t,s]}));if(Array.isArray(a))return Object.fromEntries(a.map(e=>[e.trim(),void 0]));throw new Error(`Invalid mapping provided: ${typeof a}`)}n(Hj,"ensureColumnMapping");function oM(a,e={}){let{dialect:t,isTable:s=!1,normalize:r=!0}=e,i=typeof a=="string"?ty(a,{dialect:t}):a.copy();return r?(i.meta.isTable=s,ae.getOrRaise(t).normalizeIdentifier(i)):i}n(oM,"normalizeName");var K$=class K${get dialect(){}get empty(){return!0}hasColumn(e,t,s){let r=typeof t=="string"?t:t.name;return this.columnNames(e,s).includes(r)}getUdfType(e,t){return m.build("unknown")}};n(K$,"Schema");var pM=K$,eG=class eG extends pM{constructor(e,t){super(),this.mapping=e||{},this.udfMapping=t||{},this.mappingTrie=Gt(QE(this.mapping,this.depth()).map(s=>[...s].reverse())),this.udfTrie=Gt(QE(this.udfMapping,this.udfDepth()).map(s=>[...s].reverse()))}get empty(){return Object.keys(this.mapping).length===0}depth(){return gA(this.mapping)}udfDepth(){return gA(this.udfMapping)}get supportedTableArgs(){if(!this._supportedTableArgs&&!this.empty){let e=this.depth();if(!e)this._supportedTableArgs=[];else if(1<=e&&e<=3)this._supportedTableArgs=X$.slice(0,e);else throw new is(`Invalid mapping shape. Depth: ${e}`)}return this._supportedTableArgs||[]}tableParts(e){return[...e.parts].reverse().map(t=>t.name)}udfParts(e){let t=e.parent;return[...t instanceof ge?[...t.flatten()].map(r=>r.name):[e.name]].reverse().slice(0,this.udfDepth())}findInTrie(e,t,s){let{raiseOnMissing:r}=s,[i,o]=Nn(t,e);if(i!==0){if(i===1){let c=QE(o);if(c.length===1)e.push(...c[0]);else{if(r){let p=e.join("."),u=c.map(h=>h.join(".")).join(", ");throw new is(`Ambiguous mapping for ${p}: ${u}.`)}return}}return e}}find(e,t={}){let{raiseOnMissing:s=!0}=t,r=this.tableParts(e).slice(0,this.supportedTableArgs.length),i=this.findInTrie(r,this.mappingTrie,{raiseOnMissing:s});if(i)return this.nestedGet(i,void 0,{raiseOnMissing:s})}findUdf(e,t={}){let{raiseOnMissing:s=!1}=t,r=this.udfParts(e),i=this.findInTrie(r,this.udfTrie,{raiseOnMissing:s});if(!i)return;let o=[...i].reverse();return cM(this.udfMapping,i.map((c,p)=>[c,o[p]]),{raiseOnMissing:s})}nestedGet(e,t,s={}){let{raiseOnMissing:r=!0}=s,i=[...e].reverse();return cM(t||this.mapping,this.supportedTableArgs.map((o,c)=>[o,i[c]]),{raiseOnMissing:r})}};n(eG,"AbstractMappingSchema");var Z$=eG,zE=class zE extends V(Z$,pM){constructor(t,s={}){let r,i,o,c,p;if(t&&("schema"in t||"udfMapping"in t||"visible"in t||"dialect"in t||"normalize"in t)){let g=t;r=g.schema||{},i=g.visible,o=g.dialect,c=g.normalize??!0,p=g.udfMapping}else r=t||{},{visible:i,dialect:o,normalize:c=!0,udfMapping:p}=s;let u=o?ae.getOrRaise(o):new ae,h=p||{};super(c?zE.normalizeSchemaStatic(r,u,{normalize:c}):r,c?zE.normalizeUdfsStatic(h,u,{normalize:c}):h);this._typeCache={};this._depth=0;this.visible=i||{},this.normalize=c,this._dialect=u}static fromMappingSchema(t){return new zE(t.mapping,{visible:t.visible,dialect:t.dialect,normalize:t.normalize,udfMapping:t.udfMapping})}get dialect(){return this._dialect}depth(){return!this.empty&&!this._depth&&(this._depth=super.depth()-1),this._depth}copy(t={}){return new zE(t.schema??{...this.mapping},{visible:t.visible??{...this.visible},dialect:t.dialect??this.dialect,normalize:t.normalize??this.normalize,udfMapping:t.udfMapping??{...this.udfMapping}})}find(t,s={}){let{ensureDataTypes:r=!1}=s,i=super.find(t,s);return!r||typeof i!="object"||i===null?i:Object.fromEntries(Object.entries(i).map(([o,c])=>[o,typeof c=="string"?this.toDataType(c):c]))}addTable(t,s,r={}){let{dialect:i,normalize:o,matchDepth:c=!0}=r,p=this.normalizeTable(t,i,o);if(c&&!this.empty&&p.parts.length!==this.depth())throw new is(`Table ${p.sql()} must match the schema's nesting level: ${this.depth()}.`);let u=Object.fromEntries(Object.entries(Hj(s)).map(([f,x])=>[this.normalizeName(f,i,{isTable:!1,normalize:o}),x]));if(this.find(p,{raiseOnMissing:!1})&&!Object.keys(u).length)return;let g=this.tableParts(p);Q$(this.mapping,[...g].reverse(),u),Gt([g],this.mappingTrie)}columnNames(t,s={}){let{onlyVisible:r=!1,dialect:i,normalize:o}=s,c=this.normalizeTable(t,i,o),p=this.find(c);if(!p||typeof p!="object")return[];let u=Object.keys(p);if(!r||!Object.keys(this.visible).length)return u;let h=this.nestedGet(this.tableParts(c),this.visible,{raiseOnMissing:!1}),g=h instanceof Set?h:h||[];return u.filter(f=>g instanceof Set?g.has(f):g.includes(f))}getColumnType(t,s,r={}){let{dialect:i,normalize:o}=r,c=this.normalizeTable(t,i,o),p=this.normalizeName(typeof s=="string"?s:s.args.this,i,{isTable:!1,normalize:o}),u=this.find(c,{raiseOnMissing:!1});if(u&&typeof u=="object"){let h=u[p];if(h instanceof m)return h;if(typeof h=="string")return this.toDataType(h,i)}return m.build("unknown")}hasColumn(t,s,r){let{dialect:i,normalize:o}=r||{},c=this.normalizeTable(t,i,o),p=this.normalizeName(typeof s=="string"?s:s.args.this,i,{isTable:!1,normalize:o}),u=this.find(c,{raiseOnMissing:!1});return u?p in u:!1}getUdfType(t,s={}){let{dialect:r,normalize:i}=s,o=this.normalizeUdf(t,r,i),c=this.findInTrie(o,this.udfTrie,{raiseOnMissing:!1});if(!c)return m.build("unknown");let p=[...c].reverse(),u=cM(this.udfMapping,c.map((h,g)=>[h,p[g]]),{raiseOnMissing:!1});return u instanceof m?u:typeof u=="string"?this.toDataType(u,r):m.build("unknown")}normalizeUdf(t,s,r){let i=s?ae.getOrRaise(s):this._dialect,o=r??this.normalize,c;if(typeof t=="string"){let u=W(t,{dialect:i});if(u instanceof Qe)c=u;else if(u instanceof ge){let h=[...u.flatten()],g=h[h.length-1];if(!(g instanceof Qe))throw new is(`Unable to parse UDF from: ${JSON.stringify(t)}`);c=g}else throw new is(`Unable to parse UDF from: ${JSON.stringify(t)}`)}else c=t;let p=this.udfParts(c);return o?p.map(u=>this.normalizeName(u,s,{isTable:!0,normalize:r})):p}toDataType(t,s){if(!this._typeCache[t]){let r=s?ae.getOrRaise(s):this._dialect,i=m.build(t,{dialect:r,udt:r._constructor.SUPPORTS_USER_DEFINED_TYPES});i?.transform(o=>r.normalizeIdentifier(o),{copy:!1}),this._typeCache[t]=i}return this._typeCache[t]}normalizeTable(t,s,r){let i=s?ae.getOrRaise(s):this._dialect,o=r??this.normalize,c=W(t,{into:_,dialect:i,copy:o});if(o)for(let p of c.parts)p instanceof v&&p.replace(oM(p,{dialect:i,isTable:!0,normalize:o}));return c}normalizeName(t,s,r={}){let{isTable:i=!1,normalize:o}=r,c=s?ae.getOrRaise(s):this._dialect;return oM(t,{dialect:c,isTable:i,normalize:o??this.normalize}).name}static normalizeSchemaStatic(t,s,r){let{normalize:i}=r;if(!i||!Object.keys(t).length)return t;let o={},c=QE(t);if(!c.length)return t;for(let p of c){let u=cM(t,p.map(x=>[x,x]),{raiseOnMissing:!1});if(typeof u!="object"||u===void 0)throw new is(`Table ${p.slice(0,-1).join(".")} must match the schema's nesting level: ${c[0].length}.`);let h=Object.entries(u);if(!h.length)throw new is(`Table ${p.slice(0,-1).join(".")} must have at least one column`);let g=h[0][1];if(g!=null&&typeof g=="object"&&!(g instanceof d)){let x=QE(u);throw new is(`Table ${[...p,...x[0]||[]].join(".")} must match the schema's nesting level: ${c[0].length}.`)}let f=p.map(x=>oM(x,{dialect:s,isTable:!0,normalize:i}).name);for(let[x,T]of h)Q$(o,[...f,oM(x,{dialect:s,normalize:i}).name],T)}return o}static normalizeUdfsStatic(t,s,r){let{normalize:i}=r;if(!i||!Object.keys(t).length)return t;let o={};for(let c of QE(t,gA(t))){let p=cM(t,c.map(h=>[h,h]),{raiseOnMissing:!1}),u=c.map(h=>oM(h,{dialect:s,isTable:!0,normalize:i}).name);Q$(o,u,p)}return o}};n(zE,"MappingSchema");var ZI=zE;function NM(a,e={}){return a instanceof pM?a:new ZI(a,e)}n(NM,"ensureSchema");export{n as a,vt as b,Nt as c,It as d,R as e,hM as f,un as g,kr as h,Ke as i,ZE as j,$l as k,nG as l,aG as m,KE as n,Y as o,re as p,ct as q,Et as r,O as s,tW as t,cX as u,pX as v,lX as w,uX as x,hX as y,gX as z,EX as A,AX as B,dX as C,fX as D,xX as E,dW as F,TX as G,SX as H,RX as I,OX as J,mX as K,NX as L,GI as M,dG as N,eA as O,fG as P,xG as Q,TG as R,SG as S,RG as T,OG as U,mG as V,NG as W,AM as X,IG as Y,yG as Z,Yt as _,CG as $,bG as aa,PG as ba,At as ca,YI as da,LG as ea,wG as fa,MG as ga,kG as ha,DG as ia,qG as ja,UG as ka,vG as la,FG as ma,BG as na,$G as oa,GG as pa,YG as qa,VG as ra,tD as sa,dM as ta,HG as ua,_G as va,WG as wa,jG as xa,sD as ya,QE as za,cM as Aa,Q$ as Ba,oM as Ca,pM as Da,ZI as Ea,NM as Fa,js as Ga,sA as Ha,$X as Ia,rA as Ja,Dr as Ka,PW as La,Kt as Ma,Yl as Na,XX as Oa,xM as Pa,IM as Qa,LW as Ra,D as Sa,J as Ta,yM as Ua,En as Va,FY as Wa,CM as Xa,BY as Ya,gA as Za,AA as _a,qY as $a,bM as ab,Wl as bb,ey as cb,jl as db,sy as eb,z0 as fb,mD as gb,zW as hb,Jt as ib,RD as jb,sj as kb,oV as lb,rj as mb,pV as nb,ry as ob,GD as pb,YD as qb,q_ as rb,ND as sb,X$ as tb,U_ as ub,v_ as vb,d as wb,Ce as xb,ke as yb,An as zb,ee as Ab,yt as Bb,iy as Cb,ny as Db,ay as Eb,dn as Fb,_D as Gb,bs as Hb,ss as Ib,Br as Jb,Gn as Kb,oy as Lb,cy as Mb,py as Nb,ly as Ob,uy as Pb,Ql as Qb,WD as Rb,jD as Sb,XD as Tb,hy as Ub,gy as Vb,Ey as Wb,Ay as Xb,dy as Yb,Zl as Zb,xA as _b,Xl as $b,JD as ac,zD as bc,fy as cc,TA as dc,xy as ec,dt as fc,ns as gc,QD as hc,pe as ic,Ty as jc,be as kc,Os as lc,ZD as mc,KD as nc,SA as oc,RA as pc,Sy as qc,vA as rc,Yn as sc,eq as tc,Kl as uc,Ry as vc,Oy as wc,In as xc,Pn as yc,tq as zc,yn as Ac,oe as Bc,eu as Cc,sq as Dc,my as Ec,Gr as Fc,tu as Gc,rq as Hc,Xr as Ic,iq as Jc,Ny as Kc,Iy as Lc,yy as Mc,Cy as Nc,by as Oc,su as Pc,nq as Qc,Py as Rc,aq as Sc,ru as Tc,iu as Uc,rt as Vc,ds as Wc,Ps as Xc,gn as Yc,v as Zc,Ly as _c,wy as $c,My as ad,ky as bd,nu as cd,Dy as dd,qy as ed,FA as fd,Uy as gd,vy as hd,Fy as id,By as jd,oq as kd,cq as ld,hr as md,$y as nd,Gy as od,Yr as pd,Yy as qd,OA as rd,Vy as sd,ps as td,kt as ud,Hy as vd,xe as wd,_y as xd,Wy as yd,HI as zd,Cn as Ad,Ie as Bd,jy as Cd,Xy as Dd,hs as Ed,w as Fd,Jy as Gd,zy as Hd,Vn as Id,pq as Jd,lq as Kd,uq as Ld,au as Md,hq as Nd,gq as Od,Eq as Pd,Xs as Qd,Qy as Rd,ou as Sd,Zy as Td,Ze as Ud,Nj as Vd,Aq as Wd,cu as Xd,Ky as Yd,eC as Zd,jA as _d,bb as $d,_ as ae,Ve as be,tC as ce,Rt as de,BA as ee,sC as fe,dq as ge,Ln as he,rC as ie,pu as je,iC as ke,St as le,Ne as me,Jr as ne,m as oe,fq as pe,$r as qe,nC as re,aC as se,oC as te,lu as ue,mA as ve,NA as we,cC as xe,pC as ye,lC as ze,uC as Ae,hC as Be,uu as Ce,gC as De,hu as Ee,gu as Fe,EC as Ge,AC as He,xq as Ie,dC as Je,Tq as Ke,Re as Le,wn as Me,Hn as Ne,fC as Oe,gs as Pe,Sq as Qe,Rq as Re,et as Se,Oq as Te,te as Ue,IA as Ve,yA as We,gr as Xe,mq as Ye,Pb as Ze,xC as _e,TC as $e,Er as af,qt as bf,SC as cf,RC as df,OC as ef,mC as ff,NC as gf,IC as hf,Nq as if,CA as jf,On as kf,Eu as lf,Iq as mf,zL as nf,yC as of,yq as pf,CC as qf,_n as rf,Au as sf,bC as tf,Gl as uf,Lb as vf,Cq as wf,$A as xf,bq as yf,PC as zf,du as Af,BM as Bf,Pq as Cf,Ft as Df,LC as Ef,fu as Ff,wC as Gf,Mn as Hf,MC as If,$ as Jf,_I as Kf,kC as Lf,wb as Mf,DC as Nf,kn as Of,xu as Pf,qC as Qf,Mb as Rf,Tu as Sf,Su as Tf,Ru as Uf,bA as Vf,Ou as Wf,mu as Xf,Nu as Yf,Iu as Zf,yu as _f,Jl as $f,UC as ag,Lq as bg,Cu as cg,bu as dg,Pu as eg,wq as fg,PA as gg,Lu as hg,vC as ig,wu as jg,Mu as kg,ku as lg,Du as mg,kb as ng,Dn as og,FC as pg,BC as qg,es as rg,N as sg,rr as tg,$C as ug,zl as vg,Wn as wg,jn as xg,Xn as yg,Jn as zg,Mq as Ag,qu as Bg,zr as Cg,Uu as Dg,zn as Eg,Qn as Fg,vu as Gg,Fu as Hg,Zn as Ig,Kn as Jg,ea as Kg,ta as Lg,Bu as Mg,sa as Ng,kq as Og,ra as Pg,ia as Qg,na as Rg,aa as Sg,nr as Tg,oa as Ug,$u as Vg,ir as Wg,pd as Xg,Gu as Yg,ca as Zg,pa as _g,la as $g,ua as ah,ha as bh,Yu as ch,Vu as dh,Qr as eh,ga as fh,Ea as gh,Hu as hh,GC as ih,_u as jh,Aa as kh,Dq as lh,da as mh,Wu as nh,Zr as oh,ld as ph,ju as qh,fa as rh,xa as sh,qn as th,Ta as uh,Vr as vh,Hr as wh,ys as xh,Xu as yh,Ju as zh,qq as Ah,Db as Bh,Uq as Ch,qb as Dh,vq as Eh,zu as Fh,Sa as Gh,Ra as Hh,Kr as Ih,Oa as Jh,ma as Kh,Qu as Lh,Zu as Mh,Na as Nh,Ia as Oh,Ku as Ph,_r as Qh,ya as Rh,XA as Sh,Ca as Th,ba as Uh,vs as Vh,Pa as Wh,Fs as Xh,eh as Yh,$s as Zh,La as _h,JA as $h,zA as ai,QA as bi,ZA as ci,KA as di,ed as ei,td as fi,sd as gi,rd as hi,id as ii,nd as ji,wa as ki,Ma as li,ka as mi,ad as ni,Da as oi,qa as pi,th as qi,Ua as ri,va as si,sh as ti,Fa as ui,ud as vi,hd as wi,od as xi,He as yi,Ge as zi,us as Ai,se as Bi,he as Ci,Ue as Di,YC as Ei,VC as Fi,ar as Gi,Pt as Hi,at as Ii,HC as Ji,_C as Ki,U as Li,qs as Mi,WC as Ni,Lt as Oi,Zs as Pi,Wr as Qi,qe as Ri,E as Si,q as Ti,Vs as Ui,Mt as Vi,xr as Wi,zt as Xi,Hs as Yi,Tr as Zi,ci as _i,ts as $i,Sr as aj,Dt as bj,GA as cj,Ct as dj,_l as ej,or as fj,cr as gj,ei as hj,tr as ij,Us as jj,we as kj,Ae as lj,rh as mj,jC as nj,XC as oj,ih as pj,JC as qj,wt as rj,zC as sj,nh as tj,ah as uj,ge as vj,Wt as wj,Me as xj,Ks as yj,Ur as zj,ot as Aj,QC as Bj,Ba as Cj,LA as Dj,je as Ej,Je as Fj,Gs as Gj,Un as Hj,ze as Ij,oh as Jj,Qt as Kj,Fq as Lj,Fe as Mj,nt as Nj,jr as Oj,xs as Pj,ft as Qj,Bq as Rj,ch as Sj,ZC as Tj,ye as Uj,ph as Vj,lh as Wj,Le as Xj,Se as Yj,bt as Zj,Ts as _j,lt as $j,Ub as ak,$q as bk,Wb as ck,jb as dk,Xb as ek,Jb as fk,zb as gk,Qb as hk,Gq as ik,Zb as jk,Yq as kk,Kb as lk,Vq as mk,Hq as nk,_q as ok,Wq as pk,eP as qk,tP as rk,sP as sk,rP as tk,iP as uk,nP as vk,jq as wk,Xq as xk,Jq as yk,zq as zk,Qq as Ak,Zq as Bk,Kq as Ck,eU as Dk,tU as Ek,sU as Fk,rU as Gk,iU as Hk,nU as Ik,aU as Jk,uh as Kk,aP as Lk,oU as Mk,cU as Nk,pU as Ok,lU as Pk,uU as Qk,hU as Rk,oP as Sk,Qe as Tk,gU as Uk,ue as Vk,cP as Wk,EU as Xk,AU as Yk,dU as Zk,KC as _k,eb as $k,QL as al,fU as bl,xU as cl,pP as dl,TU as el,SU as fl,RU as gl,OU as hl,tb as il,mU as jl,vb as kl,vn as ll,NU as ml,As as nl,IU as ol,yU as pl,CU as ql,bU as rl,sb as sl,rb as tl,hh as ul,PU as vl,LU as wl,wU as xl,MU as yl,kU as zl,DU as Al,qU as Bl,UU as Cl,lP as Dl,Fn as El,Va as Fl,uP as Gl,hP as Hl,vU as Il,gP as Jl,EP as Kl,AP as Ll,wA as Ml,FU as Nl,BU as Ol,dP as Pl,$U as Ql,Fb as Rl,Rr as Sl,GU as Tl,YU as Ul,VU as Vl,ut as Wl,z as Xl,fP as Yl,xP as Zl,TP as _l,HU as $l,ib as am,_U as bm,WU as cm,MA as dm,jU as em,ti as fm,tt as gm,gh as hm,Bt as im,SP as jm,Eh as km,Ah as lm,XU as mm,JU as nm,zU as om,QU as pm,ZU as qm,KU as rm,ev as sm,tv as tm,sv as um,rv as vm,RP as wm,iv as xm,nv as ym,pr as zm,OP as Am,si as Bm,dh as Cm,nb as Dm,av as Em,ri as Fm,mP as Gm,ov as Hm,cv as Im,NP as Jm,fh as Km,Mh as Lm,pv as Mm,ab as Nm,lv as Om,uv as Pm,kh as Qm,Bb as Rm,$b as Sm,Gb as Tm,xt as Um,hv as Vm,jt as Wm,_s as Xm,ls as Ym,IP as Zm,Ds as _m,Qs as $m,yP as an,gv as bn,Ev as cn,CP as dn,bP as en,PP as fn,LP as gn,wP as hn,Av as in,MP as jn,kP as kn,DP as ln,dv as mn,qP as nn,_a as on,fv as pn,xv as qn,Tv as rn,Sv as sn,Rv as tn,lr as un,Ys as vn,Ov as wn,Lh as xn,Fh as yn,UP as zn,Dh as An,Sn as Bn,mv as Cn,Bh as Dn,vP as En,FP as Fn,Nv as Gn,BP as Hn,Iv as In,$P as Jn,GP as Kn,YP as Ln,pi as Mn,Nr as Nn,ob as On,cb as Pn,yv as Qn,Cv as Rn,VP as Sn,bv as Tn,Pv as Un,Lv as Vn,wv as Wn,HP as Xn,Mv as Yn,Xt as Zn,Ib as _n,Ee as $n,xh as ao,_P as bo,WP as co,jP as do,XP as eo,kv as fo,Dv as go,qv as ho,Uv as io,vv as jo,Fv as ko,Bv as lo,$v as mo,Gv as no,pb as oo,ii as po,JP as qo,Yv as ro,zP as so,ni as to,$a as uo,Vv as vo,Hv as wo,QP as xo,_v as yo,Wv as zo,jv as Ao,Xv as Bo,Jv as Co,fe as Do,qh as Eo,Th as Fo,zv as Go,ZP as Ho,Uh as Io,KP as Jo,Qv as Ko,Zv as Lo,Kv as Mo,lb as No,eF as Oo,Sh as Po,tF as Qo,sF as Ro,rF as So,iF as To,nF as Uo,aF as Vo,ub as Wo,oF as Xo,cF as Yo,pF as Zo,hb as _o,gb as $o,Rh as ap,Oh as bp,lF as cp,mh as dp,ms as ep,uF as fp,bn as gp,Nh as hp,Eb as ip,hF as jp,gF as kp,EF as lp,AF as mp,dF as np,fF as op,ai as pp,xF as qp,TF as rp,SF as sp,RF as tp,Ih as up,OF as vp,mF as wp,NF as xp,$h as yp,IF as zp,eL as Ap,tL as Bp,yh as Cp,ur as Dp,Ar as Ep,mn as Fp,vh as Gp,yF as Hp,CF as Ip,bF as Jp,PF as Kp,LF as Lp,wF as Mp,MF as Np,kF as Op,Ab as Pp,Ss as Qp,db as Rp,sL as Sp,DF as Tp,qF as Up,UF as Vp,rL as Wp,iL as Xp,vF as Yp,FF as Zp,fb as _p,BF as $p,Yb as aq,$F as bq,GF as cq,xb as dq,YF as eq,VF as fq,HF as gq,_F as hq,WF as iq,jF as jq,nL as kq,Gh as lq,XF as mq,aL as nq,vr as oq,XI as pq,JF as qq,zF as rq,QF as sq,ZF as tq,KF as uq,eB as vq,ZL as wq,tB as xq,sB as yq,Ga as zq,Tb as Aq,rB as Bq,iB as Cq,nB as Dq,aB as Eq,oB as Fq,KL as Gq,oL as Hq,cL as Iq,ew as Jq,yb as Kq,cB as Lq,pB as Mq,lB as Nq,uB as Oq,hB as Pq,pL as Qq,gB as Rq,EB as Sq,AB as Tq,dB as Uq,lL as Vq,uL as Wq,fB as Xq,xB as Yq,hL as Zq,gL as _q,TB as $q,SB as ar,RB as br,OB as cr,mB as dr,Ns as er,NB as fr,IB as gr,Vl as hr,EL as ir,Bs as jr,yB as kr,CB as lr,oi as mr,Is as nr,bB as or,PB as pr,LB as qr,wB as rr,AL as sr,Es as tr,MB as ur,kB as vr,Ch as wr,dL as xr,Or as yr,fL as zr,DB as Ar,xL as Br,Yh as Cr,qB as Dr,Ya as Er,Vh as Fr,UB as Gr,TL as Hr,os as Ir,Vb as Jr,Hb as Kr,_b as Lr,SL as Mr,vB as Nr,RL as Or,FB as Pr,OL as Qr,mL as Rr,NL as Sr,IL as Tr,yL as Ur,CL as Vr,bL as Wr,kA as Xr,Ij as Yr,vM as Zr,PL as _r,LL as $r,dr as as,BB as bs,$B as cs,Ed as ds,GB as es,Sb as fs,YB as gs,Rb as hs,wL as is,VB as js,Ob as ks,cs as ls,Tt as ms,HB as ns,_B as os,WB as ps,jB as qs,XB as rs,JB as ss,$M as ts,DA as us,qA as vs,zB as ws,QB as xs,ZB as ys,KB as zs,e$ as As,t$ as Bs,s$ as Cs,r$ as Ds,i$ as Es,n$ as Fs,a$ as Gs,GM as Hs,o$ as Is,c$ as Js,ML as Ks,p$ as Ls,Bn as Ms,l$ as Ns,u$ as Os,h$ as Ps,kL as Qs,g$ as Rs,DL as Ss,qL as Ts,E$ as Us,A$ as Vs,d$ as Ws,f$ as Xs,x$ as Ys,UL as Zs,T$ as _s,S$ as $s,$t as at,mb as bt,_t as ct,bh as dt,vL as et,R$ as ft,_A as gt,li as ht,sr as it,Ph as jt,Te as kt,pt as lt,hA as mt,Nb as nt,O$ as ot,m$ as pt,FL as qt,BL as rt,$L as st,N$ as tt,I$ as ut,GL as vt,y$ as wt,gd as xt,YM as yt,C$ as zt,Ad as At,b$ as Bt,P$ as Ct,L$ as Dt,w$ as Et,M$ as Ft,k$ as Gt,D$ as Ht,q$ as It,U$ as Jt,v$ as Kt,F$ as Lt,B$ as Mt,$$ as Nt,YL as Ot,VL as Pt,HL as Qt,_L as Rt,G$ as St,WL as Tt,jL as Ut,XL as Vt,JL as Wt,Y$ as Xt,V$ as Yt,H$ as Zt,_$ as _t,W$ as $t,wh as au,$n as bu,yj as cu,F_ as du,ve as eu,Vt as fu,ED as gu,ks as hu,zs as iu,tw as ju,K as ku,ty as lu,ID as mu,yD as nu,Cj as ou,Be as pu,DD as qu,Ye as ru,bj as su,qD as tu,X as uu,Pj as vu,HA as wu,WA as xu,B_ as yu,$_ as zu,Lj as Au,wj as Bu,Mj as Cu,kj as Du,G_ as Eu,W as Fu,UI as Gu,j$ as Hu,Dj as Iu,$e as Ju,VA as Ku,mr as Lu,Hl as Mu,le as Nu,We as Ou,it as Pu,ht as Qu,Z as Ru,UA as Su,qj as Tu,Uj as Uu,vj as Vu,wM as Wu,Fj as Xu,SM as Yu,Bj as Zu,aM as _u,$j as $u,Gj as av,Yj as bv,Ls as cv,MM as dv,AD as ev,dD as fv,Vj as gv,Rn as hv,YA as iv,TJ as jv,IJ as kv,DJ as lv,qJ as mv,UJ as nv,vJ as ov,FJ as pv,BJ as qv,$J as rv,GJ as sv,YJ as tv,VJ as uv,HJ as vv,_J as wv,WJ as xv,jJ as yv,XJ as zv,JJ as Av,zJ as Bv,QJ as Cv,ZJ as Dv,KJ as Ev,ez as Fv,tz as Gv,sz as Hv,Cb as Iv,cd as Jv,dz as Kv,UM as Lv,ae as Mv,vz as Nv,Fz as Ov,UD as Pv,Bz as Qv,$z as Rv,Gz as Sv,Sj as Tv,Yz as Uv,Vz as Vv,Hz as Wv,_z as Xv,Wz as Yv,jz as Zv,Xz as _v,Jz as $v,zz as aw,Qz as bw,Zz as cw,Kz as dw,e1 as ew,t1 as fw,s1 as gw,r1 as hw,i1 as iw,Rj as jw,n1 as kw,OD as lw,a1 as mw,o1 as nw,c1 as ow,p1 as pw,l1 as qw,u1 as rw,h1 as sw,g1 as tw,E1 as uw,A1 as vw,d1 as ww,f1 as xw,x1 as yw,T1 as zw,S1 as Aw,R1 as Bw,O1 as Cw,ZH as Dw,m1 as Ew,N1 as Fw,I1 as Gw,y1 as Hw,C1 as Iw,b1 as Jw,P1 as Kw,L1 as Lw,w1 as Mw,M1 as Nw,k1 as Ow,D1 as Pw,q1 as Qw,Oj as Rw,U1 as Sw,v1 as Tw,DM as Uw,vD as Vw,KH as Ww,F1 as Xw,B1 as Yw,$1 as Zw,G1 as _w,Y1 as $w,V1 as ax,H1 as bx,_1 as cx,W1 as dx,j1 as ex,X1 as fx,J1 as gx,z1 as hx,Q1 as ix,Z1 as jx,K1 as kx,eQ as lx,tQ as mx,sQ as nx,rQ as ox,iQ as px,nQ as qx,aQ as rx,oQ as sx,PM as tx,KI as ux,Fr as vx};
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
15
|
+
`,{skipFirst:!0,skipLast:!0})}return r.join(s)}tooWide(e){let t=e.reduce((s,r)=>s+r.length,0);return this.maxTextWidth<t}expressions(e,t={}){let{flat:s=!1,indent:r=!0,skipFirst:i=!1,skipLast:o=!1,sep:c=", ",prefix:p="",dynamic:u=!1,newLine:h=!1,key:g,sqls:x}=t,f=e?e.getArgKey(g||"expressions"):x;if(!f||Array.isArray(f)&&f.length===0)return"";let T=Array.isArray(f)?f:[f];if(s)return T.map(C=>this.sql(C)).filter(C=>C).join(c);let y=T.length,b=[];for(let C=0;C<y;C++){let q=T[C],U=this.sql(q,void 0,{comment:!1});if(!U)continue;let _=q instanceof d?this.maybeComment("",q):"";if(this.pretty)if(this.leadingComma)b.push(`${0<C?c:""}${p}${U}${_}`);else{let ne=C+1<y?_?c.trimEnd():c:"";b.push(`${p}${U}${ne}${_}`)}else b.push(`${p}${U}${_}${C+1<y?c:""}`)}let m;return this.pretty&&(!u||this.tooWide(b))?(h&&(b.unshift(""),b.push("")),m=b.map(C=>C.trimEnd()).join(`
|
|
16
|
+
`)):m=b.join(""),r?this.indent(m,{skipFirst:i,skipLast:o}):m}opExpressions(e,t,s={}){let r=(s.flat??!1)||t.parent instanceof He,i=this.expressions(t,{flat:r});return r?`${e} ${i}`:`${this.seg(e)}${i?this.sep():""}${i}`}nakedProperty(e){let t=He.PROPERTY_TO_NAME[e._constructor.key];return t||this.unsupported(`Unsupported property ${e._constructor.key}`),`${t||""} ${this.sql(e,"this")}`}tagSql(e){let t=e.args.prefix||"",s=e.args.postfix||"";return`${t}${this.sql(e.args.this)}${s}`}tokenSql(e){return this._constructor.TOKEN_MAPPING[e]??e.replace(/([A-Z])/g,"_$1").toUpperCase()}userDefinedFunctionSql(e){let t=this.sql(e,"this"),s=this.noIdentify(this.expressions.bind(this),e);return e.args.wrapped?s=this.wrap(s):s=s?` ${s}`:"",s.trim()!==""?`${t}${s}`:t}joinHintSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});return`${t}(${s})`}kwargSql(e){return this.binary(e,"=>")}whenSql(e){let t=e.args.matched?"MATCHED":"NOT MATCHED",s=this._constructor.MATCHED_BY_SOURCE&&e.args.source?" BY SOURCE":"",r=this.sql(e,"condition"),i=r?` AND ${r}`:"",o=e.args.then,c="";if(o instanceof es){let p=this.sql(o,"this");p=p?`INSERT ${p}`:"INSERT";let u=this.sql(o,"expression");c=u?`${p} VALUES ${u}`:p}else if(o instanceof us)if(o.getArgKey("expressions")instanceof Ne)c=`UPDATE ${this.sql(o,"expressions")}`;else{let p=this.expressions(o);c=p?`UPDATE SET${this.sep()}${p}`:"UPDATE"}else c=this.sql(o);return`WHEN ${t}${s}${i} THEN ${c}`}whensSql(e){return this.expressions(e,{sep:" ",indent:!1})}mergeSql(e){let t=e.args.this,s="";if(Y(t,W)){let h=t.args.hints||[];if(0<h.length&&t.alias&&h[0]instanceof cu){let g=t.args.alias,x=Y(g,d)?g.pop():void 0;s=x?` AS ${this.sql(x)}`:""}}let r=this.sql(t),i=`USING ${this.sql(e,"using")}`,o=this.sql(e,"whens"),c=this.sql(e,"on");if(c=c?`ON ${c}`:"",!c){let h=this.expressions(e,{key:"usingCond"});c=h?`USING (${h})`:""}let p=this.sql(e,"returning");p&&(o=`${o}${p}`);let u=this.sep();return this.prependCtes(e,`MERGE INTO ${r}${s}${u}${i}${u}${c}${u}${o}`)}toCharSql(e){return Cb.call(this,e,"format"),this.sql(X(e.args.this,"text"))}toNumberSql(e){if(!this._constructor.SUPPORTS_TO_NUMBER)return this.unsupported("Unsupported TO_NUMBER function"),this.sql(X(e.args.this,"double"));let t=e.args.format;return t?this.func("TO_NUMBER",[e.args.this,t]):(this.unsupported("Conversion format is required for TO_NUMBER"),this.sql(X(e.args.this,"double")))}dictPropertySql(e){let t=this.sql(e,"this"),s=this.sql(e,"kind"),r=this.expressions(e,{key:"settings",sep:" "}),i=r?`(${this.sep("")}${r}${this.seg(")","")}`:"()";return`${t}(${s}${i})`}dictRangeSql(e){let t=this.sql(e,"this"),s=this.sql(e,"max"),r=this.sql(e,"min");return`${t}(MIN ${r} MAX ${s})`}dictSubPropertySql(e){return`${this.sql(e,"this")} ${this.sql(e,"value")}`}duplicateKeyPropertySql(e){return`DUPLICATE KEY (${this.expressions(e,{flat:!0})})`}distributedByPropertySql(e){let t=this.expressions(e,{flat:!0});t=t?` ${this.wrap(t)}`:"";let s=this.sql(e,"buckets"),r=this.sql(e,"kind"),i=s?` BUCKETS ${s}`:"",o=this.sql(e,"order");return`DISTRIBUTED BY ${r}${t}${i}${o}`}onClusterSql(e){return""}clusteredByPropertySql(e){let t=this.expressions(e,{key:"expressions",flat:!0}),s=this.expressions(e,{key:"sortedBy",flat:!0});s=s?` SORTED BY (${s})`:"";let r=this.sql(e,"buckets");return`CLUSTERED BY (${t})${s} INTO ${r} BUCKETS`}anyValueSql(e){let t=this.sql(e,"this"),s=this.sql(e,"having");if(s){let r=e.args.max;return this.func("ANY_VALUE",[`${t} HAVING ${r?"MAX":"MIN"} ${s}`])}return this.func("ANY_VALUE",[e.args.this])}queryTransformSql(e){let t=this.func("TRANSFORM",e.args.expressions||[]),s=this.sql(e,"rowFormatBefore");s=s?` ${s}`:"";let r=this.sql(e,"recordWriter");r=r?` RECORDWRITER ${r}`:"";let i=` USING ${this.sql(e,"commandScript")}`,o=this.sql(e,"schema");o=o?` AS ${o}`:"";let c=this.sql(e,"rowFormatAfter");c=c?` ${c}`:"";let p=this.sql(e,"recordReader");return p=p?` RECORDREADER ${p}`:"",`${t}${s}${r}${i}${o}${c}${p}`}indexConstraintOptionSql(e){let t=this.sql(e,"keyBlockSize");if(t)return`KEY_BLOCK_SIZE = ${t}`;let s=this.sql(e,"using");if(s)return`USING ${s}`;let r=this.sql(e,"parser");if(r)return`WITH PARSER ${r}`;let i=this.sql(e,"comment");if(i)return`COMMENT ${i}`;let o=e.args.visible;if(o!==void 0)return o?"VISIBLE":"INVISIBLE";let c=this.sql(e,"engineAttr");if(c)return`ENGINE_ATTRIBUTE = ${c}`;let p=this.sql(e,"secondaryEngineAttr");return p?`SECONDARY_ENGINE_ATTRIBUTE = ${p}`:(this.unsupported("Unsupported index constraint option."),"")}checkColumnConstraintSql(e){let t=e.args.enforced?" ENFORCED":"";return`CHECK (${this.sql(e,"this")})${t}`}indexColumnConstraintSql(e){let t=this.sql(e,"kind"),s=t?`${t} INDEX`:"INDEX",r=this.sql(e,"this");r=r?` ${r}`:"";let i=this.sql(e,"indexType");i=i?` USING ${i}`:"";let o=this.expressions(e,{flat:!0});o=o?` (${o})`:"";let c=this.expressions(e,{key:"options",flat:!0,sep:" "});return c=c?` ${c}`:"",`${s}${r}${i}${o}${c}`}nvl2Sql(e){if(this._constructor.NVL2_SUPPORTED)return this.functionFallbackSql(e);let t=e.args.this;if(!t)return"";let s=new ut({}).when(t.is(le()).not({copy:!1}),e.args.true??"",{copy:!1}),r=e.args.false;return r&&s.else(r,{copy:!1}),this.sql(s)}comprehensionSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=this.sql(e,"position"),i=r?`, ${r}`:"",o=this.sql(e,"iterator"),c=this.sql(e,"condition"),p=c?` IF ${c}`:"";return`${t} FOR ${s}${i} IN ${o}${p}`}columnPrefixSql(e){return`${this.sql(e,"this")}(${this.sql(e,"expression")})`}opclassSql(e){return`${this.sql(e,"this")} ${this.sql(e,"expression")}`}mlSql(e,t){let s=`MODEL ${this.sql(e,"this")}`,r=e.args.expression,i;if(r){let c=this.sql(e,"expression");i=r instanceof he?c:`TABLE ${c}`}let o=this.sql(e,"paramsStruct")||void 0;return this.func(t,[s,i,o])}predictSql(e){return this.mlSql(e,"PREDICT")}generateEmbeddingSql(e){let t=e.args.isText?"GENERATE_TEXT_EMBEDDING":"GENERATE_EMBEDDING";return this.mlSql(e,t)}mlTranslateSql(e){return this.mlSql(e,"TRANSLATE")}mlForecastSql(e){return this.mlSql(e,"FORECAST")}featuresAtTimeSql(e){let t=e.args.this,s=this.sql(e,"this");return t instanceof W&&(s=`TABLE ${s}`),this.func("FEATURES_AT_TIME",[s,e.args.time,e.args.numRows,e.args.ignoreFeatureNulls])}vectorSearchSql(e){let t=this.sql(e,"this");e.args.this instanceof W&&(t=`TABLE ${t}`);let s=e.args.queryTable,r=s?this.sql(s):void 0;return s instanceof W&&(r=`TABLE ${r}`),this.func("VECTOR_SEARCH",[t,e.args.columnToSearch,r,e.args.queryColumnToSearch,e.args.topK,e.args.distanceType,e.args.options])}forInSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return`FOR ${t} DO ${s}`}refreshSql(e){let t=this.sql(e,"this");return`REFRESH ${e.args.this instanceof I?"":`${e.args.kind||""} `}${t}`}toArraySql(e){let t=e.args.this;if(!t)return"";if(t.type||(t=Kt(t,{dialect:this.dialect})),t.isType("array"))return this.sql(t);let s=t.is(le());return this.sql(_A("IF",s,le(),vA(t,{copy:!1})))}tsOrDsToTimeSql(e){let t=e.args.this;if(!t)return"";let s=this.formatTime(e);return s?this.sql(X(new ys({this:t,format:e.args.format||s}),"time")):e.args.this instanceof Hb||t.isType("time")?this.sql(t):this.sql(X(t,"time"))}tsOrDsToTimestampSql(e){let t=e.args.this;return t?t instanceof _b||t.isType("timestamp")?this.sql(t):this.sql(X(t,"timestamp",{dialect:this.dialect})):""}tsOrDsToDatetimeSql(e){let t=e.args.this;return t?e.args.this instanceof Vb||t.isType("datetime")?this.sql(t):this.sql(X(t,"datetime",{dialect:this.dialect})):""}tsOrDsToDateSql(e){let t=e.args.this;if(!t)return"";let s=this.formatTime(e),r=e.args.safe;return s&&![this.dialect._constructor.TIME_FORMAT,this.dialect._constructor.DATE_FORMAT].includes(s)?this.sql(X(new ys({this:t,format:s,safe:r}),"date")):e.args.this instanceof os||t.isType("date")?this.sql(t):r?this.sql(new Gt({this:t,to:new N({this:"date"})})):this.sql(X(t,"date"))}unixDateSql(e){let t=e.args.this;return this.sql(new _s({this:t instanceof d?t:void 0,expression:X(I.string("1970-01-01"),"date"),unit:Q("day")}))}lastDaySql(e){if(this._constructor.LAST_DAY_SUPPORTS_DATE_PART)return this.functionFallbackSql(e);let t=e.text("unit"),s=t?this.sql(t):"";return s&&s!=="MONTH"&&this.unsupported("Date parts are not supported in LAST_DAY."),this.func("LAST_DAY",[e.args.this])}dateAddSql(e){return this.func("DATE_ADD",[e.args.this,e.args.expression,DM(e)])}arrayAnySql(e){if(this._constructor.CAN_IMPLEMENT_ARRAY_ANY){let t=new Va({this:e.args.this,expression:e.args.expression}),s=new Rr({this:t}).neq(0),r=new Rr({this:e.args.this}).eq(0);return this.sql(zs(r.or(s)))}return this.dialect._constructor!==ae&&this.unsupported("ARRAY_ANY is unsupported"),this.functionFallbackSql(e)}structSql(e){return e.setArgKey("expressions",(e.args.expressions??[]).map(t=>{if(t instanceof ot){let s=t.args.this,r=GY(s,o=>o instanceof F?o:o.name),i=t.args.expression;return Be(i instanceof d||typeof i=="string"?i:"",r)}return t})),this.functionFallbackSql(e)}partitionRangeSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return`${t} TO ${s}`}truncateTableSql(e){let t=e.args.isDatabase?"DATABASE":"TABLE",s=` ${this.expressions(e)}`,r=e.args.exists?" IF EXISTS":"",i=this.sql(e,"cluster");i=i?` ${i}`:"";let o=this.sql(e,"identity");o=o?` ${o} IDENTITY`:"";let c=this.sql(e,"option");c=c?` ${c}`:"";let p=this.sql(e,"partition");return p=p?` ${p}`:"",`TRUNCATE ${t}${r}${s}${i}${o}${c}${p}`}convertSql(e){let t=e.args.this,s=e.args.expression,r=e.args.style,i=e.args.safe,o=e.getArgKey("strict");if(!t||!s)return"";re(t,N);let c=t;!k(t.args.expressions??[],0)&&this._constructor.PARAMETERIZABLE_TEXT_TYPES.has(t.args.this)&&(c=N.build(t.args.this,{expressions:[I.number(30)],nested:!1})??c);let p,u=o?z:Gt;if(r instanceof I&&r.isInteger){let h=r.name,x=ae.get("tsql")?.CONVERT_FORMAT_MAPPING?.[h]??"";x||this.unsupported(`Unsupported T-SQL 'style' value: ${h}`);let f=I.string(x);c.args.this==="date"?p=new oi({this:s,format:f}):c.args.this==="datetime"||c.args.this==="datetime2"?p=new ys({this:s,format:f}):this._constructor.PARAMETERIZABLE_TEXT_TYPES.has(c.args.this)?p=new u({this:new Or({this:s,format:f}),to:c,safe:i}):c.args.this==="text"&&(p=new Or({this:s,format:f}))}return p||(p=new u({this:s,to:c,safe:i})),this.sql(p)}jsonPathKeySql(e){let t=e.args.this;if(t instanceof qt){let r=this.jsonPathPart(t);return r?`.${r}`:""}if(typeof t=="string"&&this._constructor.SAFE_JSON_PATH_KEY_RE.test(t))return`.${t}`;let s=this.jsonPathPart(typeof t=="string"?t:t instanceof d?t.name??"":"");return this.quoteJsonPathKeyUsingBrackets&&this._constructor.JSON_PATH_BRACKETED_KEY_SUPPORTED?`[${s}]`:`.${s}`}jsonPathSubscriptSql(e){let t=e.args.this,s=this.jsonPathPart(t);return s?`[${s}]`:""}simplifyUnlessLiteral(e){return e instanceof I||(e=IM(e,{dialect:this.dialect})),e}embedIgnoreNulls(e,t){let s=e.args.this;if(this._constructor.RESPECT_IGNORE_NULLS_UNSUPPORTED_EXPRESSIONS.some(r=>s instanceof r))return this.unsupported(`RESPECT/IGNORE NULLS is not supported for ${s?._constructor.key} in ${this.dialect.constructor.name}`),this.sql(s);if(this._constructor.IGNORE_NULLS_IN_FUNC&&!e.meta?.inline){if(this._constructor.IGNORE_NULLS_BEFORE_ORDER){let i=[...e.findAll([gr,ye,Dt])].sort((o,c)=>{let p=n(u=>u instanceof gr?0:u instanceof ye?1:2,"getPriority");return p(o)-p(c)});if(0<i.length){let o=i[0],c=new e._constructor({this:o.args.this?.copy()});return c.meta={...c.meta,inline:!0},o.args.this?.replace(c),this.sql(e.args.this)}}let r=e.find(D);if(r){let i=this.sql(r,void 0,{comment:!1}).slice(0,-1)+` ${t})`;return this.maybeComment(i,void 0,r.comments)}}return`${this.sql(e,"this")} ${t}`}replaceLineBreaks(e){return this.pretty?e.replace(/\n/g,this._constructor.SENTINEL_LINE_BREAK):e}copyParameterSql(e){let t=this.sql(e,"this");if(e.args.expressions&&0<e.args.expressions.length){let i=t.toUpperCase(),o=i==="FILE_FORMAT"?" ":", ",c=i==="COPY_OPTIONS"||i==="FORMAT_OPTIONS"?" ":" = ",p=this.expressions(e,{flat:!0,sep:o});return`${t}${c}(${p})`}let s=this.sql(e,"expression");if(!s)return t;let r=this._constructor.COPY_PARAMS_EQ_REQUIRED?" = ":" ";return`${t}${r}${s}`}credentialsSql(e){let t=e.args.credentials,s="";if(t instanceof I){let x=this.sql(e,"credentials");s=x?`CREDENTIALS ${x}`:""}else{let x=this.expressions(e,{key:"credentials",flat:!0,sep:" "});s=t!=null?`CREDENTIALS = (${x})`:""}let r=this.sql(e,"storage"),i=r?`STORAGE_INTEGRATION = ${r}`:"",o=this.expressions(e,{key:"encryption",flat:!0,sep:" "}),c=o?` ENCRYPTION = (${o})`:"",p=this.sql(e,"iamRole"),u=p?`IAM_ROLE ${p}`:"",h=this.sql(e,"region"),g=h?` REGION ${h}`:"";return`${s}${i}${c}${u}${g}`}copySql(e){let t=this._constructor,s=this.sql(e,"this");s=t.COPY_HAS_INTO_KEYWORD?` INTO ${s}`:` ${s}`;let r=this.sql(e,"credentials");r=r?this.seg(r):"";let i=this.expressions(e,{key:"files",flat:!0}),o=i&&e.args.kind?this.seg("FROM"):i?this.seg("TO"):"",p=this.dialect._constructor.COPY_PARAMS_ARE_CSV||!1?", ":" ",u=this.expressions(e,{key:"params",sep:p,newLine:!0,skipLast:!0,skipFirst:!0,indent:t.COPY_PARAMS_ARE_WRAPPED});return u&&(t.COPY_PARAMS_ARE_WRAPPED?u=` WITH (${u})`:!this.pretty&&(i||r)&&(u=` ${u}`)),`COPY${s}${o} ${i}${r}${u}`}semicolonSql(e){return""}dataDeletionPropertySql(e){let t=e.args.on?"ON":"OFF",s=this.sql(e,"filterColumn"),r=s?`FILTER_COLUMN=${s}`:void 0,i=this.sql(e,"retentionPeriod"),o=i?`RETENTION_PERIOD=${i}`:void 0;return r||o?`DATA_DELETION=${this.func("ON",[r,o])}`:`DATA_DELETION=${t}`}gapFillSql(e){let t=this.sql(e,"this");t=`TABLE ${t}`;let s=Object.entries(e.args).filter(([r])=>r!=="this").map(([r,i])=>i);return this.func("GAP_FILL",[t,...s])}scopeResolution(e,t){return this.func("SCOPE_RESOLUTION",[t||void 0,e])}scopeResolutionSql(e){let t=this.sql(e,"this"),s=e.args.expression,r;if(s instanceof E){let i=this.sql(s,"this"),o=this.formatArgs(s.args.expressions||[]);r=`${i}(${o})`}else r=this.sql(e,"expression");return this.scopeResolution(r,t)}parseJsonSql(e){let t=this._constructor.PARSE_JSON_NAME;return t==null?this.sql(e.args.this):this.func(t,[e.args.this,e.args.expression])}randSql(e){let t=this.sql(e,"lower"),s=this.sql(e,"upper");return t&&s?`(${s} - ${t}) * ${this.func("RAND",[e.args.this])} + ${t}`:this.func("RAND",[e.args.this])}changesSql(e){let s=`INFORMATION => ${this.sql(e,"information")}`,r=this.sql(e,"atBefore"),i=r?`${this.seg("")}${r}`:"",o=this.sql(e,"end"),c=o?`${this.seg("")}${o}`:"";return`CHANGES (${s})${i}${c}`}padSql(e){let t=e.args.isLeft?"L":"R",s=this.sql(e,"fillPattern");return!s&&this._constructor.PAD_FILL_PATTERN_IS_REQUIRED&&(s="' '"),this.func(`${t}PAD`,[e.args.this,e.args.expression,s])}summarizeSql(e){return`SUMMARIZE${e.args.table?" TABLE":""} ${this.sql(e.args.this)}`}explodingGenerateSeriesSql(e){let t=new As({...e.args}),s=e.parent;return(s instanceof Oe||s instanceof pe)&&(s=s.parent),this._constructor.SUPPORTS_EXPLODING_PROJECTIONS&&!(s instanceof W)&&!(s instanceof Ee)?this.sql(new Ee({expressions:[t]})):(s instanceof se&&this.unsupported("GenerateSeries projection unnesting is not supported."),this.sql(t))}convertTimezoneSql(e){if(this._constructor.SUPPORTS_CONVERT_TIMEZONE)return this.functionFallbackSql(e);let t=e.args.sourceTz,s=e.args.targetTz,r=e.args.timestamp;t&&r&&(r=new gs({this:X(r,"timestampntz"),zone:t}));let i=new gs({this:r,zone:s});return this.sql(i)}jsonSql(e){let t=this.sql(e,"this"),s=t?` ${t}`:"",r=e.args.with,i="";r==null?i="":r?i=" WITH":i=" WITHOUT";let o=e.args.unique?" UNIQUE KEYS":"";return`JSON${s}${i}${o}`}jsonValueSql(e){let t=this.sql(e,"path"),s=this.sql(e,"returning");s=s?` RETURNING ${s}`:"";let r=this.sql(e,"onCondition");return r=r?` ${r}`:"",this.func("JSON_VALUE",[e.args.this,`${t}${s}${r}`])}skipJsonColumnSql(e){return`SKIP${e.args.regexp?" REGEXP":""} ${this.sql(e.args.expression)}`}conditionalInsertSql(e){let t=e.args.else?"ELSE ":"",s=this.sql(e,"expression"),r=s?`WHEN ${s} THEN `:t,i=this.sql(e,"this").substring(6).trim();return`${r}${i}`}multitableInsertsSql(e){let t=this.sql(e,"kind"),s=this.seg(this.expressions(e,{sep:" "}));return`INSERT ${t}${s}${this.seg(this.sql(e,"source"))}`}onConditionSql(e){let t=e.args.empty,s="";t instanceof d?s=`DEFAULT ${this.sql(t)} ON EMPTY`:s=this.sql(e,"empty");let r=e.args.error,i="";r instanceof d?i=`DEFAULT ${this.sql(r)} ON ERROR`:i=this.sql(e,"error"),i&&s&&(this._constructor.ON_CONDITION_EMPTY_BEFORE_ERROR?i=`${s} ${i}`:i=`${i} ${s}`,s="");let o=this.sql(e,"null");return`${s}${i}${o}`}jsonExtractSql(e){return this.functionFallbackSql(e)}jsonExtractScalarSql(e){return this.functionFallbackSql(e)}jsonbExtractSql(e){return this.functionFallbackSql(e)}jsonbExtractScalarSql(e){return this.functionFallbackSql(e)}jsonExtractQuoteSql(e){let t=e.args.scalar?" ON SCALAR STRING":"";return`${this.sql(e,"option")} QUOTES${t}`}jsonExistsSql(e){let t=this.sql(e,"this"),s=this.sql(e,"path"),r=this.expressions(e,{key:"passing"}),i=r?` PASSING ${r}`:"",o=this.sql(e,"onCondition");return o=o?` ${o}`:"",s=`${s}${i}${o}`,this.func("JSON_EXISTS",[t,s])}addArrayAggNullFilter(e,t,s){if(!(this.dialect._constructor.ARRAY_AGG_INCLUDES_NULLS&&t.args.nullsExcluded))return e;let r=t.parent;if(r instanceof Xr){let i=r.args.expression?.args.this;if(!i)return e;i.replace(i.and(s.is(le()).not()))}else if(s.find($)){let i=s instanceof et?this.expressions(s):this.sql(s);e=`${e} FILTER(WHERE ${i} IS NOT NULL)`}return e}arrayAggSql(e){let t=this.functionFallbackSql(e),s=e.args.this instanceof d?e.args.this:void 0;return s?this.addArrayAggNullFilter(t,e,s):t}sliceSql(e){let t=this.sql(e,"step"),s=this.sql(typeof e.args.expression=="number"?e.args.expression.toString():e.args.expression),r=this.sql(e.args.this),i=t?`${s}:${t}`:s;return i?`${r}:${i}`:`${r}:`}applySql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return`${t} APPLY(${s})`}grantOrRevokeSql(e,t={}){let{keyword:s,preposition:r,grantOptionPrefix:i="",grantOptionSuffix:o=""}=t,c=this.expressions(e,{key:"privileges",flat:!0}),p=this.sql(e,"kind"),u=p?` ${p}`:"",h=this.sql(e,"securable");h=h?` ${h}`:"";let g=this.expressions(e,{key:"principals",flat:!0}),x=i,f=o;e.args.grantOption||(x=f="");let T=this.sql(e,"cascade"),y=T?` ${T}`:"";return`${s} ${x}${c} ON${u}${h} ${r} ${g}${f}${y}`}grantSql(e){return this.grantOrRevokeSql(e,{keyword:"GRANT",preposition:"TO",grantOptionSuffix:" WITH GRANT OPTION"})}revokeSql(e){return this.grantOrRevokeSql(e,{keyword:"REVOKE",preposition:"FROM",grantOptionPrefix:"GRANT OPTION FOR "})}grantPrivilegeSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0}),r=s?`(${s})`:"";return`${t}${r}`}grantPrincipalSql(e){let t=this.sql(e,"this"),s=this.sql(e,"kind");return`${s?`${s} `:""}${t}`}columnsSql(e){let t=this.functionFallbackSql(e);return e.args.unpack?`*${t}`:t}overlaySql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=this.sql(e,"from"),i=this.sql(e,"for"),o=i?` FOR ${i}`:"";return`OVERLAY(${t} PLACING ${s} FROM ${r}${o})`}toDoubleSql(e){Cb.call(this,e,"format");let t=e.args.safe?Gt:z;return this.sql(new t({this:e.args.this,to:new N({this:"double"})}))}stringSql(e){let t=e.args.this,s=e.args.zone;return s&&(t=new vn({sourceTz:new I({this:"UTC",isString:!0}),targetTz:s,timestamp:t})),this.sql(X(t,"VARCHAR",{dialect:this.dialect}))}medianSql(e){return this._constructor.SUPPORTS_MEDIAN?this.functionFallbackSql(e):this.sql(new Ed({this:e.args.this,expression:I.number(.5)}))}overflowTruncateBehaviorSql(e){let t=this.sql(e,"this"),s=t?` ${t}`:"",r=e.args.withCount?"WITH COUNT":"WITHOUT COUNT";return`TRUNCATE${s} ${r}`}unixSecondsSql(e){if(this._constructor.SUPPORTS_UNIX_SECONDS)return this.functionFallbackSql(e);let t=X(I.string("1970-01-01 00:00:00+00"),"timestamptz");return this.sql(new Dh({this:e.args.this,expression:t,unit:new Ve({this:"SECONDS"})}))}arraySizeSql(e){let t=e.args.expression;return t&&this._constructor.ARRAY_SIZE_DIM_REQUIRED===void 0&&(t.isInteger&&t.name==="1"||this.unsupported("Cannot transpile dimension argument for ARRAY_LENGTH"),t=void 0),this._constructor.ARRAY_SIZE_DIM_REQUIRED&&!t&&(t=new I({this:"1",isString:!1})),this.func(this._constructor.ARRAY_SIZE_NAME,[e.args.this,t])}attachSql(e){let t=this.sql(e,"this"),s=e.args.exists?" IF NOT EXISTS":"",r=this.expressions(e);return r=r?` (${r})`:"",`ATTACH${s} ${t}${r}`}detachSql(e){let t=this.sql(e,"kind");t=t?` ${t}`:"";let s=e.args.exists?" IF EXISTS":"";s&&(t=t||" DATABASE");let r=this.sql(e,"this"),i=r?` ${r}`:"",o=this.sql(e,"cluster");o=o?` ${o}`:"";let c=e.args.permanent?" PERMANENTLY":"",p=e.args.sync?" SYNC":"";return`DETACH${t}${s}${i}${o}${c}${p}`}attachOptionSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression");return s=s?` ${s}`:"",`${t}${s}`}watermarkColumnConstraintSql(e){return`WATERMARK FOR ${this.sql(e,"this")} AS ${this.sql(e,"expression")}`}encodePropertySql(e){let s=`${e.args.key?"KEY ENCODE":"ENCODE"} ${this.sql(e,"this")}`,r=e.args.properties;return r&&(re(r,He),s=`${s} ${this.properties(r)}`),s}includePropertySql(e){let s=`INCLUDE ${this.sql(e,"this")}`,r=this.sql(e,"columnDef");r&&(s=`${s} ${r}`);let i=this.sql(e,"alias");return i&&(s=`${s} AS ${i}`),s}xmlElementSql(e){let s=`${e.args.evalname?"EVALNAME":"NAME"} ${this.sql(e,"this")}`;return this.func("XmlELEMENT",[s,...e.args.expressions||[]])}xmlKeyValueOptionSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=s?`(${s})`:"";return`${t}${r}`}partitionByRangePropertySql(e){let t=this.expressions(e,{key:"partitionExpressions"}),s=this.expressions(e,{key:"createExpressions"});return`PARTITION BY RANGE ${this.wrap(t)} ${this.wrap(s)}`}partitionByRangePropertyDynamicSql(e){let t=this.sql(e,"start"),s=this.sql(e,"end"),r=e.args.every;r instanceof qe&&r.args.this?.isString&&r.args.this.replace(I.number(r.name));let i=this.sql(r);return`START (${t}) END (${s}) EVERY (${i})`}unpivotColumnsSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});return`NAME ${t} VALUE ${s}`}analyzeSampleSql(e){let t=this.sql(e,"kind");return`SAMPLE ${this.sql(e,"sample")} ${t}`}analyzeStatisticsSql(e){let t=this.sql(e,"kind"),s=this.sql(e,"option");s=s?` ${s}`:"";let r=this.sql(e,"this");r=r?` ${r}`:"";let i=this.expressions(e);return i=i?` ${i}`:"",`${t}${s} STATISTICS${r}${i}`}analyzeHistogramSql(e){let t=this.sql(e,"this"),s=this.expressions(e),r=this.sql(e,"expression");r=r?` ${r}`:"";let i=this.sql(e,"updateOptions");return i=i?` ${i} UPDATE`:"",`${t} HISTOGRAM ON ${s}${r}${i}`}analyzeDeleteSql(e){let t=this.sql(e,"kind");return t=t?` ${t}`:"",`DELETE${t} STATISTICS`}analyzeListChainedRowsSql(e){return`LIST CHAINED ROWS${this.sql(e,"expression")}`}analyzeValidateSql(e){let t=this.sql(e,"kind"),s=this.sql(e,"this");s=s?` ${s}`:"";let r=this.sql(e,"expression");return`VALIDATE ${t}${s}${r}`}analyzeSql(e){let t=this.expressions(e,{key:"options",sep:" "});t=t?` ${t}`:"";let s=this.sql(e,"kind");s=s?` ${s}`:"";let r=this.sql(e,"this");r=r?` ${r}`:"";let i=this.sql(e,"mode");i=i?` ${i}`:"";let o=this.sql(e,"properties");o=o?` ${o}`:"";let c=this.sql(e,"partition");c=c?` ${c}`:"";let p=this.sql(e,"expression");return p=p?` ${p}`:"",`ANALYZE${t}${s}${r}${c}${i}${p}${o}`}xmlTableSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{key:"namespaces"}),r=s?`XMLNAMESPACES(${s}), `:"",i=this.expressions(e,{key:"passing"}),o=i?`${this.sep()}PASSING${this.seg(i)}`:"",c=this.expressions(e,{key:"columns"}),p=c?`${this.sep()}COLUMNS${this.seg(c)}`:"",u=e.args.byRef?`${this.sep()}RETURNING SEQUENCE BY REF`:"";return`XMLTABLE(${this.sep("")}${this.indent(r+t+o+u+p)}${this.seg(")","")}`}xmlNamespaceSql(e){let t=this.sql(e,"this");return e.args.this instanceof Oe?t:`DEFAULT ${t}`}exportSql(e){let t=this.sql(e,"this"),s=this.sql(e,"connection"),r=s?`WITH CONNECTION ${s} `:"",i=this.sql(e,"options");return`EXPORT DATA ${r}${i} AS ${t}`}declareSql(e){return`DECLARE ${e.args.replace?"OR REPLACE ":""}${this.expressions(e,{flat:!0})}`}declareItemSql(e){let t=this.expressions(e,{key:"this"}),s=this.sql(e,"default"),r=this._constructor.DECLARE_DEFAULT_ASSIGNMENT,i=s?` ${r} ${s}`:"",o=this.sql(e,"kind");return e.args.kind instanceof Rt&&(o=`TABLE ${o}`),o=o?` ${o}`:"",`${t}${o}${i}`}recursiveWithSearchSql(e){let t=this.sql(e,"kind"),s=this.sql(e,"this"),r=this.sql(e,"expression"),i=this.sql(e,"using"),o=i?` USING ${i}`:"";return`${t==="CYCLE"?t:`SEARCH ${t} FIRST BY`} ${s} SET ${r}${o}`}parameterizedAggSql(e){let t=this.expressions(e,{key:"params",flat:!0}),s=e.name||"";return this.func(s,e.args.expressions||[])+`(${t})`}anonymousAggFuncSql(e){let t=e.name||"";return this.func(t,e.args.expressions||[])}combinedAggFuncSql(e){return this.anonymousAggFuncSql(e)}combinedParameterizedAggSql(e){return this.parameterizedAggSql(e)}showSql(e){return this.unsupported("Unsupported SHOW statement"),""}installSql(e){return this.unsupported("Unsupported INSTALL statement"),""}getPutSql(e){let t=e.args.properties;t&&re(t,He);let s=t?this.properties(t,{prefix:" ",sep:" ",wrapped:!1}):"",r=this.sql(e,"this"),i=this.sql(e,"target");return e instanceof XA?`PUT ${r} ${i}${s}`:`GET ${i} ${r}${s}`}translateCharactersSql(e){let t=this.sql(e,"this"),s=this.sql(e,"expression"),r=e.args.withError?" WITH ERROR":"";return`TRANSLATE(${t} USING ${s}${r})`}decodeCaseSql(e){if(this._constructor.SUPPORTS_DECODE_CASE)return this.func("DECODE",e.args.expressions??[]);let[t,...s]=e.args.expressions??[],r=[];for(let c=0;c<s.length-1;c+=2){let p=s[c],u=s[c+1];if(p instanceof I)r.push(new xe({this:t.eq(p),true:u}));else if(p instanceof Lt)r.push(new xe({this:t.is(le()),true:u}));else{let h=p;h instanceof v&&(h=zs(h));let g=Ht([t.eq(h),ve([t.is(le()),h.is(le())],{copy:!1})],{copy:!1});r.push(new xe({this:g,true:u}))}}let i=s.length%2===1?s[s.length-1]:void 0,o=new ut({ifs:r,default:i});return this.sql(o)}semanticViewSql(e){let t=this.sql(e,"this"),s=this.seg(t,""),r=this.expressions(e,{key:"dimensions",dynamic:!0,skipFirst:!0,skipLast:!0}),i=r?this.seg(`DIMENSIONS ${r}`):"",o=this.expressions(e,{key:"metrics",dynamic:!0,skipFirst:!0,skipLast:!0}),c=o?this.seg(`METRICS ${o}`):"",p=this.expressions(e,{key:"facts",dynamic:!0,skipFirst:!0,skipLast:!0}),u=p?this.seg(`FACTS ${p}`):"",h=this.sql(e,"where"),g=h?this.seg(`WHERE ${h}`):"";return`SEMANTIC_VIEW(${this.indent(s+c+i+u+g,{skipFirst:!0})}${this.seg(")","")}`}getExtractSql(e){let t=e.args.this,s=e.args.expression;return t?((!t.type||!e.type)&&(t=Kt(t,{dialect:this.dialect})),t.isType(["array","map"])?this.sql(new wt({this:t,expressions:s?[s]:[]})):this.sql(new Ns({this:t,expression:this.dialect.toJsonPath(s)}))):""}dateFromUnixDateSql(e){return this.sql(new ft({this:X(I.string("1970-01-01"),"date"),expression:e.args.this,unit:Q("DAY")}))}spaceSql(e){return this.func("REPEAT",[Hl(" "),e.args.this])}buildPropertySql(e){return`BUILD ${this.sql(e,"this")}`}refreshTriggerPropertySql(e){let t=this.sql(e,"method"),s=e.args.kind;if(!s)return`REFRESH ${t}`;let r=this.sql(e,"every"),i=this.sql(e,"unit"),o=r?` EVERY ${r} ${i}`:"",c=this.sql(e,"starts");return c=c?` STARTS ${c}`:"",`REFRESH ${t} ON ${s}${o}${c}`}modelAttributeSql(e){return this.unsupported("The model!attribute syntax is not supported"),""}directoryStageSql(e){return this.func("DIRECTORY",[e.args.this])}uuidSql(e){let t=this.func("UUID",[]);return e.args.isString&&!this.dialect._constructor.UUID_IS_STRING_TYPE?this.sql(X(Q(t),"varchar")):t}initcapSql(e){let t=e.args.expression;return t&&(this.dialect._constructor.INITCAP_SUPPORTS_CUSTOM_DELIMITERS?t.isString&&t.args.this===this.dialect._constructor.INITCAP_DEFAULT_DELIMITER_CHARS&&(t=void 0):t=void 0),this.func("INITCAP",[e.args.this,t])}localtimeSql(e){let t=e.args.this;return t?this.func("LOCALTIME",[t]):"LOCALTIME"}localtimestampSql(e){let t=e.args.this;return t?this.func("LOCALTIMESTAMP",[t]):"LOCALTIMESTAMP"}weekStartSql(e){let t=e.args.this,s=t?.name.toUpperCase();return this.dialect._constructor.WEEK_OFFSET===-1&&s==="SUNDAY"?"WEEK":this.func("WEEK",[t])}chrSql(e,t={}){let{name:s="CHR"}=t,r=this.expressions(e),i=this.sql(e,"charset"),o=i?` USING ${i}`:"";return this.func(s,[r+o])}blockSql(e){let t=this.expressions(e,{sep:"; ",flat:!0});return t?`${t}`:""}tableSampleSql(e,t={}){let{tablesampleKeyword:s}=t,r=this.sql(e,"method");r=r&&this._constructor.TABLESAMPLE_WITH_METHOD?`${r} `:"";let i=this.sql(e,"bucketNumerator"),o=this.sql(e,"bucketDenominator"),c=this.sql(e,"bucketField");c=c?` ON ${c}`:"";let p=i?`BUCKET ${i} OUT OF ${o}${c}`:"",u=this.sql(e,"seed");u=u?` ${this._constructor.TABLESAMPLE_SEED_KEYWORD} (${u})`:"";let h=this.sql(e,"size");h&&this._constructor.TABLESAMPLE_SIZE_IS_ROWS&&(h=`${h} ROWS`);let g=this.sql(e,"percent");g&&!this.dialect._constructor.TABLESAMPLE_SIZE_IS_PERCENT&&(g=`${g} PERCENT`);let x=`${p}${g}${h}`;return this._constructor.TABLESAMPLE_REQUIRES_PARENS&&(x=`(${x})`),` ${s||this._constructor.TABLESAMPLE_KEYWORDS} ${r}${x}${u}`}maskingPolicyColumnConstraintSql(e){let t=this.sql(e,"this"),s=this.expressions(e,{flat:!0});return s=s?` USING (${s})`:"",`MASKING POLICY ${t}${s}`}uniqueKeyPropertySql(e,t={}){let{prefix:s="UNIQUE KEY"}=t;return`${s} (${this.expressions(e,{flat:!0})})`}formatTime(e,t,s){let r=this.dialect._constructor,i=t||r.INVERSE_TIME_MAPPING,o=s||r.INVERSE_TIME_TRIE;return Wl(this.sql(e,"format"),i,o)}ceilSql(e){return this.ceilFloor(e)}floorSql(e){return this.ceilFloor(e)}generateSeriesSql(e){if(e.args.isEndExclusive){let t=e.args.start,s=e.args.end,r=e.args.step,i=s instanceof d?new Ce({this:s,expression:I.number(1)}):s;return this.func(e._constructor.sqlName(),[t,i,r])}return this.functionFallbackSql(e)}offsetLimitModifiers(e,t,s){let{fetch:r}=t;return[r?this.sql(e,"offset"):this.sql(s),r?this.sql(s):this.sql(e,"offset")]}storedProcedureSql(e){return this.unsupported("Unsupported Stored Procedure syntax"),""}ifBlockSql(e){return this.unsupported("Unsupported If block syntax"),""}whileBlockSql(e){return this.unsupported("Unsupported While block syntax"),""}executeSql(e){return this.unsupported("Unsupported Execute syntax"),""}executeSqlSql(e){return this.unsupported("Unsupported Execute syntax"),""}alterModifySqlSecuritySql(e){return`MODIFY ${this.expressions(e,{sep:" "})}`}};rs=Ft(null),R(rs,10,"NULL_ORDERING_SUPPORTED",QH,L),R(rs,10,"SUPPORTED_JSON_PATH_PARTS",zH,L),R(rs,10,"UNWRAPPED_INTERVAL_VALUES",JH,L),R(rs,10,"WITH_SEPARATED_COMMENTS",XH,L),R(rs,10,"EXCLUDE_COMMENTS",jH,L),R(rs,10,"TYPE_MAPPING",WH,L),R(rs,10,"UNSUPPORTED_TYPES",_H,L),R(rs,10,"PARAMETERIZABLE_TEXT_TYPES",HH,L),R(rs,10,"TOKEN_MAPPING",VH,L),R(rs,10,"ORIGINAL_TRANSFORMS",YH,L),R(rs,10,"TRANSFORMS",GH,L),R(rs,10,"PROPERTIES_LOCATION",$H,L),It(rs,L),yt(rs,3,L),n(L,"Generator"),L.WINDOW_FUNCS_WITH_NULL_ORDERING=[],L.IGNORE_NULLS_IN_FUNC=!1,L.IGNORE_NULLS_BEFORE_ORDER=!0,L.RESPECT_IGNORE_NULLS_UNSUPPORTED_EXPRESSIONS=[],L.LOCKING_READS_SUPPORTED=!1,L.EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE=!0,L.WRAP_DERIVED_VALUES=!0,L.CREATE_FUNCTION_RETURN_AS=!0,L.MATCHED_BY_SOURCE=!0,L.SINGLE_STRING_INTERVAL=!1,L.INTERVAL_ALLOWS_PLURAL_FORM=!0,L.LIMIT_FETCH="ALL",L.LIMIT_ONLY_LITERALS=!1,L.RENAME_TABLE_WITH_DB=!0,L.GROUPINGS_SEP=",",L.INDEX_ON="ON",L.INOUT_SEPARATOR=" ",L.JOIN_HINTS=!0,L.DIRECTED_JOINS=!1,L.TABLE_HINTS=!0,L.QUERY_HINTS=!0,L.QUERY_HINT_SEP=", ",L.IS_BOOL_ALLOWED=!0,L.DUPLICATE_KEY_UPDATE_WITH_SET=!0,L.LIMIT_IS_TOP=!1,L.RETURNING_END=!0,L.EXTRACT_ALLOWS_QUOTES=!0,L.TZ_TO_WITH_TIME_ZONE=!1,L.NVL2_SUPPORTED=!0,L.SELECT_KINDS=["STRUCT","VALUE"],L.VALUES_AS_TABLE=!0,L.ALTER_TABLE_INCLUDE_COLUMN_KEYWORD=!0,L.UNNEST_WITH_ORDINALITY=!0,L.AGGREGATE_FILTER_SUPPORTED=!0,L.SEMI_ANTI_JOIN_WITH_SIDE=!0,L.COMPUTED_COLUMN_WITH_TYPE=!0,L.SUPPORTS_TABLE_COPY=!0,L.TABLESAMPLE_REQUIRES_PARENS=!0,L.TABLESAMPLE_SIZE_IS_ROWS=!0,L.TABLESAMPLE_SIZE_IS_PERCENT=!1,L.TABLESAMPLE_KEYWORDS="TABLESAMPLE",L.TABLESAMPLE_WITH_METHOD=!0,L.TABLESAMPLE_SEED_KEYWORD="SEED",L.COLLATE_IS_FUNC=!1,L.DATA_TYPE_SPECIFIERS_ALLOWED=!1,L.ENSURE_BOOLS=!1,L.CTE_RECURSIVE_KEYWORD_REQUIRED=!0,L.SUPPORTS_SINGLE_ARG_CONCAT=!0,L.LAST_DAY_SUPPORTS_DATE_PART=!0,L.SUPPORTS_TABLE_ALIAS_COLUMNS=!0,L.UNPIVOT_ALIASES_ARE_IDENTIFIERS=!0,L.JSON_KEY_VALUE_PAIR_SEP=":",L.INSERT_OVERWRITE=" OVERWRITE TABLE",L.SUPPORTS_SELECT_INTO=!1,L.SUPPORTS_UNLOGGED_TABLES=!1,L.SUPPORTS_CREATE_TABLE_LIKE=!0,L.SUPPORTS_MODIFY_COLUMN=!1,L.LIKE_PROPERTY_INSIDE_SCHEMA=!1,L.MULTI_ARG_DISTINCT=!0,L.JSON_TYPE_REQUIRED_FOR_EXTRACTION=!1,L.JSON_PATH_BRACKETED_KEY_SUPPORTED=!0,L.JSON_PATH_SINGLE_QUOTE_ESCAPE=!1,L.CAN_IMPLEMENT_ARRAY_ANY=!1,L.SUPPORTS_TO_NUMBER=!0,L.SUPPORTS_WINDOW_EXCLUDE=!1,L.SET_OP_MODIFIERS=!0,L.COPY_PARAMS_ARE_WRAPPED=!0,L.COPY_PARAMS_EQ_REQUIRED=!1,L.COPY_HAS_INTO_KEYWORD=!0,L.TRY_SUPPORTED=!0,L.SUPPORTS_UESCAPE=!0,L.UNICODE_SUBSTITUTE=void 0,L.STAR_EXCEPT="EXCEPT",L.HEX_FUNC="HEX",L.WITH_PROPERTIES_PREFIX="WITH",L.QUOTE_JSON_PATH=!0,L.PAD_FILL_PATTERN_IS_REQUIRED=!1,L.SUPPORTS_EXPLODING_PROJECTIONS=!0,L.ARRAY_CONCAT_IS_VAR_LEN=!0,L.SUPPORTS_CONVERT_TIMEZONE=!1,L.SUPPORTS_MEDIAN=!0,L.SUPPORTS_UNIX_SECONDS=!1,L.ALTER_SET_WRAPPED=!1,L.NORMALIZE_EXTRACT_DATE_PARTS=!1,L.PARSE_JSON_NAME="PARSE_JSON",L.ARRAY_SIZE_NAME="ARRAY_LENGTH",L.ALTER_SET_TYPE="SET DATA TYPE",L.ARRAY_SIZE_DIM_REQUIRED=void 0,L.SUPPORTS_DECODE_CASE=!0,L.ON_CONDITION_EMPTY_BEFORE_ERROR=!0,L.SUPPORTS_BETWEEN_FLAGS=!1,L.SUPPORTS_LIKE_QUANTIFIERS=!0,L.MATCH_AGAINST_TABLE_PREFIX=void 0,L.SET_ASSIGNMENT_REQUIRES_VARIABLE_KEYWORD=!1,L.UPDATE_STATEMENT_SUPPORTS_FROM=!0,L.STAR_EXCLUDE_REQUIRES_DERIVED_TABLE=!0,L.SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY=!0,L.AFTER_HAVING_MODIFIER_TRANSFORMS=new Map([["cluster",function(e){return this.sql(e,"cluster")}],["distribute",function(e){return this.sql(e,"distribute")}],["sort",function(e){return this.sql(e,"sort")}],["windows",function(e){return e.getArgKey("windows")?this.seg("WINDOW ")+this.expressions(e,{key:"windows",flat:!0}):""}],["qualify",function(e){return this.sql(e,"qualify")}]]),L.SAFE_JSON_PATH_KEY_RE=/^[_a-zA-Z]\w*$/,L.SENTINEL_LINE_BREAK="__SQLGLOT__LB__",L.TIME_PART_SINGULARS={MICROSECONDS:"MICROSECOND",SECONDS:"SECOND",MINUTES:"MINUTE",HOURS:"HOUR",DAYS:"DAY",WEEKS:"WEEK",MONTHS:"MONTH",QUARTERS:"QUARTER",YEARS:"YEAR"},L.STRUCT_DELIMITER=["<",">"],L.PARAMETER_TOKEN="@",L.NAMED_PLACEHOLDER_TOKEN=":",L.RESERVED_KEYWORDS=new Set,L.EXPRESSIONS_WITHOUT_NESTED_CTES=new Set,L.EXPRESSION_PRECEDES_PROPERTIES_CREATABLES=new Set,L.DECLARE_DEFAULT_ASSIGNMENT="=";var pd=L;function xz(a,e){return new pd(e).generate(a)}n(xz,"generate");var e_,t_,qM;t_=[O],e_=[O];var Ha=class Ha{static get TIMESTAMP_EXPRESSIONS(){return new Set([ri,ys,Yh,Fh,UP,NL])}static get EXPRESSION_METADATA(){let e=new Map,t=n((s,r)=>{for(let i of s)e.set(i,r)},"extend");return t([ML,Rr,vL,Uh,yL,CL,bL],{returns:"BIGINT"}),t([_P,WP],{returns:"BINARY"}),t([cs,Tt,lP,Ss,at,SP,EL,Ys,lt,KP,ZP,BL,FL,Ga,Vl],{returns:"BOOLEAN"}),t([pr,pi,BP,$P,VP,_a,oi,fL,os],{returns:"DATE"}),t([OP,IP,Ds,Qs],{returns:"DATETIME"}),t([Xb,Jb,Wb,jb,wh,zb,Qb,DL,Ah,Kb,nP,Zb,iP,HP,XL,yh,ur,nL,Gh,dd,oL,cL,vr,pL,eP,tP,Ch,VL,HL,_L,sP,rP,pP,WL,jL,JL],{returns:"DOUBLE"}),t([cP,eL,ti,yP,PP,CP,LP,zP,QP,Dh,FP,RL,YP,tL,$h,hL,Bs,SL,aL,OL],{returns:"INT"}),t([qe,xP,fP,TP,qP],{returns:"INTERVAL"}),e.set(ai,{returns:"Json"}),t([si,dh,dL,Bh,vP],{returns:"TIME"}),e.set(PL,{returns:"TIMESTAMPLTZ"}),t([mP,LL],{returns:"TIMESTAMPTZ"}),Ha.TIMESTAMP_EXPRESSIONS.forEach(s=>e.set(s,{returns:"TIMESTAMP"})),t([Nr,bP,rL,Ad,MP,wL,kP,DP],{returns:"TINYINT"}),t([AP,$t,Wt,gh,Mh,NP,RP,xh,wP,GP,jt,sr,Th,Ar,sL,iL,lL,uL,Is,dP,Or,xL,Ya,jP,XP,oP,TL,mL,IL,dr,Mn,kh,AL],{returns:"VARCHAR"}),t([aP,qL,kL,gP,EP,Xr,gr,UL,Dt,ye,gL,Ue],{annotator:n((s,r)=>s.annotateByArgs(r,["this"]),"annotator")}),t([hh,tt,ni,Ih,$L,GL],{annotator:n((s,r)=>s.annotateByArgs(r,["this","expressions"]),"annotator")}),t([uP,hP],{annotator:n((s,r)=>s.annotateByArrayElement(r),"annotator")}),t([ft,Xt,ls],{annotator:n((s,r)=>s.annotateTimeunit(r),"annotator")}),t([z,Gt],{annotator:n((s,r)=>s.setType(r,r.args.to),"annotator")}),t([mn,Rs],{annotator:n((s,r)=>s.annotateMap(r),"annotator")}),e.set(Qe,{annotator:n((s,r)=>s.setType(r,s.schema.getUdfType(r)),"annotator")}),e.set(ue,{annotator:n((s,r)=>s.annotateByArgs(r,["expressions"],{array:!0}),"annotator")}),e.set(Bn,{annotator:n((s,r)=>s.annotateByArgs(r,["this"],{array:!0}),"annotator")}),e.set(wt,{annotator:n((s,r)=>s.annotateBracket(r),"annotator")}),e.set(ut,{annotator:n((s,r)=>s.annotateByArgs(r,[...Et(r.args.ifs??[],xe).flatMap(i=>i.args.true??[]),"default"]),"annotator")}),e.set(bh,{annotator:n((s,r)=>s.setType(r,r.args.bigInt?"bigint":"int"),"annotator")}),e.set(_s,{annotator:n((s,r)=>s.setType(r,r.args.bigInt?"bigint":"int"),"annotator")}),e.set(N,{annotator:n((s,r)=>s.setType(r,r.copy()),"annotator")}),e.set(Mt,{annotator:n((s,r)=>s.annotateDiv(r),"annotator")}),e.set(et,{annotator:n((s,r)=>s.annotateByArgs(r,["expressions"]),"annotator")}),e.set(ge,{annotator:n((s,r)=>s.annotateDot(r),"annotator")}),e.set(Jt,{annotator:n((s,r)=>s.annotateExplode(r),"annotator")}),e.set(lr,{annotator:n((s,r)=>s.annotateExtract(r),"annotator")}),e.set(xu,{annotator:n((s,r)=>s.setType(r,r.args.isInteger?"bigint":"binary"),"annotator")}),e.set(As,{annotator:n((s,r)=>s.annotateByArgs(r,["start","end","step"],{array:!0}),"annotator")}),e.set(ii,{annotator:n((s,r)=>s.setType(r,N.build("ARRAY<DATE>")),"annotator")}),e.set(JP,{annotator:n((s,r)=>s.setType(r,N.build("ARRAY<TIMESTAMP>")),"annotator")}),e.set(xe,{annotator:n((s,r)=>s.annotateByArgs(r,["true","false"]),"annotator")}),e.set(I,{annotator:n((s,r)=>s.annotateLiteral(r),"annotator")}),e.set(Lt,{returns:"NULL"}),e.set(qh,{annotator:n((s,r)=>s.annotateByArgs(r,["this","expression"]),"annotator")}),e.set(ot,{annotator:n((s,r)=>s.annotateByArgs(r,["expression"]),"annotator")}),e.set(Es,{annotator:n((s,r)=>s.annotateStruct(r),"annotator")}),e.set(YL,{annotator:n((s,r)=>s.annotateByArgs(r,["this","expressions"],{promote:!0}),"annotator")}),e.set(Lh,{annotator:n((s,r)=>s.setType(r,r.args.withTz?"timestamptz":"timestamp"),"annotator")}),e.set(vh,{annotator:n((s,r)=>s.annotateToMap(r),"annotator")}),e.set(Ee,{annotator:n((s,r)=>s.annotateUnnest(r),"annotator")}),e.set(he,{annotator:n((s,r)=>s.annotateSubquery(r),"annotator")}),e.set(Le,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e.set(Pt,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e.set(lh,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e.set(Re,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e.set(Oe,{annotator:n((s,r)=>s.annotateUnary(r),"annotator")}),e}};qM=Ft(null),R(qM,10,"TIMESTAMP_EXPRESSIONS",t_,Ha),R(qM,10,"EXPRESSION_METADATA",e_,Ha),It(qM,Ha),yt(qM,3,Ha),n(Ha,"DialectTyping");var UM=Ha;var Sj={"\\a":"\x07","\\b":"\b","\\f":"\f","\\n":`
|
|
17
|
+
`,"\\r":"\r","\\t":" ","\\v":"\v","\\\\":"\\"};var kM=(oe=>(oe.DIALECT="",oe.ATHENA="athena",oe.BIGQUERY="bigquery",oe.CLICKHOUSE="clickhouse",oe.DATABRICKS="databricks",oe.DORIS="doris",oe.DREMIO="dremio",oe.DRILL="drill",oe.DRUID="druid",oe.DUCKDB="duckdb",oe.DUNE="dune",oe.FABRIC="fabric",oe.HIVE="hive",oe.MATERIALIZE="materialize",oe.MYSQL="mysql",oe.ORACLE="oracle",oe.POSTGRES="postgres",oe.PRESTO="presto",oe.PRQL="prql",oe.REDSHIFT="redshift",oe.RISINGWAVE="risingwave",oe.SINGLESTORE="singlestore",oe.SNOWFLAKE="snowflake",oe.SOLR="solr",oe.SPARK="spark",oe.SPARK2="spark2",oe.SQLITE="sqlite",oe.STARROCKS="starrocks",oe.TABLEAU="tableau",oe.TERADATA="teradata",oe.TRINO="trino",oe.TSQL="tsql",oe.EXASOL="exasol",oe))(kM||{}),b_=(i=>(i.LOWERCASE="lowercase",i.UPPERCASE="uppercase",i.CASE_SENSITIVE="caseSensitive",i.CASE_INSENSITIVE="caseInsensitive",i.CASE_INSENSITIVE_UPPERCASE="caseInsensitiveUppercase",i))(b_||{}),s_,r_,i_,n_,a_,o_,c_,p_,l_,u_,h_,g_,E_,A_,d_,x_,f_,T_,S_,R_,O_,m_,N_,I_,y_,C_,De;C_=[O],y_=[O],I_=[O],N_=[O],m_=[O],O_=[O],R_=[O],S_=[O],T_=[O],f_=[O],x_=[O],d_=[O],A_=[O],E_=[O],g_=[O],h_=[O],u_=[O],l_=[O],p_=[O],c_=[O],o_=[O],a_=[O],n_=[O],i_=[O],r_=[O],s_=[O];var M=class M{constructor(e={}){this.version=void 0;this.normalizationStrategy=void 0;this.settings=void 0;let{version:t=Number.MAX_SAFE_INTEGER,normalizationStrategy:s}=e,r=t.toString().split(".");for(;r.length<3;)r.push("0");this.version={major:parseInt(r[0]),minor:parseInt(r[1]),patch:parseInt(r[2])},this.normalizationStrategy=st(b_,s)??this._constructor.NORMALIZATION_STRATEGY,this.settings=e;for(let i of Object.keys(e))this._constructor.SUPPORTED_SETTINGS.has(i)||xD("setting",i,[...this._constructor.SUPPORTED_SETTINGS])}static get SUPPORTS_COLUMN_JOIN_MARKS(){return!!this.tokenizerClass.KEYWORDS["(+)"]}static get NULL_ORDERING(){return"nulls_are_small"}static get TIME_MAPPING(){return{}}static get FORMAT_MAPPING(){return{}}static get UNESCAPED_SEQUENCES(){let e={};return this.STRINGS_SUPPORT_ESCAPED_SEQUENCES||this.BYTE_STRINGS_SUPPORT_ESCAPED_SEQUENCES?e={...Sj,...this.ORIGINAL_UNESCAPED_SEQUENCES}:e=this.ORIGINAL_UNESCAPED_SEQUENCES,e}static get PSEUDOCOLUMNS(){return new Set}static get SET_OP_DISTINCT_BY_DEFAULT(){return{except:!0,intersect:!0,union:!0}}static get CREATABLE_KIND_MAPPING(){return{}}static get INITCAP_SUPPORTS_CUSTOM_DELIMITERS(){return["","bigquery","snowflake"].includes(this.DIALECT_NAME)}static get DEFAULT_FUNCTIONS_COLUMN_NAMES(){return new Map}static get DEFAULT_NULL_TYPE(){return"unknown"}static get UNMERGABLE_ARGS(){return new Set(Array.from(se.availableArgs).filter(e=>!["expressions","from","joins","where","order","hint"].includes(e)))}static get TRY_SUPPORTED(){return["","athena","presto","trino","duckdb"].includes(this.DIALECT_NAME)}static get SUPPORTS_UESCAPE(){return["","athena","presto","trino","duckdb"].includes(this.DIALECT_NAME)}static get tokenizerClass(){let e=this._tokenizerClassCache.get(this);if(e)return e;if(Object.prototype.hasOwnProperty.call(this,"Tokenizer"))return this.Tokenizer;let s=Object.getPrototypeOf(this)?.tokenizerClass;if(!s)return this._tokenizerClassCache.set(this,Fr),Fr;let i=class i extends s{};n(i,"DerivedTokenizer");let r=i;return this._tokenizerClassCache.set(this,r),r}static get jsonpathTokenizerClass(){let e=this._jsonpathTokenizerClassCache.get(this);if(e)return e;if(Object.prototype.hasOwnProperty.call(this,"JsonPathTokenizer"))return this.JsonPathTokenizer;let s=Object.getPrototypeOf(this)?.JsonPathTokenizer;if(!s)return this._jsonpathTokenizerClassCache.set(this,VA),VA;let i=class i extends s{};n(i,"DerivedJsonPathTokenizer");let r=i;return this._jsonpathTokenizerClassCache.set(this,r),r}static get parserClass(){let e=this._parserClassCache.get(this);if(e)return e;if(Object.prototype.hasOwnProperty.call(this,"Parser"))return this.Parser;let s=Object.getPrototypeOf(this)?.parserClass;if(!s)return this._parserClassCache.set(this,iy),iy;let i=class i extends s{};n(i,"DerivedParser");let r=i;return this._parserClassCache.set(this,r),r}static get generatorClass(){let e=this._generatorClassCache.get(this);if(e)return e;if(Object.prototype.hasOwnProperty.call(this,"Generator"))return this.Generator;let s=Object.getPrototypeOf(this)?.generatorClass;if(!s)return this._generatorClassCache.set(this,pd),pd;let i=class i extends s{};n(i,"DerivedGenerator");let r=i;return this._generatorClassCache.set(this,r),r}static get TIME_TRIE(){return Yt(Object.keys(this.TIME_MAPPING).map(e=>Array.from(e)))}static get FORMAT_TRIE(){let e=0<Object.keys(this.FORMAT_MAPPING).length?this.FORMAT_MAPPING:this.TIME_MAPPING;return Yt(Object.keys(e).map(t=>Array.from(t)))}static get INVERSE_TIME_MAPPING(){return Object.fromEntries(Object.entries(this.TIME_MAPPING).map(([e,t])=>[t,e]))}static get INVERSE_TIME_TRIE(){return Yt(Object.keys(this.INVERSE_TIME_MAPPING).map(e=>Array.from(e)))}static get INVERSE_FORMAT_MAPPING(){return Object.fromEntries(Object.entries(this.FORMAT_MAPPING).map(([e,t])=>[t,e]))}static get INVERSE_FORMAT_TRIE(){return Yt(Object.keys(this.INVERSE_FORMAT_MAPPING).map(e=>Array.from(e)))}static get INVERSE_CREATABLE_KIND_MAPPING(){return Object.fromEntries(Object.entries(this.CREATABLE_KIND_MAPPING).map(([e,t])=>[t,e]))}static get ESCAPED_SEQUENCES(){return Object.fromEntries(Object.entries(this.UNESCAPED_SEQUENCES).map(([e,t])=>[t,e]))}static get QUOTE_START(){return Object.entries(this.tokenizerClass._QUOTES)[0]?.[0]}static get QUOTE_END(){return Object.entries(this.tokenizerClass._QUOTES)[0]?.[1]}static get IDENTIFIER_START(){return Object.entries(this.tokenizerClass._IDENTIFIERS)[0]?.[0]}static get IDENTIFIER_END(){return Object.entries(this.tokenizerClass._IDENTIFIERS)[0]?.[1]}static getStartEnd(e){let t=Object.entries(this.tokenizerClass._FORMAT_STRINGS).find(([s,[r,i]])=>i===e);if(t){let[s,[r]]=t;return[s,r]}return[void 0,void 0]}static get BIT_START(){return this.getStartEnd("bitString")[0]}static get BIT_END(){return this.getStartEnd("bitString")[1]}static get HEX_START(){return this.getStartEnd("hexString")[0]}static get HEX_END(){return this.getStartEnd("hexString")[1]}static get BYTE_START(){return this.getStartEnd("byteString")[0]}static get BYTE_END(){return this.getStartEnd("byteString")[1]}static get UNICODE_START(){return this.getStartEnd("unicodeString")[0]}static get UNICODE_END(){return this.getStartEnd("unicodeString")[1]}static get DATE_PART_MAPPING(){return{Y:"YEAR",YY:"YEAR",YYY:"YEAR",YYYY:"YEAR",YR:"YEAR",YEARS:"YEAR",YRS:"YEAR",MM:"MONTH",MON:"MONTH",MONS:"MONTH",MONTHS:"MONTH",D:"DAY",DD:"DAY",DAYS:"DAY",DAYOFMONTH:"DAY","DAY OF WEEK":"DAYOFWEEK",WEEKDAY:"DAYOFWEEK",DOW:"DAYOFWEEK",DW:"DAYOFWEEK",WEEKDAY_ISO:"DAYOFWEEKISO",DOW_ISO:"DAYOFWEEKISO",DW_ISO:"DAYOFWEEKISO",DAYOFWEEK_ISO:"DAYOFWEEKISO","DAY OF YEAR":"DAYOFYEAR",DOY:"DAYOFYEAR",DY:"DAYOFYEAR",W:"WEEK",WK:"WEEK",WEEKOFYEAR:"WEEK",WOY:"WEEK",WY:"WEEK",WEEK_ISO:"WEEKISO",WEEKOFYEARISO:"WEEKISO",WEEKOFYEAR_ISO:"WEEKISO",Q:"QUARTER",QTR:"QUARTER",QTRS:"QUARTER",QUARTERS:"QUARTER",H:"HOUR",HH:"HOUR",HR:"HOUR",HOURS:"HOUR",HRS:"HOUR",M:"MINUTE",MI:"MINUTE",MIN:"MINUTE",MINUTES:"MINUTE",MINS:"MINUTE",S:"SECOND",SEC:"SECOND",SECONDS:"SECOND",SECS:"SECOND",MS:"MILLISECOND",MSEC:"MILLISECOND",MSECS:"MILLISECOND",MSECOND:"MILLISECOND",MSECONDS:"MILLISECOND",MILLISEC:"MILLISECOND",MILLISECS:"MILLISECOND",MILLISECON:"MILLISECOND",MILLISECONDS:"MILLISECOND",US:"MICROSECOND",USEC:"MICROSECOND",USECS:"MICROSECOND",MICROSEC:"MICROSECOND",MICROSECS:"MICROSECOND",USECOND:"MICROSECOND",USECONDS:"MICROSECOND",MICROSECONDS:"MICROSECOND",NS:"NANOSECOND",NSEC:"NANOSECOND",NANOSEC:"NANOSECOND",NSECOND:"NANOSECOND",NSECONDS:"NANOSECOND",NANOSECS:"NANOSECOND",EPOCH_SECOND:"EPOCH",EPOCH_SECONDS:"EPOCH",EPOCH_MILLISECONDS:"EPOCH_MILLISECOND",EPOCH_MICROSECONDS:"EPOCH_MICROSECOND",EPOCH_NANOSECONDS:"EPOCH_NANOSECOND",TZH:"TIMEZONE_HOUR",TZM:"TIMEZONE_MINUTE",DEC:"DECADE",DECS:"DECADE",DECADES:"DECADE",MIL:"MILLENNIUM",MILS:"MILLENNIUM",MILLENIA:"MILLENNIUM",C:"CENTURY",CENT:"CENTURY",CENTS:"CENTURY",CENTURIES:"CENTURY"}}static get COERCES_TO(){return new Map}static get EXPRESSION_METADATA(){return UM.EXPRESSION_METADATA}static get SUPPORTED_SETTINGS(){return new Set(["normalizationStrategy","version"])}static get QUOTE_DELIMITERS(){return Object.entries(this.tokenizerClass.QUOTES)[0]}static get IDENTIFIER_DELIMITERS(){return Object.entries(this.tokenizerClass.IDENTIFIERS)[0]}static get BASE_VALID_INTERVAL_UNITS(){return new Set}static get VALID_INTERVAL_UNITS(){let e=this.DATE_PART_MAPPING;return new Set([...this.BASE_VALID_INTERVAL_UNITS,...Object.keys(e),...Object.values(e)])}static get STRINGS_SUPPORT_ESCAPED_SEQUENCES(){return this.tokenizerClass.STRING_ESCAPES.includes("\\")}static get BYTE_STRINGS_SUPPORT_ESCAPED_SEQUENCES(){return this.tokenizerClass.BYTE_STRING_ESCAPES.includes("\\")}static equals(e){return this===e?!0:typeof e=="string"?this===this.get(e):e instanceof M?this===e.constructor:!1}static register(...e){for(let t of e){this.registry.set(t.DIALECT_NAME,t);for(let s of t.DIALECT_ALIASES??[])this.registry.set(s,t)}}static get(e,t){return this.registry.get(e)||t}static getOrRaise(e){if(!e)return new this;if(typeof e=="function"&&(e===M||e.prototype instanceof M))return new e;if(e instanceof M)return e;if(typeof e=="string"){let t,s={};try{let[i,...o]=e.split(",");t=i.trim();for(let c of o){let p=c.split("="),u=p[0].trim(),h=!0;p.length===2&&(h=p[1].trim()),s[yM(u)]=$Y(h)??h}}catch{throw new Error(`Invalid dialect format: '${e}'. Please use the correct format: 'dialect [, k1 = v2 [, ...]]'.`)}let r=this.get(t);if(!r){let i=new Set(Object.keys(kM));xD("dialect",t,Array.from(i))}return new r(s)}throw new Error(`Invalid dialect type for '${e}': '${typeof e}'.`)}static formatTime(e){return typeof e=="string"?I.string(Wl(e.slice(1,-1),this.TIME_MAPPING,this.TIME_TRIE)??""):e instanceof d&&e.isString?I.string(Wl(e.args.this,this.TIME_MAPPING,this.TIME_TRIE)??""):e}equals(e){return this===e?!0:e instanceof M?this.constructor===e.constructor:!1}hash(){return this.constructor.name.toLowerCase()}normalizeIdentifier(e){if(e instanceof F&&this.normalizationStrategy!=="caseSensitive"&&(!e.args.quoted||this.normalizationStrategy==="caseInsensitive"||this.normalizationStrategy==="caseInsensitiveUppercase")){let t=this.normalizationStrategy==="uppercase"||this.normalizationStrategy==="caseInsensitiveUppercase",s=e.args.this;if(typeof s=="string"){let r=t?s.toUpperCase():s.toLowerCase();e.setArgKey("this",r)}}return e}caseSensitive(e){if(this.normalizationStrategy==="caseInsensitive")return!1;let t=this.normalizationStrategy==="uppercase"?s=>s===s.toLowerCase()&&s!==s.toUpperCase():s=>s===s.toUpperCase()&&s!==s.toLowerCase();return Array.from(e).some(t)}canQuote(e,t={}){let{identify:s="safe"}=t;if(e.args.quoted)return!0;if(!s)return!1;if(s===!0)return!0;let r=e.name??"",i=!this.caseSensitive(r)&&tw.test(r);if(s==="safe")return i;if(s==="unsafe")return!i;throw new Error(`Unexpected argument for identify: '${s}'`)}quoteIdentifier(e,t={}){let{identify:s=!0}=t;return e instanceof F&&e.setArgKey("quoted",this.canQuote(e,{identify:s||"unsafe"})),e}toJsonPath(e){if(e instanceof I){let t=e.name;e.isNumber&&(t=`[${t}]`);try{return PD(t,{dialect:this})}catch(s){let r=this._constructor.STRICT_JSON_PATH_SYNTAX,i=t.trimStart(),o=i.startsWith("lax")||i.startsWith("strict");r&&!o&&console.warn(`Invalid JSON path syntax. ${s instanceof Error?s.message:String(s)}`)}}return e}parse(e,t){return this.parser(t).parse(this.tokenize(e),e)}parser(e){return new this._constructor.parserClass({dialect:this,...e})}parseIntoTypes(e,t,s){return this.parser(s).parseIntoTypes(e,this.tokenize(t),t)}generate(e,t={}){let{copy:s=!0,...r}=t;return this.generator(r).generate(e,{copy:s})}generator(e={}){return new this._constructor.generatorClass({dialect:this,...e})}tokenize(e,t={}){return this.tokenizer(t).tokenize(e)}tokenizer(e={}){return new this._constructor.tokenizerClass({dialect:this,...e})}jsonpathTokenizer(e={}){return new this._constructor.jsonpathTokenizerClass({dialect:this,...e})}transpile(e,t={}){return this.parse(e,t).map(s=>s?this.generate(s,{copy:!1,...t}):"")}generateValuesAliases(e){let t=e.args.expressions?.[0];return t instanceof d?(t.args.expressions??[]).map((r,i)=>Z(`_col_${i}`)):[]}get _constructor(){return this.constructor}isKind(e){let t=st(kM,e);return t!==void 0?this._constructor.DIALECT_NAME===t:this._constructor.DIALECT_NAME.toLowerCase()===e.toLowerCase()}};De=Ft(null),R(De,10,"NULL_ORDERING",C_,M),R(De,10,"TIME_MAPPING",y_,M),R(De,10,"FORMAT_MAPPING",I_,M),R(De,10,"UNESCAPED_SEQUENCES",N_,M),R(De,10,"PSEUDOCOLUMNS",m_,M),R(De,10,"SET_OP_DISTINCT_BY_DEFAULT",O_,M),R(De,10,"CREATABLE_KIND_MAPPING",R_,M),R(De,10,"DEFAULT_FUNCTIONS_COLUMN_NAMES",S_,M),R(De,10,"DEFAULT_NULL_TYPE",T_,M),R(De,10,"UNMERGABLE_ARGS",f_,M),R(De,10,"TIME_TRIE",x_,M),R(De,10,"FORMAT_TRIE",d_,M),R(De,10,"INVERSE_TIME_MAPPING",A_,M),R(De,10,"INVERSE_TIME_TRIE",E_,M),R(De,10,"INVERSE_FORMAT_MAPPING",g_,M),R(De,10,"INVERSE_FORMAT_TRIE",h_,M),R(De,10,"INVERSE_CREATABLE_KIND_MAPPING",u_,M),R(De,10,"ESCAPED_SEQUENCES",l_,M),R(De,10,"DATE_PART_MAPPING",p_,M),R(De,10,"COERCES_TO",c_,M),R(De,10,"EXPRESSION_METADATA",o_,M),R(De,10,"SUPPORTED_SETTINGS",a_,M),R(De,10,"QUOTE_DELIMITERS",n_,M),R(De,10,"IDENTIFIER_DELIMITERS",i_,M),R(De,10,"BASE_VALID_INTERVAL_UNITS",r_,M),R(De,10,"VALID_INTERVAL_UNITS",s_,M),It(De,M),yt(De,3,M),n(M,"Dialect"),M.DIALECT_NAME="",M.DIALECT_ALIASES=void 0,M.INDEX_OFFSET=0,M.WEEK_OFFSET=0,M.UNNEST_COLUMN_ONLY=!1,M.ALIAS_POST_TABLESAMPLE=!1,M.ALIAS_POST_VERSION=!0,M.TABLESAMPLE_SIZE_IS_PERCENT=!1,M.NORMALIZATION_STRATEGY="lowercase",M.IDENTIFIERS_CAN_START_WITH_DIGIT=!1,M.DPIPE_IS_STRING_CONCAT=!0,M.STRICT_STRING_CONCAT=!1,M.SUPPORTS_USER_DEFINED_TYPES=!0,M.SUPPORTS_SEMI_ANTI_JOIN=!0,M.COPY_PARAMS_ARE_CSV=!0,M.NORMALIZE_FUNCTIONS="upper",M.PRESERVE_ORIGINAL_NAMES=!1,M.LOG_BASE_FIRST=!0,M.TYPED_DIVISION=!1,M.SAFE_DIVISION=!1,M.CONCAT_COALESCE=!1,M.HEX_LOWERCASE=!1,M.DATE_FORMAT="'%Y-%m-%d'",M.DATEINT_FORMAT="'%Y%m%d'",M.TIME_FORMAT="'%Y-%m-%d %H:%M:%S'",M.ORIGINAL_UNESCAPED_SEQUENCES={},M.PREFER_CTE_ALIAS_COLUMN=!1,M.FORCE_EARLY_ALIAS_REF_EXPANSION=!1,M.EXPAND_ONLY_GROUP_ALIAS_REF=!1,M.ANNOTATE_ALL_SCOPES=!1,M.DISABLES_ALIAS_REF_EXPANSION=!1,M.SUPPORTS_ALIAS_REFS_IN_JOIN_CONDITIONS=!1,M.SUPPORTS_ORDER_BY_ALL=!1,M.PROJECTION_ALIASES_SHADOW_SOURCE_NAMES=!1,M.TABLES_REFERENCEABLE_AS_COLUMNS=!1,M.SUPPORTS_STRUCT_STAR_EXPANSION=!1,M.EXCLUDES_PSEUDOCOLUMNS_FROM_STAR=!1,M.QUERY_RESULTS_ARE_STRUCTS=!1,M.REQUIRES_PARENTHESIZED_STRUCT_ACCESS=!1,M.SUPPORTS_NULL_TYPE=!1,M.COALESCE_COMPARISON_NON_STANDARD=!1,M.HAS_DISTINCT_ARRAY_CONSTRUCTORS=!1,M.SUPPORTS_FIXED_SIZE_ARRAYS=!1,M.STRICT_JSON_PATH_SYNTAX=!0,M.ON_CONDITION_EMPTY_BEFORE_ERROR=!0,M.ARRAY_AGG_INCLUDES_NULLS=!0,M.ARRAY_FUNCS_PROPAGATES_NULLS=!1,M.PROMOTE_TO_INFERRED_DATETIME_TYPE=!1,M.SUPPORTS_VALUES_DEFAULT=!0,M.NUMBERS_CAN_BE_UNDERSCORE_SEPARATED=!1,M.HEX_STRING_IS_INTEGER_TYPE=!1,M.REGEXP_EXTRACT_DEFAULT_GROUP=0,M.REGEXP_EXTRACT_POSITION_OVERFLOW_RETURNS_NULL=!0,M.ALTER_TABLE_SUPPORTS_CASCADE=!1,M.ALTER_TABLE_ADD_REQUIRED_FOR_EACH_COLUMN=!0,M.TRY_CAST_REQUIRES_STRING=void 0,M.SAFE_TO_ELIMINATE_DOUBLE_NEGATION=!0,M.INITCAP_DEFAULT_DELIMITER_CHARS=`
|
|
18
|
+
\r\f\v!"#$%&'()*+,\\-./:;<=>?@\\[\\]^_\`{|}~`,M.BYTE_STRING_IS_BYTES_TYPE=!1,M.UUID_IS_STRING_TYPE=!1,M.JSON_EXTRACT_SCALAR_SCALAR_ONLY=!1,M.LEAST_GREATEST_IGNORES_NULLS=!0,M.UNNEST_REQUIRES_CROSS_JOIN=!1,M.PRIORITIZE_NON_LITERAL_TYPES=!1,M._tokenizerClassCache=new WeakMap,M._jsonpathTokenizerClassCache=new WeakMap,M._parserClassCache=new WeakMap,M._generatorClassCache=new WeakMap,M.registry=new Map;var ae=M;function Fz(a){let e=k(dA(a.args.this,a.args.expressions??[],1-(a.args.offset??0),{dialect:this.dialect}),0);return this.func("ELEMENT_AT",[a.args.this,e])}n(Fz,"bracketToElementAtSql");function Bz(a){return function(e){let t=e.args.this,s=e.args.expression;return e.args.caseInsensitive&&(t=t?new dr({this:t}):void 0,s=s?new dr({this:s}):void 0),this.func(a,[t,s])}}n(Bz,"jarowinklerSimilarity");function UD(a){return function(e){let t=[];for(let s of Object.values(e.args))Array.isArray(s)?t.push(...s):t.push(s);return this.func(a,t)}}n(UD,"renameFunc");function $z(a){return Cb.call(this,a,"accuracy"),this.func("APPROX_COUNT_DISTINCT",[a.args.this])}n($z,"approxCountDistinctSql");function Gz(a="IF",e){return function(t){return t.parent instanceof ut?`WHEN ${this.sql(t,"this")} THEN ${this.sql(t,"true")}`:this.func(a,[t.args.this,t.args.true,t.args.false||e])}}n(Gz,"ifSql");function Yz(a){let e=a.args.this;if(this._constructor.JSON_TYPE_REQUIRED_FOR_EXTRACTION&&e instanceof I&&e.isString){let s=new N({this:"json"});e.replace(X(e.copy(),s))}let t=a instanceof Ns?"->":"->>";return this.binary(a,t)}n(Yz,"arrowJsonExtractSql");function Rj(a){return`[${this.expressions(a,{dynamic:!0,newLine:!0,skipFirst:!0,skipLast:!0})}]`}n(Rj,"inlineArraySql");function Vz(a){let e=k(a.args.expressions??[],0);return e instanceof d&&e?.find?.(ee)?this.func("ARRAY",[e]):Rj.call(this,a)}n(Vz,"inlineArrayUnlessQuery");function Hz(a){let e=new Zt({this:new Ar({this:a.args.this}),expression:new Ar({this:a.args.expression})});return this.likeSql(e)}n(Hz,"noIlikeSql");function _z(a){let e=this.sql(a,"this");return e?`CURRENT_DATE AT TIME ZONE ${e}`:"CURRENT_DATE"}n(_z,"noParenCurrentDateSql");function Wz(a){return a.args.recursive&&(this.unsupported("Recursive CTEs are unsupported"),a.setArgKey("recursive",!1)),this.withSql(a)}n(Wz,"noRecursiveCteSql");function jz(a){return this.unsupported("TABLESAMPLE unsupported"),this.sql(a.args.this)}n(jz,"noTablesampleSql");function Xz(a){return this.unsupported("PIVOT unsupported"),""}n(Xz,"noPivotSql");function Jz(a){return this.castSql(a)}n(Jz,"noTrycastSql");function zz(a){return this.unsupported("CommentColumnConstraint unsupported"),""}n(zz,"noCommentColumnConstraintSql");function Qz(a){return this.unsupported("MAP_FROM_ENTRIES unsupported"),""}n(Qz,"noMapFromEntriesSql");function Zz(a){return`${this.propertyName(a,{stringKey:!0})}=${this.sql(a,"value")}`}n(Zz,"propertySql");function Kz(a,e={}){let{funcName:t="STRPOS",supportsPosition:s=!1,supportsOccurrence:r=!1,useAnsiPosition:i=!0}=e,o=a.args.this,c=a.args.substr,p=a.args.position,u=a.args.occurrence,h=I.number(0),g=I.number(1);r&&u&&s&&!p&&(p=g);let x=p&&!s;x&&(o=new Is({this:o,start:p}));let f;if(t==="POSITION"&&i)f=new Qe({this:t,expressions:[new lt({this:c,field:o})]});else{let T=t==="LOCATE"||t==="CHARINDEX"?[c,o]:[o,c];s&&p!==void 0&&T.push(p),u&&(r?T.push(u):this.unsupported(`${t} does not support the occurrence parameter.`)),f=new Qe({this:t,expressions:T.filter(y=>y!==void 0)})}if(x){let T=new Ce({this:new we({this:f,expression:p}),expression:g}),y=new xe({this:f.eq(h),true:h,false:T});return this.sql(y)}return this.sql(f)}n(Kz,"strPositionSql");function e1(a){return`${this.sql(a,"this")}.${this.sql(Z(a.args.expression?.name??""))}`}n(e1,"structExtractSql");function t1(a,e={}){let{swapParams:t=!1}=e;return function(s){let r=s.args.this,i=s.args.expression,o=t?[i,r]:[r,i],c=this.func(a,o),p=!!s.args.nullPropagation,u=this.dialect._constructor.ARRAY_FUNCS_PROPAGATES_NULLS;if(p===u)return c;if(p)return this.sql(new xe({this:new ze({this:r,expression:le()}),true:le(),false:c}));let h=r??new ue({expressions:[]});return r=new tt({expressions:[h,new ue({expressions:[]})]}),o=t?[i,r]:[r,i],this.func(a,o)}}n(t1,"arrayAppendSql");function s1(a,e={}){let{exclusiveFuncName:t}=e;return function(s){let r=s.args.start,i=s.args.end,o=s.args.step;if(s.args.isEndExclusive){if(t)return this.func(t,[r,i,o]);let c=i instanceof d?new Ce({this:i,expression:I.number(1)}):i;return this.func(a,[r,c,o])}return this.func(a,[r,i,o])}}n(s1,"generateSeriesSql");function r1(a){function e(t,s){if(this._constructor.ARRAY_CONCAT_IS_VAR_LEN)return this.func(t,s);if(s.length===1)return this.func(t,[s[0],new ue({expressions:[]})]);let r=this.func(t,[s[s.length-2],s[s.length-1]]);for(let i=s.length-3;0<=i;i--)r=`${t}(${this.sql(s[i])}, ${r})`;return r}return n(e,"buildFuncCall"),function(t){let s=t.args.this,r=t.args.expressions||[],i=[...s?[s]:[],...r],o=!!t.args.nullPropagation,c=this.dialect._constructor.ARRAY_FUNCS_PROPAGATES_NULLS;if(o===c||s instanceof ue||r.length===0)return e.call(this,a,i);if(o){let h=i.map(g=>new ze({this:g.copy(),expression:le()})).reduce((g,x)=>new pt({this:g,expression:x}));return this.sql(new xe({this:h,true:le(),false:e.call(this,a,i)}))}let p=i.map(u=>new tt({expressions:[u.copy(),new ue({expressions:[]})]}));return e.call(this,a,p)}}n(r1,"arrayConcatSql");function i1(a,e="MAP"){let t=a.args.keys,s=a.args.values;if(!(t instanceof ue)||!(s instanceof ue))return this.unsupported("Cannot convert array columns into map."),this.func(e,[...J(t),...J(s)]);let r=[],i=t.args.expressions,o=s.args.expressions;for(let c=0;c<Math.min(i?.length||0,o?.length||0);c++)r.push(this.sql(i?.[c])),r.push(this.sql(o?.[c]));return this.func(e,r)}n(i1,"varMapSql");function n1(a){let e=a.args.this,t=a.args.expression,s=X(e,"date"),r=X(t,"date"),i=new _s({this:s,expression:r,unit:Q("month")}),o=new Nr({this:s.copy()}),c=new Nr({this:r.copy()}),p=new _a({this:s.copy()}),u=new _a({this:r.copy()}),h=new Nr({this:p}),g=new Nr({this:u}),x=new Me({this:o.copy(),expression:h}),f=new Me({this:c.copy(),expression:g}),T=new Te({this:x,expression:f}),y=new Mt({this:new Re({this:new Ce({this:o.copy(),expression:c.copy()})}),expression:I.number("31.0")}),b=new xe({this:T,true:I.number("0"),false:y});return this.sql(new we({this:i,expression:b}))}n(n1,"monthsBetweenSql");function Oj(a,e){let{dialect:t,defaultValue:s}=e;return r=>new a({this:k(r,0),format:ae.get(t)?.formatTime(k(r,1)||(s===!0?ae.get(t)?.TIME_FORMAT:void 0))})}n(Oj,"buildFormattedTime");function a1(a){return function(e){let t=this.formatTime(e);return t!==ae.getOrRaise(a)?._constructor.TIME_FORMAT?t:void 0}}n(a1,"timeFormat");function OD(a,e,t={}){let{defaultUnit:s,supportsTimezone:r=!1}=t;return i=>{let o=3<=i.length,c=i.length===4,p=o?i[2]:k(i,0),u;if(o||s){u=o?i[0]:I.string(s);let g=u.name?.toLowerCase();if(e&&g&&e[g]&&(u=Q(e[g])),(u instanceof Ve||u instanceof $||u instanceof I)&&!(u instanceof $&&u.parts.length!==1)){let x={D:"DAY",H:"HOUR",M:"MINUTE",MS:"MILLISECOND",NS:"NANOSECOND",Q:"QUARTER",S:"SECOND",US:"MICROSECOND",W:"WEEK",Y:"YEAR"};u=new Ve({this:(x[u.name]||u.name).toUpperCase()})}}let h=new a({this:p,expression:k(i,1),unit:u});return r&&c&&h.setArgKey("zone",i[i.length-1]),h}}n(OD,"buildDateDelta");function o1(a){return e=>{if(e.length<2)throw new Ke(`Expected at least 2 arguments but got ${e.length}`);let t=e[1];if(!(t instanceof qe))throw new Ke(`INTERVAL expression expected but got '${t}'`);return new a({this:e[0],expression:t.args.this,unit:DM(t)})}}n(o1,"buildDateDeltaWithInterval");function c1(a){let e=k(a,0),t=k(a,1);return t instanceof z&&t.isType("date")?new ls({unit:e,this:t}):new Sn({this:t,unit:e})}n(c1,"dateTruncToTime");function p1(a,e){return function(t){let s=this.sql(t,"this"),r=new qe({this:t.args.expression,unit:vD(t)});return`${a}_${e}(${s}, ${this.sql(r)})`}}n(p1,"dateAddIntervalSql");function l1(a={}){let{func:e="DATE_TRUNC",zone:t=!1}=a;return function(s){let r=[DM(s),s.args.this];return t&&r.push(s.args.zone),this.func(e,r)}}n(l1,"timestampTruncSql");function u1(a){let e=a.args.zone;if(!e){let t=Kt(a,{dialect:this.dialect}).type,s=Y(t,N)?t:"timestamp";return this.sql(X(a.args.this||"",s))}return SD.has(e.name?.toLowerCase())?this.sql(new gs({this:X(a.args.this||"","timestamp"),zone:e})):this.func("TIMESTAMP",[a.args.this,e])}n(u1,"noTimestampSql");function h1(a){let e=X(a.args.this||"","timestamptz"),t=X(new gs({this:e,zone:a.args.zone}),"time");return this.sql(t)}n(h1,"noTimeSql");function g1(a){let e=a.args.this,t=a.args.expression;if(t&&SD.has(t.name?.toLowerCase()||"")){let i=X(e,"timestamptz"),o=X(new gs({this:i,zone:t}),"timestamp");return this.sql(o)}let s=X(e,"date"),r=X(t||"","time");return this.sql(X(new we({this:s,expression:r}),"timestamp"))}n(g1,"noDatetimeSql");function E1(a){return this.sql(new Is({this:a.args.this,start:I.number(1),length:a.args.expression}))}n(E1,"leftToSubstringSql");function A1(a){return this.sql(new Is({this:a.args.this,start:new Ce({this:new $h({this:a.args.this}),expression:new Re({this:new Ce({this:a.args.expression,expression:I.number(1)})})})}))}n(A1,"rightToSubstringSql");function d1(a,e={}){let{includePrecision:t=!1}=e,s=N.build(a.args.zone?"timestamptz":"timestamp");if(a.args.this instanceof I&&t){let r=rV(a.args.this.name);0<r&&s&&(s=N.build(s.args.this,{expressions:new Jr({this:I.number(r)})}))}return this.sql(X(a.args.this,s,{dialect:this.dialect}))}n(d1,"timeStrToTimeSql");function x1(a){let e=a.args.this,t=e instanceof d||typeof e=="string"?e:"";return this.sql(X(t,"date"))}n(x1,"dateStrToDateSql");function f1(a,e,t={}){let{replace:s=!0}=t,r=a.args.charset;return r&&!["utf-8","utf8"].includes(r.name?.toLowerCase())&&this.unsupported(`Expected utf-8 character set, got ${r}.`),this.func(e,[a.args.this,s?a.getArgKey("replace"):void 0])}n(f1,"encodeDecodeSql");function T1(a){let e=0<(a.args.expressions?.length??0)?"LEAST":"MIN";return UD(e).call(this,a)}n(T1,"minOrLeast");function S1(a){let e=0<(a.args.expressions?.length??0)?"GREATEST":"MAX";return UD(e).call(this,a)}n(S1,"maxOrGreatest");function R1(a){let e=a.args.this;return e instanceof et&&(e=e.args.expressions?.[0],this.unsupported("DISTINCT is not supported when converting COUNT_IF to SUM")),this.func("sum",e?[new xe({this:e,true:I.number(1),false:I.number(0)})]:[])}n(R1,"countIfToSum");function O1(a,e={}){let{defaultTrimType:t=""}=e,s=this.sql(a,"this"),r=this.sql(a,"position")||t,i=this.sql(a,"expression"),o=this.sql(a,"collation");if(!i)return this.trimSql(a);let c=r?`${r} `:"",p=i?`${i} `:"",u=c||p?"FROM ":"",h=o?` COLLATE ${o}`:"";return`TRIM(${c}${p}${u}${s}${h})`}n(O1,"trimSql");function m1(a){return this.func("STRPTIME",[a.args.this,this.formatTime(a)])}n(m1,"strToTimeSql");function ZH(a){return this.sql((a.args.expressions??[]).reduce((e,t)=>new jt({this:e,expression:t})))}n(ZH,"concatToDPipeSql");function N1(a){let[e,...t]=a.args.expressions??[];return this.sql(t.reduce((s,r)=>new jt({this:s,expression:new jt({this:e,expression:r})})))}n(N1,"concatWsToDPipeSql");function I1(a){let e=a.args.group;return e&&e.name===String(this.dialect._constructor.REGEXP_EXTRACT_DEFAULT_GROUP)&&(e=void 0),this.func(a._constructor.sqlName(),[a.args.this,a.args.expression,e])}n(I1,"regexpExtractSql");function y1(a){return this.func("REGEXP_REPLACE",[a.args.this,a.args.expression,a.args.replacement])}n(y1,"regexpReplaceSql");function C1(a,e){let{dialect:t}=e,s=[];for(let r of a)if(r instanceof Oe)s.push(r.alias);else{let i=r.transform(o=>o instanceof F?new F({this:o.name,quoted:!1}):o);s.push(i.sql({dialect:t,normalizeFunctions:"lower"}))}return s}n(C1,"pivotColumnNames");function b1(a){return e=>new a({this:k(e,0),expression:k(e,1)})}n(b1,"binaryFromFunction");function P1(a){return new Sn({this:k(a,1),unit:k(a,0)})}n(P1,"buildTimestampTrunc");function L1(a,e){let{dialect:t,dateTruncUnabbreviate:s=!0,defaultDateTruncUnit:r,dateTruncRequiresPart:i=!0}=e,o=k(a,0),c=k(a,1);o&&!o.type&&(o=Kt(o,{dialect:t})),c&&!c.type&&(c=Kt(c,{dialect:t}));let p=o?.isType(N.TEMPORAL_TYPES),u=c?.isType(N.TEXT_TYPES),h=o?.isType(N.NUMERIC_TYPES),g=c?.isType(N.NUMERIC_TYPES);if(o&&p&&(c||r)||c&&u){let x=c||I.string(r??"");return new ls({this:o,unit:x,unabbreviate:s})}return o&&h||c&&g||!i&&!c?new ew({this:o,decimals:c}):new Qe({this:"TRUNC",expressions:a})}n(L1,"buildTrunc");function w1(a){return this.func("MAX",[a.args.this])}n(w1,"anyValueToMaxSql");function M1(a){let e=this.sql(a.left),t=this.sql(a.right);return`(${e} AND (NOT ${t})) OR ((NOT ${e}) AND ${t})`}n(M1,"boolXorSql");function k1(a){return a instanceof ai||a instanceof z&&a.isType("json")}n(k1,"isParseJson");function D1(a){return new Re({this:new ze({this:k(a,0),expression:le()})})}n(D1,"isnullToIsNull");function q1(a){let e=this.sql(a,"start")||"1",t=this.sql(a,"increment")||"1";return`IDENTITY(${e}, ${t})`}n(q1,"generatedAsIdentityColumnConstraintSql");function U1(a){return function(e){return this.func(a,[e.args.this,e.args.expression])}}n(U1,"argMaxOrMinNoCount");function mj(a){if(!a.args.this)return a;let e=a.args.this.copy(),t=a.returnType;return re(t,N),t.isType("date")&&(e=X(e,"timestamp")),a.args.this?.replace(X(e,t)),a}n(mj,"tsOrDsAddCast");function v1(a,e={}){let{cast:t=!1}=e;return function(s){let r=s;return t&&s instanceof Vh&&(r=mj(s)),this.func(a,[vD(r),r.args.expression,r.args.this])}}n(v1,"dateDeltaSql");function F1(a={}){let{cast:e=!0}=a;return function(t){let s=t.args.this,r=vD(t),i=t instanceof ft||t instanceof Bh||t instanceof Fh||t instanceof Ds||t instanceof Vh?"+":"-",o;if(e)if(t instanceof Vh){let u=t.returnType;re(u,N),o=u}else s?.isString&&(o=t instanceof Ds||t instanceof Qs?"datetime":"date");s=o?X(s,o):s;let c=t.args.expression,p=c instanceof qe?c:new qe({this:c,unit:r});return`${this.sql(s)} ${i} ${this.sql(p)}`}}n(F1,"dateDeltaToBinaryIntervalOp");function DM(a,e={}){let{defaultValue:t="DAY"}=e,s=a.args.unit;return s instanceof I,s?s instanceof ar||!(s instanceof Ve||s instanceof I||s instanceof F||s instanceof $)?s:I.string(s.name.toUpperCase()):t?I.string(t):void 0}n(DM,"unitToStr");function vD(a,e={}){let{defaultValue:t="DAY"}=e,s=a.args.unit;if(s instanceof Ve||s instanceof ar||s instanceof $||s instanceof zL)return s;let r=s?.name.toUpperCase()||t;return r?Q(r):void 0}n(vD,"unitToVar");function KH(a,e={}){let{dialect:t=ae}=e;if(a===void 0)return a;let s=a instanceof d?a.name:a,r=a instanceof d&&!(a instanceof $&&a.parts?.length!==1)?ae.getOrRaise(t)._constructor.DATE_PART_MAPPING[s.toUpperCase()]:void 0;return r?a instanceof d&&a.isString?I.string(r):typeof a=="string"?I.string(a):Q(r):a instanceof d?a:I.string(a)}n(KH,"mapDatePart");function B1(a){let e=new ls({this:a.args.this,unit:Q("MONTH")}),t=new ft({this:e,expression:I.number(1),unit:Q("MONTH")}),s=new Xt({this:t,expression:I.number(1),unit:Q("DAY")});return this.sql(X(s,"date"))}n(B1,"noLastDaySql");function $1(a){let e=a.args.this?.args.alias,t=n(i=>i?this.dialect.normalizeIdentifier(i).name:void 0,"normalize"),s=a.args.this?.args.this,r=new Set([t(Y(s,d)?s:void 0)]);Y(e,d)&&r.add(typeof e.args.this=="string"?e.args.this:t(Y(e.args.this,d)?e.args.this:void 0));for(let i of a.args.whens?.args.expressions||[]){if(!Y(i,_n))continue;let o=i.args.then;if(o instanceof us)for(let c of o.findAll(Me)){let p=c.args.this;p instanceof $&&r.has(t(typeof p.args.table=="string"?Z(p.args.table):p.args.table))&&p.replace(new $({this:p.args.this}))}else if(o instanceof es){let c=o.args.this;if(c instanceof Ze)for(let p of c.args.expressions||[]){if(!(p instanceof d))continue;let u=p,h=u.getArgKey("table");(u.args.this instanceof F||u.args.this instanceof Ne)&&h&&r.has(h instanceof d?t(h):h.toString())&&u.replace(new $({this:u.args.this}))}}}return this.mergeSql(a)}n($1,"mergeWithoutTargetSql");function G1(a,e={}){let{zeroBasedIndexing:t=!0,arrowReqJsonType:s=!1,jsonType:r}=e;return i=>{let o=[new Qt({})];for(let p of i.slice(1)){if(!(p instanceof I))return a.fromArgList(i);let u=p.name;if(FY(u)&&(!s||!p.isString)){let h=parseInt(u);o.push(new ts({this:t?h:h-1}))}else o.push(new kt({this:u}))}i.splice(2);let c={this:k(i,0),expression:new Er({expressions:o})};return a.prototype instanceof Nh||(c.onlyJsonTypes=s),r!==void 0&&(c.jsonType=r),new a(c)}}n(G1,"buildJsonExtractPath");function Y1(a,e={}){let{quotedIndex:t=!0,op:s}=e;return function(r){let i=r.args.expression;if(!(i instanceof Er))return UD(a).call(this,r);let o=[];for(let c of i.args.expressions??[]){let p=this.sql(c);p&&(c instanceof Ut&&(t||!(c instanceof ts))&&(i.args.escape&&(p=this.escapeStr(p)),p=`${this.dialect._constructor.QUOTE_START}${p}${this.dialect._constructor.QUOTE_END}`),o.push(p))}return s?[this.sql(r.args.this),...o].join(` ${s} `):this.func(a,[r.args.this,...o])}}n(Y1,"jsonExtractSegments");function V1(a){return a.args.this instanceof qt&&this.unsupported("Unsupported wildcard in JsonPathKey expression"),a.name}n(V1,"jsonPathKeyOnlyName");function H1(a){let e=a.args.expression,t=I.string("_u");if(e instanceof ps&&(e.args.expressions?.length??0)===1){let i=e.args.expressions?.[0];i&&(t=i),e=e.args.this}else a instanceof uh&&(e=new xt({this:t,expression:a.args.expression}));let s=new Ee({expressions:[...a.args.this?[a.args.this]:[]]}),r=Ye(t).from(Be(s,void 0,{table:[t]})).where(e);return this.sql(new ue({expressions:[r]}))}n(H1,"filterArrayUsingUnnest");function _1(a){let e=new F({this:"_u",quoted:!1}),t=new ze({this:e,expression:le()}).not();return this.sql(new Va({this:a.args.this,expression:new ps({this:t,expressions:[e]})}))}n(_1,"arrayCompactSql");function W1(a){let e=new F({this:"_u",quoted:!1}),t=new xt({this:e,expression:a.args.expression}),s=this.sql(new Va({this:a.args.this,expression:new ps({this:t,expressions:[e]})}));if(a.args.nullPropagation&&!this.dialect._constructor.ARRAY_FUNCS_PROPAGATES_NULLS){let r=a.args.expression;return r instanceof I&&!(r instanceof Lt)||r instanceof ue?s:this.sql(new xe({this:new ze({this:r,expression:le()}),true:le(),false:s}))}return s}n(W1,"removeFromArrayUsingFilter");function j1(a){return this.func("TO_NUMBER",[a.args.this,a.args.format,a.args.nlsparam])}n(j1,"toNumberWithNlsParam");function X1(a,e){return t=>{if(0<(t.args.expressions?.length??0)||a===void 0)return t;let s=e!==void 0?`${a}, ${e}`:`${a}`;return N.build(`DECIMAL(${s})`)??t}}n(X1,"buildDefaultDecimalType");function J1(a){return this.func(`SHA${a.text("length")||"256"}`,[a.args.this])}n(J1,"sha256Sql");function z1(a){return this.func(`SHA${a.text("length")||"256"}`,[a.args.this])}n(z1,"sha2DigestSql");function Q1(a){let e=a,t=e.args.start,s=e.args.end,r=e.args.step,i=t instanceof z?t.args.to:s instanceof z?s.args.to:void 0;if(t!==void 0&&s!==void 0&&(Rn(i,["date","timestamp"])&&(re(i,N),t instanceof z&&i===t.to?s=X(s,i):t=X(t,i)),Y(e,As)&&e.args.isEndExclusive)){let o=r||I.number(1),c=new Ce({this:s,expression:o});s=new Re({this:c});let p=new Qe({this:"SEQUENCE",expressions:[t,s,...r?[r]:[]]}),u=I.number(0),h=Ht([new Me({this:o.copy(),expression:u.copy()}),ve([new je({this:o.copy(),expression:u.copy()}),new je({this:t.copy(),expression:s.copy()})]),ve([new Fe({this:o.copy(),expression:u.copy()}),new Fe({this:t.copy(),expression:s.copy()})])]),g=new xe({this:h,true:new ue({expressions:[]}),false:p});return this.sql(this.simplifyUnlessLiteral(g))}return this.func("SEQUENCE",[t,s,r])}n(Q1,"sequenceSql");function Z1(a,e={}){let{notLike:t=!1}=e;return s=>{let r=new a({this:k(s,0),expression:k(s,1)}),i=k(s,2);return i&&(r=new Ba({this:r,expression:i})),t?new Le({this:r}):r}}n(Z1,"buildLike");function K1(a){return(e,{dialect:t})=>{let s={this:k(e,0),expression:k(e,1),group:k(e,2)||I.number(t._constructor.REGEXP_EXTRACT_DEFAULT_GROUP),parameters:k(e,3)};return a===ZL&&(s.nullIfPosOverflow=t._constructor.REGEXP_EXTRACT_POSITION_OVERFLOW_RETURNS_NULL),new a(s)}}n(K1,"buildRegexpExtract");function eQ(a){let e=a.args.this,t=a.args.alias,s;if(e instanceof li&&t){re(t,pe);let[r,...i]=t.args.columns||[];re(r,F);let o=i.filter(p=>p instanceof d),c=Ye([Be(r.sub(1),r),...o]).from(new Ee({expressions:[...e.args.this?[e.args.this]:[]],offset:!0,alias:new pe({this:t.args.this,columns:[...o,r]})}));s=new bt({this:c.subquery()})}else e instanceof Jt&&(s=new Ee({expressions:[...e.args.this?[e.args.this]:[]],alias:t}));return s?this.sql(new fe({this:s,kind:"cross"})):this.lateralSql(a)}n(eQ,"explodeToUnnestSql");function tQ(a){return this.func("TIMESTAMPDIFF",[a.unit,a.args.expression,a.args.this])}n(tQ,"timestampDiffSql");function sQ(a,e={}){let{sep:t=", "}=e;return`INTERVAL '${Object.entries(a.args).map(([r,i])=>`${i instanceof oh?i.args.expression:i} ${r}`).join(t)}'`}n(sQ,"noMakeIntervalSql");function rQ(a){return this.func(a.args.binary?"LENGTH":"CHAR_LENGTH",[a.args.this])}n(rQ,"lengthOrCharLengthSql");function iQ(a,e={}){let{funcName:t="LISTAGG",sep:s,withinGroup:r=!0,onOverflow:i=!1}=e,o=s===void 0?",":s,c=a.args.this,p=this.sql(a.args.separator||(o?I.string(o):void 0)),u=i&&this.sql(a,"onOverflow")?` ON OVERFLOW ${this.sql(a,"onOverflow")}`:"",h;c instanceof Dt&&(h=c,c=h.args.this?.pop());let g=c?.find(ye);g?.args.this&&(c=g.args.this.pop());let x=[c?this.sql(c):void 0,p?`${p}${u}`:u||void 0].filter(Boolean).join(", "),f=new Qe({this:t,expressions:[x]}),T=this.sql(h);return g&&(r?f=new ns({this:f,expression:g}):T=`${this.sql(g)}${T}`),T&&f.setArgKey("expressions",[`${x}${T}`]),this.sql(f)}n(iQ,"groupConcatSql");function nQ(a,{dialect:e}){if(a.length===2){let t=a[0];if(t.type||Kt(t,{dialect:e}),t.isType(N.TEMPORAL_TYPES)){let s;return typeof e=="string"?s=e:typeof e=="function"?s=e.name.toLowerCase():s=e.constructor.name.toLowerCase(),Oj(Or,{dialect:s,defaultValue:!0})(a)}}return QL.fromArgList(a)}n(nQ,"buildTimeToStrOrToChar");function aQ(a){return new KL({this:k(a,0),expression:k(a,1),replacement:k(a,2)||I.string("")})}n(aQ,"buildReplaceWithOptionalReplacement");function oQ(a){let e=a.args.modifiers;return!a.args.singleReplace&&(!a.args.occurrence||a.args.occurrence.isInteger&&a.args.occurrence.toValue()===0)&&(!e||e.isString)?I.string((e?.name||"")+"g"):e}n(oQ,"regexpReplaceGlobalModifier");function cQ(a){let e=a.args.this,t=a.args.expression;if(!a.args.zeroIsMsb&&a.isType([...N.SIGNED_INTEGER_TYPES,...N.UNSIGNED_INTEGER_TYPES])){let s=new ih({this:e,expression:t}),r=new rh({this:s,expression:I.number(1)});return this.sql(r)}return this.func("GET_BIT",[e,t])}n(cQ,"getBitSql");var L_="i",w_="k",M_="a",FD="c",sw="t",BD="o",$D="m",FM="v",k_="DataType.Type";function GD(a){let e=0,t=[],s=[[a,void 0,void 0,!1]];for(;0<s.length;){let[r,i,o,c]=s.pop(),p={};if(i!==void 0&&(p[L_]=i),o!==void 0&&(p[w_]=o),c&&(p[M_]=c),t.push(p),r instanceof d){if(p[FD]=r.constructor.name,r.type&&(typeof r=="string"?p[sw]=[r]:typeof r.type=="string"?p[sw]=[r.type]:p[sw]=GD(r.type)),r.comments&&0<r.comments.length&&(p[BD]=r.comments),r.meta&&(p[$D]=r.meta),r.args){let u=Object.entries(r.args).reverse();for(let[h,g]of u)if(Array.isArray(g))for(let x=g.length-1;0<=x;x--)s.push([g[x],e,h,!0]);else g!==void 0&&s.push([g,e,h,!1])}}else r&&typeof r=="object"&&"value"in r?(p[FD]=k_,p[FM]=r.value):p[FM]=r;e++}return t}n(GD,"dump");function YD(a,e){let t={...VD,...e};if(!a||a.length===0)return;let[s,...r]=a,i=P_(s,t);if(!(i instanceof d))return;let o=[i];for(let c of r){let p=P_(c,t);o.push(p);let u=o[c[L_]],h=c[w_];c[M_]?u.append(h,p):u.setArgKey(h,p)}return i}n(YD,"load");function P_(a,e){let t=a[FD];if(!t)return a[FM];if(t===k_)return st(At,a[FM]);let s=e[t];if(!s)throw new Error(`Expression class does not exist: ${t}`);let r=new s({});return a[sw]&&(r.type=YD(a[sw])),a[BD]&&(r.comments=a[BD]),a[$D]&&(r.meta=a[$D]),r}n(P_,"_load");function HD(a){switch(String(a)){case"__proto__":case"prototype":case"constructor":throw new Error("Error: Block an attempty to pollute an object prototype");default:return}}n(HD,"requireSafeDynamicObjectKey");var q_="sqlglot.meta",ND="sqlglot.anonymous",X$=["this","db","catalog"],U_=["this","table","db","catalog"],v_=["line","col","start","end"];function Nj(a){if(typeof a=="boolean")return a;if(typeof a=="string"){let e=a.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"}return!!a}n(Nj,"toBool");var _e=class _e{constructor(e={}){this.args={};this.meta={};this.args=e;for(let[t,s]of Object.entries(e))this.setParent(t,s);Object.defineProperty(this,"meta",{value:{},writable:!0,configurable:!0,enumerable:!1}),Object.defineProperty(this,"comments",{value:void 0,writable:!0,configurable:!0,enumerable:!1})}*[Symbol.iterator](){if(this.constructor.availableArgs.has("expressions")){if(Array.isArray(this.args.expressions))for(let e of this.args.expressions)yield e;return}}text(e){let t=this.getArgKey(e);return typeof t=="string"?t:t instanceof F||t instanceof I||t instanceof Ve?t.args.this?.toString()??"":t instanceof Ne||t instanceof Lt?t.name:""}get isString(){return this instanceof I&&this.args.isString===!0}get isNumber(){return this instanceof I&&!this.args.isString||this instanceof Pt&&this.args.this.isNumber}toValue(){if(this instanceof I){let e=this.args.this;return this.isString?e:typeof e=="string"?Number(e):e}if(this instanceof Pt){let e=this.args.this.toValue();return typeof e=="number"?-e:e!==void 0?-Number(e):void 0}throw new Error(`${this.constructor.name} cannot be converted to a JavaScript value.`)}get isInteger(){if(!this.isNumber)return!1;if(this instanceof I){let e=String(this.args.this);return!e.includes(".")&&!e.toLowerCase().includes("e")}try{return this.args.this.isInteger}catch{return!1}}get isStar(){return this instanceof Ne||this instanceof $&&this.args.this instanceof Ne}get alias(){return this.args.alias instanceof _e?this.args.alias.name:this.text("alias")}get aliasColumnNames(){let e=this.args.alias;if(!(e instanceof pe))return[];let t=e.args.columns;return Array.isArray(t)?t.map(s=>s instanceof _e?s.name:""):[]}get name(){return this.text("this")}get aliasOrName(){return this.alias||this.name}get sqlKey(){return this.sql()}get outputName(){return""}get type(){return this instanceof z?this._type||this.args.to:this._type}set type(e){e!==void 0&&!(e instanceof N)&&(e=N.build(e)),this._type=e}isType(e,t){return this._type?this._type.isType(J(e)):!1}get isLeaf(){return!Object.values(this.args).some(e=>(e instanceof _e||Array.isArray(e))&&e)}copy(){let e=new this.constructor,t=[[this,e]];for(;0<t.length;){let[s,r]=t.pop();s.comments&&(r.comments=[...s.comments]),s._type&&(r._type=s._type.copy()),s.meta&&(r.meta={...s.meta}),s._hash&&(r._hash=s._hash);for(let[i,o]of Object.entries(s.args))if(o instanceof _e){let c=new o.constructor;t.push([o,c]),r.setArgKey(i,c)}else if(Array.isArray(o)){r.args[i]=[];for(let c of o)if(c instanceof _e){let p=new c.constructor;t.push([c,p]),r.append(i,p)}else r.append(i,c)}else r.args[i]=o}return e}addComments(e,t={}){let{prepend:s=!1}=t;if(this.comments||(this.comments=[]),e){for(let r of e){let[i,...o]=r.split(q_);if(0<o.length)for(let c of o.join("").split(",")){let[p,...u]=c.split("="),h=0<u.length?u[0].trim():void 0,g=yM(p.trim());h===void 0?this.meta[g]=!0:/^(true|false|1|0)$/i.test(h)?this.meta[g]=Nj(h):this.meta[g]=h}s||this.comments.push(r)}s&&(this.comments=[...e,...this.comments])}}popComments(){let e=this.comments||[];return this.comments=void 0,e}append(e,t){let s=this.args;Array.isArray(s[e])||(s[e]=[]),this.setParent(e,t);let r=s[e];t instanceof _e&&(t.index=r.length),r.push(t)}setArgKey(e,t,s,r){HD(e),HD(s);let i=r?.overwrite??!0,o=this;for(;o&&o._hash!==void 0;)o._hash=void 0,o=o.parent;let c=this.args;if(s!==void 0){let p=c[e]||[];if(p[s]===void 0)return;if(t===void 0){p.splice(s,1);for(let u=s;u<p.length;u++){let h=p[u];h instanceof _e&&h.index!==void 0&&(h.index=h.index-1)}return}Array.isArray(t)?(p.splice(s,1),p.splice(s,0,...t)):i?p[s]=t:p.splice(s,0,t),t=p}else if(t===void 0){delete c[e];return}c[e]=t,this.setParent(e,t,s)}getArgKey(e){if(e!==void 0)return this.args[e]??void 0}setParent(e,t,s){t instanceof _e?(t.parent=this,t.argKey=e,t.index=s):Array.isArray(t)&&t.forEach((r,i)=>{r instanceof _e&&(r.parent=this,r.argKey=e,r.index=i)})}get depth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}*iterExpressions(e){let t=e?.reverse??!1,s=t?Object.values(this.args).reverse():Object.values(this.args);for(let r of s)if(r instanceof _e)yield r;else if(Array.isArray(r)){let i=t?[...r].reverse():r;for(let o of i)o instanceof _e&&(yield o)}}find(e,t){for(let s of this.findAll(e,t))return s}*findAll(e,t){let s=Array.from(J(e)),r=t?.bfs??!0;for(let i of this.walk({bfs:r}))s.some(o=>i instanceof o)&&(yield i)}findAncestor(...e){let t=this.parent;for(;t;){if(e.some(s=>t instanceof s))return t;t=t.parent}}get parentSelect(){return this.findAncestor(se)}get sameParent(){return this.parent?.constructor===this.constructor}sameParentAs(e){return this.parent===e.parent}root(){let e=this;for(;e.parent;)e=e.parent;return e}*walk(e){let t=e?.bfs??!0,s=e?.prune;t?yield*this.bfs({prune:s}):yield*this.dfs({prune:s})}*dfs(e){let t=e?.prune,s=[this];for(;0<s.length;){let r=s.pop();if(yield r,!t?.(r))for(let i of r.iterExpressions({reverse:!0}))s.push(i)}}*bfs(e){let t=e?.prune,s=[this];for(;0<s.length;){let r=s.shift();if(yield r,!t?.(r))for(let i of r.iterExpressions())s.push(i)}}unnest(){let e=this;for(;e instanceof Re;){let t=e.args.this;if(t instanceof _e)e=t;else break}return e}unalias(){if(this instanceof Oe){let e=this.args.this;if(e instanceof _e)return e}return this}unnestOperands(){return Array.from(this.iterExpressions()).map(e=>e.unnest())}*flatten(e){let t=e?.unnest??!0;for(let s of this.dfs({prune:n(r=>r.parent!==void 0&&r.constructor!==this.constructor,"prune")}))s.constructor!==this.constructor&&(t&&!(s instanceof he)?yield s.unnest():yield s)}sql(e={}){let{dialect:t,...s}=e;return ae.getOrRaise(t).generate(this,s)}transform(e,t={}){let{copy:s=!0,...r}=t,i,o,c=s?this.copy():this;for(let p of c.dfs({prune:n(u=>u!==o,"prune")})){let u=p.parent,h=p.argKey,g=p.index;o=e(p,{...r,copy:s}),i?u&&h&&o!==p&&u.setArgKey(h,o,g):i=o}if(!i)throw new Error("Transform failed: no root node");if(!(i instanceof _e))throw new Error("Expected final root to be an Expression");return i}replace(e){let t=this.parent;if(!t||t===e)return e;let s=this.argKey;if(!s)return e;let r=t.getArgKey(s);return Array.isArray(e)&&r instanceof _e?r.parent?.replace(e):t.setArgKey(s,e,this.index),e!==this&&(this.parent=void 0,this.argKey=void 0,this.index=void 0),e}pop(){return this.replace(void 0),this}assertIs(e){if(!(this instanceof e))throw new Error(`${this.constructor.name} is not ${e.name}.`);return this}errorMessages(e){let t=[],s=this._constructor;for(let r of s.requiredArgs){let i=this.getArgKey(r);(i===void 0||Array.isArray(i)&&i.length===0)&&t.push(`Required keyword: '${r}' missing for ${this.constructor.name}`)}if(e&&this instanceof E){let r=s.availableArgs.size,i=s.isVarLenArgs||!1;r<e.length&&!i&&t.push(`The number of provided arguments (${e.length}) is greater than the maximum number of supported arguments (${r})`)}return t}dump(){return GD(this)}static load(e){return YD(e)}and(e,t={}){let{copy:s=!0,wrap:r=!0,...i}=t,o=Array.from(J(e));return ve([this,...o],{...i,copy:s,wrap:r})}or(e,t={}){let{copy:s=!0,wrap:r=!0,...i}=t,o=Array.from(J(e));return Ht([this,...o],{...i,copy:s,wrap:r})}not(e={}){let{copy:t=!0,...s}=e;return ks(this,{...s,copy:t})}updatePositions(e,t){if(!e)this.meta.line=t?.line,this.meta.col=t?.col,this.meta.start=t?.start,this.meta.end=t?.end;else if(e instanceof _e)for(let s of v_)s in e.meta&&(this.meta[s]=e.meta[s]);else this.meta.line=e.line,this.meta.col=e.col,this.meta.start=e.start,this.meta.end=e.end;return this}as(e,t={}){let{copy:s=!0,...r}=t,i=e instanceof _e?e.name:e.toString();return Be(this,i,{...r,copy:s})}binop(e,t,s){let r=s?.reverse??!1,i=this.copy(),o=ht(t,{copy:!0});if(!(i instanceof e)&&!(t instanceof e)){let c=mr(i,v),p=mr(o,v);c&&(i=c),p&&(o=p)}return r?new e({this:o,expression:i}):new e({this:i,expression:o})}resetHash(){this._hash=void 0}computeHash(){return this.hash()}hash(){if(this._hash!==void 0)return this._hash;let e=[],t=[this];for(;0<t.length;){let s=t.shift();e.push(s);for(let r of s.iterExpressions())r._hash===void 0&&t.push(r)}for(let s=e.length-1;0<=s;s--){let r=e[s],i=this.hashString(r._constructor.key);if(r instanceof I||r instanceof F){let o=Object.entries(r.args).sort();for(let[c,p]of o)p&&(i=this.hashString(i+c+p.toString()))}else{let o=Object.entries(r.args);for(let[c,p]of o)if(Array.isArray(p))for(let u of p)if(u!==void 0&&u!==!1){let h=typeof u=="string"?u.toLowerCase():u;i=this.hashString(i+c+h)}else i=this.hashString(i+c);else if(p!==void 0&&p!==!1){let u=typeof p=="string"?p.toLowerCase():p;i=this.hashString(i+c+u)}}r._hash=i}return this._hash||""}equals(e){return this===e?!0:!(e instanceof _e)||this.constructor!==e.constructor?!1:this.hash()===e.hash()}hashString(e){return e.split("").reduce((t,s)=>(t=(t<<5)-t+s.charCodeAt(0),t&t),0).toString()}toString(){return this.sql()}in(e,t,s={}){let{copy:r=!0,unnest:i,...o}=s,c=t?j(t):void 0;return!(c instanceof he)&&c instanceof ee&&(c=c.subquery(void 0,{copy:!1})),new lt({this:$e(this,r),expressions:e?.map(p=>ht(p,{copy:r})),query:c,unnest:i?new Ee({expressions:Array.from(J(i)).map(p=>j(p,{...o,copy:r}))}):void 0})}between(e,t,s={}){let{copy:r=!0,symmetric:i}=s,o=new Ss({this:$e(this,r),low:ht(e,{copy:r}),high:ht(t,{copy:r})});return i!==void 0&&o.setArgKey("symmetric",i),o}is(e){return this.binop(ze,e)}like(e){return this.binop(Zt,e)}ilike(e){return this.binop(Gs,e)}eq(e){return this.binop(Me,e)}neq(e){return this.binop(xt,e)}rlike(e){return this.binop(Ga,e)}div(e,t){let s=this.binop(Mt,e);return s.setArgKey("typed",t?.typed??!1),s.setArgKey("safe",t?.safe??!1),s}asc(e={}){let{nullsFirst:t=!0}=e;return new hs({this:this.copy(),nullsFirst:t?ht(t):void 0})}desc(e={}){let{nullsFirst:t=!1}=e;return new hs({this:this.copy(),desc:ht(!0),nullsFirst:t?ht(t):void 0})}lt(e){return this.binop(Fe,e)}lte(e){return this.binop(nt,e)}gt(e){return this.binop(je,e)}gte(e){return this.binop(Je,e)}add(e){return this.binop(we,e)}radd(e){return this.binop(we,e,{reverse:!0})}sub(e){return this.binop(Ce,e)}rsub(e){return this.binop(Ce,e,{reverse:!0})}mul(e){return this.binop(Ts,e)}rmul(e){return this.binop(Ts,e,{reverse:!0})}truediv(e){return this.binop(Mt,e)}rtruediv(e){return this.binop(Mt,e,{reverse:!0})}floorDiv(e){return this.binop(Un,e)}rfloorDiv(e){return this.binop(Un,e,{reverse:!0})}mod(e){return this.binop(jr,e)}rmod(e){return this.binop(jr,e,{reverse:!0})}pow(e){return this.binop(Gh,e)}rpow(e){return this.binop(Gh,e,{reverse:!0})}neg(){return new Pt({this:mr(this.copy(),v)})}invert(){return ks(this.copy())}getItem(...e){return new wt({this:this.copy(),expressions:(Array.isArray(e)?e:[e]).map(t=>ht(t,{copy:!0}))})}get _constructor(){return this.constructor}};n(_e,"Expression"),_e.key="expression",_e.requiredArgs=new Set(["this"]),_e.availableArgs=new Set(["this"]);var d=_e,VM=class VM extends d{constructor(e={}){super(e)}};n(VM,"ConditionExpr"),VM.key="condition";var be=VM,fd=class fd extends be{constructor(e={}){super(e)}};n(fd,"PredicateExpr"),fd.key="predicate",fd.requiredArgs=new Set(["this"]),fd.availableArgs=new Set(["this"]);var ke=fd,Td=class Td extends d{constructor(e={}){super(e)}get selects(){return this.args.this instanceof ee?this.args.this.selects:[]}get namedSelects(){return this.selects.map(e=>e.outputName)}};n(Td,"DerivedTableExpr"),Td.key="derivedTable",Td.requiredArgs=new Set(["this"]),Td.availableArgs=new Set(["this"]);var An=Td,Sd=class Sd extends d{constructor(e={}){super(e)}subquery(e,t={}){let{copy:s=!0}=t,r=$e(this,s),i;return e instanceof pe?i=e:e&&(i=new pe({this:Z(e)})),new he({this:r,alias:i})}limit(e,t={}){let{copy:s=!0,...r}=t;return JE(e,{instance:this,arg:"limit",into:Dt,prefix:"LIMIT",intoArg:"expression",...r,copy:s})}offset(e,t={}){let{copy:s=!0,...r}=t;return JE(e,{instance:this,arg:"offset",into:Cn,prefix:"OFFSET",intoArg:"expression",...r,copy:s})}orderBy(e,t={}){let{append:s=!0,copy:r=!0,...i}=t,o=Array.from(J(e));return xd(o,{instance:this,arg:"order",prefix:"ORDER BY",into:ye,...i,append:s,copy:r})}get ctes(){let e=this.args.with;return Et(e?.args.expressions??[],d)}get selects(){throw new Error("Query objects must implement `selects`")}get namedSelects(){throw new Error("Query objects must implement `namedSelects`")}select(e,t={}){throw new Error("Query objects must implement `select`")}where(e,t={}){let{append:s=!0,copy:r=!0,dialect:i,...o}=t;return FI(J(e).map(c=>c instanceof St?c.args.this:c),{instance:this,arg:"where",into:St,append:s,copy:r,dialect:i,...o})}with(e,t,s={}){let{recursive:r=!1,append:i=!0,copy:o=!0,...c}=s;return z$({instance:this,alias:e,as:t,...c,recursive:r,append:i,copy:o})}union(e,t={}){return jA([this,...e!==void 0?J(e):[]],{...t,distinct:t.distinct??!0})}intersect(e,t={}){return B_([this,...J(e)],{...t,distinct:t.distinct??!0})}except(e,t={}){return $_([this,...e!==void 0?Array.from(J(e)):[]],{...t,distinct:t.distinct??!0})}};n(Sd,"QueryExpr"),Sd.key="query",Sd.requiredArgs=new Set(["this"]),Sd.availableArgs=new Set(["this"]);var ee=Sd,HM=class HM extends An{constructor(e={}){super(e)}get selects(){let e=this.args.alias;return Y(e,pe)?e.columns:[]}};n(HM,"UdtfExpr"),HM.key="udtf";var Ct=HM,Rd=class Rd extends d{constructor(e={}){super(e)}};n(Rd,"CacheExpr"),Rd.key="cache",Rd.requiredArgs=new Set(["this"]),Rd.availableArgs=new Set(["this","lazy","options","expression"]);var ny=Rd,Od=class Od extends d{constructor(e={}){super(e)}};n(Od,"UncacheExpr"),Od.key="uncache",Od.requiredArgs=new Set(["this"]),Od.availableArgs=new Set(["this","exists"]);var ay=Od,md=class md extends d{constructor(e={}){super(e)}};n(md,"RefreshExpr"),md.key="refresh",md.requiredArgs=new Set(["this","kind"]),md.availableArgs=new Set(["this","kind"]);var oy=md,Nd=class Nd extends d{constructor(e={}){super(e)}get ctes(){let e=this.args.with;return Et(e?.args.expressions??[],d)}get selects(){let e=this.args.expression;return e instanceof ee?e.selects:[]}get namedSelects(){let e=this.args.expression;return e instanceof ee?e.namedSelects:[]}};n(Nd,"DdlExpr"),Nd.key="ddl",Nd.requiredArgs=new Set(["this"]),Nd.availableArgs=new Set(["this"]);var dn=Nd,Id=class Id extends d{constructor(e={}){super(e)}};n(Id,"LockingStatementExpr"),Id.key="lockingStatement",Id.requiredArgs=new Set(["this","expression"]),Id.availableArgs=new Set(["this","expression"]);var _D=Id,yd=class yd extends d{constructor(e={}){super(e)}returning(e,t={}){let{copy:s=!0,...r}=t;return JE(e,{instance:this,arg:"returning",prefix:"RETURNING",into:BA,...r,copy:s})}};n(yd,"DmlExpr"),yd.key="dml",yd.requiredArgs=new Set(["this"]),yd.availableArgs=new Set(["this"]);var bs=yd,Cd=class Cd extends dn{constructor(e={}){super(e)}get kind(){return this.args.kind}};n(Cd,"CreateExpr"),Cd.key="create",Cd.requiredArgs=new Set(["this","kind"]),Cd.availableArgs=new Set(["with","this","kind","expression","exists","properties","replace","refresh","unique","indexes","noSchemaBinding","begin","clone","concurrently","clustered"]);var ss=Cd,bd=class bd extends d{constructor(e={}){super(e)}};n(bd,"SequencePropertiesExpr"),bd.key="sequenceProperties",bd.requiredArgs=new Set,bd.availableArgs=new Set(["increment","minvalue","maxvalue","cache","start","owned","options"]);var Br=bd,Pd=class Pd extends d{constructor(e={}){super(e)}};n(Pd,"TriggerPropertiesExpr"),Pd.key="triggerProperties",Pd.requiredArgs=new Set(["table","timing","events","execute"]),Pd.availableArgs=new Set(["table","timing","events","execute","constraint","referencedTable","deferrable","initially","referencing","forEach","when"]);var Gn=Pd,_M=class _M extends d{constructor(e={}){super(e)}};n(_M,"TriggerExecuteExpr"),_M.key="triggerExecute";var cy=_M,Ld=class Ld extends d{constructor(e={}){super(e)}};n(Ld,"TriggerEventExpr"),Ld.key="triggerEvent",Ld.requiredArgs=new Set(["this"]),Ld.availableArgs=new Set(["this","columns"]);var py=Ld,wd=class wd extends d{constructor(e={}){super(e)}};n(wd,"TriggerReferencingExpr"),wd.key="triggerReferencing",wd.requiredArgs=new Set,wd.availableArgs=new Set(["old","new"]);var ly=wd,Md=class Md extends d{constructor(e={}){super(e)}};n(Md,"TruncateTableExpr"),Md.key="truncateTable",Md.requiredArgs=new Set(["expressions"]),Md.availableArgs=new Set(["expressions","isDatabase","exists","only","cluster","identity","option","partition"]);var uy=Md,kd=class kd extends d{constructor(e={}){super(e)}};n(kd,"CloneExpr"),kd.key="clone",kd.requiredArgs=new Set(["this"]),kd.availableArgs=new Set(["this","shallow","copy"]);var hy=kd,Dd=class Dd extends d{constructor(e={}){super(e)}};n(Dd,"DescribeExpr"),Dd.key="describe",Dd.requiredArgs=new Set(["this"]),Dd.availableArgs=new Set(["this","properties","style","kind","expressions","partition","format","asJson"]);var Ql=Dd,qd=class qd extends d{constructor(e={}){super(e)}};n(qd,"AttachExpr"),qd.key="attach",qd.requiredArgs=new Set(["this"]),qd.availableArgs=new Set(["this","exists","expressions"]);var WD=qd,Ud=class Ud extends d{constructor(e={}){super(e)}};n(Ud,"DetachExpr"),Ud.key="detach",Ud.requiredArgs=new Set(["this"]),Ud.availableArgs=new Set(["this","kind","exists","cluster","permanent","sync"]);var jD=Ud,vd=class vd extends d{constructor(e={}){super(e)}};n(vd,"InstallExpr"),vd.key="install",vd.requiredArgs=new Set(["this"]),vd.availableArgs=new Set(["this","from","force"]);var XD=vd,Fd=class Fd extends d{constructor(e={}){super(e)}};n(Fd,"SummarizeExpr"),Fd.key="summarize",Fd.requiredArgs=new Set(["this"]),Fd.availableArgs=new Set(["this","table"]);var gy=Fd,Bd=class Bd extends d{constructor(e={}){super(e)}};n(Bd,"KillExpr"),Bd.key="kill",Bd.requiredArgs=new Set(["this"]),Bd.availableArgs=new Set(["this","kind"]);var Ey=Bd,$d=class $d extends d{constructor(e={}){super(e)}};n($d,"PragmaExpr"),$d.key="pragma",$d.requiredArgs=new Set(["this"]),$d.availableArgs=new Set(["this"]);var Ay=$d,Gd=class Gd extends d{constructor(e={}){super(e)}};n(Gd,"DeclareExpr"),Gd.key="declare",Gd.requiredArgs=new Set(["expressions"]),Gd.availableArgs=new Set(["expressions","replace"]);var dy=Gd,Yd=class Yd extends d{constructor(e={}){super(e)}};n(Yd,"DeclareItemExpr"),Yd.key="declareItem",Yd.requiredArgs=new Set(["this"]),Yd.availableArgs=new Set(["this","kind","default"]);var xy=Yd,Vd=class Vd extends d{constructor(e={}){super(e)}};n(Vd,"SetExpr"),Vd.key="set",Vd.requiredArgs=new Set,Vd.availableArgs=new Set(["expressions","unset","tag"]);var Zl=Vd,Hd=class Hd extends d{constructor(e={}){super(e)}};n(Hd,"HeredocExpr"),Hd.key="heredoc",Hd.requiredArgs=new Set(["this"]),Hd.availableArgs=new Set(["this","tag"]);var fA=Hd,_d=class _d extends d{constructor(e={}){super(e)}};n(_d,"SetItemExpr"),_d.key="setItem",_d.requiredArgs=new Set,_d.availableArgs=new Set(["this","expressions","kind","collate","global"]);var Xl=_d,Wd=class Wd extends d{constructor(e={}){super(e)}};n(Wd,"QueryBandExpr"),Wd.key="queryBand",Wd.requiredArgs=new Set(["this"]),Wd.availableArgs=new Set(["this","scope","update"]);var JD=Wd,jd=class jd extends d{constructor(e={}){super(e)}};n(jd,"ShowExpr"),jd.key="show",jd.requiredArgs=new Set(["this"]),jd.availableArgs=new Set(["this","history","terse","target","offset","startsWith","limit","from","like","where","db","scope","scopeKind","full","mutex","query","channel","global","log","position","types","privileges","forTable","forGroup","forUser","forRole","intoOutfile","json","iceberg"]);var zD=jd,Xd=class Xd extends d{constructor(e={}){super(e)}};n(Xd,"UserDefinedFunctionExpr"),Xd.key="userDefinedFunction",Xd.requiredArgs=new Set(["this"]),Xd.availableArgs=new Set(["this","expressions","wrapped"]);var fy=Xd,Jd=class Jd extends d{constructor(e={}){super(e)}};n(Jd,"CharacterSetExpr"),Jd.key="characterSet",Jd.requiredArgs=new Set(["this"]),Jd.availableArgs=new Set(["this","default"]);var TA=Jd,zd=class zd extends d{constructor(e={}){super(e)}};n(zd,"RecursiveWithSearchExpr"),zd.key="recursiveWithSearch",zd.requiredArgs=new Set(["kind","this","expression"]),zd.availableArgs=new Set(["kind","this","expression","using"]);var Ty=zd,Qd=class Qd extends d{constructor(e={}){super(e)}get recursive(){return this.args.recursive}};n(Qd,"WithExpr"),Qd.key="with",Qd.requiredArgs=new Set(["expressions"]),Qd.availableArgs=new Set(["expressions","recursive","search"]);var dt=Qd,Zd=class Zd extends d{constructor(e={}){super(e)}};n(Zd,"WithinGroupExpr"),Zd.key="withinGroup",Zd.requiredArgs=new Set(["this"]),Zd.availableArgs=new Set(["this","expression"]);var ns=Zd,Kd=class Kd extends d{constructor(e={}){super(e)}};n(Kd,"ProjectionDefExpr"),Kd.key="projectionDef",Kd.requiredArgs=new Set(["this","expression"]),Kd.availableArgs=new Set(["this","expression"]);var QD=Kd,ex=class ex extends d{constructor(e={}){super(e)}get columns(){return this.args.columns||[]}};n(ex,"TableAliasExpr"),ex.key="tableAlias",ex.requiredArgs=new Set,ex.availableArgs=new Set(["this","columns"]);var pe=ex,tx=class tx extends d{constructor(e={}){super(e)}};n(tx,"ColumnPositionExpr"),tx.key="columnPosition",tx.requiredArgs=new Set(["position"]),tx.availableArgs=new Set(["this","position"]);var Sy=tx,sx=class sx extends d{constructor(e={}){super(e)}get kind(){return this.args.kind}get constraints(){return this.args.constraints||[]}};n(sx,"ColumnDefExpr"),sx.key="columnDef",sx.requiredArgs=new Set(["this"]),sx.availableArgs=new Set(["this","kind","constraints","exists","position","default","output"]);var Pe=sx,rx=class rx extends d{constructor(e={}){super(e)}};n(rx,"AlterColumnExpr"),rx.key="alterColumn",rx.requiredArgs=new Set(["this"]),rx.availableArgs=new Set(["this","dtype","collate","using","default","drop","comment","allowNull","visible","renameTo"]);var ms=rx,WM=class WM extends d{constructor(e={}){super(e)}};n(WM,"ModifyColumnExpr"),WM.key="modifyColumn";var ZD=WM,ix=class ix extends d{constructor(e={}){super(e)}};n(ix,"AlterIndexExpr"),ix.key="alterIndex",ix.requiredArgs=new Set(["this","visible"]),ix.availableArgs=new Set(["this","visible"]);var KD=ix,nx=class nx extends d{constructor(e={}){super(e)}};n(nx,"AlterDistStyleExpr"),nx.key="alterDistStyle",nx.requiredArgs=new Set(["this"]),nx.availableArgs=new Set(["this"]);var SA=nx,ax=class ax extends d{constructor(e={}){super(e)}};n(ax,"AlterSortKeyExpr"),ax.key="alterSortKey",ax.requiredArgs=new Set,ax.availableArgs=new Set(["this","expressions","compound"]);var RA=ax,ox=class ox extends d{constructor(e={}){super(e)}};n(ox,"AlterSetExpr"),ox.key="alterSet",ox.requiredArgs=new Set,ox.availableArgs=new Set(["expressions","option","tablespace","accessMethod","fileFormat","copyOptions","tag","location","serde"]);var Ry=ox,cx=class cx extends d{constructor(e={}){super(e)}};n(cx,"RenameColumnExpr"),cx.key="renameColumn",cx.requiredArgs=new Set(["this","to"]),cx.availableArgs=new Set(["this","to","exists"]);var FA=cx,px=class px extends d{constructor(e={}){super(e)}};n(px,"AlterRenameExpr"),px.key="alterRename",px.requiredArgs=new Set(["this"]),px.availableArgs=new Set(["this"]);var Yn=px,lx=class lx extends d{constructor(e={}){super(e)}};n(lx,"AlterModifySqlSecurityExpr"),lx.key="alterModifySqlSecurity",lx.requiredArgs=new Set(["expressions"]),lx.availableArgs=new Set(["expressions"]);var eq=lx,ux=class ux extends d{constructor(e={}){super(e)}};n(ux,"SwapTableExpr"),ux.key="swapTable",ux.requiredArgs=new Set(["this"]),ux.availableArgs=new Set(["this"]);var Kl=ux,hx=class hx extends d{constructor(e={}){super(e)}};n(hx,"CommentExpr"),hx.key="comment",hx.requiredArgs=new Set(["this","kind","expression"]),hx.availableArgs=new Set(["this","kind","expression","exists","materialized"]);var Oy=hx,gx=class gx extends d{constructor(e={}){super(e)}};n(gx,"ComprehensionExpr"),gx.key="comprehension",gx.requiredArgs=new Set(["this","expression","iterator"]),gx.availableArgs=new Set(["this","expression","position","iterator","condition"]);var my=gx,Ex=class Ex extends d{constructor(e={}){super(e)}};n(Ex,"MergeTreeTtlActionExpr"),Ex.key="mergeTreeTtlAction",Ex.requiredArgs=new Set(["this"]),Ex.availableArgs=new Set(["this","delete","recompress","toDisk","toVolume"]);var In=Ex,Ax=class Ax extends d{constructor(e={}){super(e)}};n(Ax,"MergeTreeTtlExpr"),Ax.key="mergeTreeTtl",Ax.requiredArgs=new Set(["expressions"]),Ax.availableArgs=new Set(["expressions","where","group","aggregates"]);var Pn=Ax,dx=class dx extends d{constructor(e={}){super(e)}};n(dx,"IndexConstraintOptionExpr"),dx.key="indexConstraintOption",dx.requiredArgs=new Set,dx.availableArgs=new Set(["keyBlockSize","using","parser","comment","visible","engineAttr","secondaryEngineAttr"]);var tq=dx,xx=class xx extends d{constructor(e={}){super(e)}get kind(){return this.args.kind}};n(xx,"ColumnConstraintExpr"),xx.key="columnConstraint",xx.requiredArgs=new Set(["kind"]),xx.availableArgs=new Set(["this","kind"]);var yn=xx,fx=class fx extends d{constructor(e={}){super(e)}};n(fx,"ColumnConstraintKindExpr"),fx.key="columnConstraintKind",fx.requiredArgs=new Set(["this"]),fx.availableArgs=new Set(["this"]);var ce=fx,Tx=class Tx extends d{constructor(e={}){super(e)}};n(Tx,"WithOperatorExpr"),Tx.key="withOperator",Tx.requiredArgs=new Set(["this","op"]),Tx.availableArgs=new Set(["this","op"]);var eu=Tx,Sx=class Sx extends d{constructor(e={}){super(e)}};n(Sx,"WatermarkColumnConstraintExpr"),Sx.key="watermarkColumnConstraint",Sx.requiredArgs=new Set(["this","expression"]),Sx.availableArgs=new Set(["this","expression"]);var sq=Sx,Rx=class Rx extends d{constructor(e={}){super(e)}};n(Rx,"ConstraintExpr"),Rx.key="constraint",Rx.requiredArgs=new Set(["this","expressions"]),Rx.availableArgs=new Set(["this","expressions"]);var Ny=Rx,Ox=class Ox extends bs{constructor(e={}){super(e)}delete(e,t={}){let{copy:s=!0,...r}=t;return JE(e,{instance:this,arg:"this",into:W,...r,copy:s})}where(e,t={}){let{append:s=!0,copy:r=!0,...i}=t;return FI(Array.from(J(e)),{instance:this,arg:"where",into:St,...i,append:s,copy:r})}};n(Ox,"DeleteExpr"),Ox.key="delete",Ox.requiredArgs=new Set,Ox.availableArgs=new Set(["with","this","using","where","returning","order","limit","tables","cluster"]);var Gr=Ox,mx=class mx extends d{constructor(e={}){super(e)}get kind(){return this.args.kind}};n(mx,"DropExpr"),mx.key="drop",mx.requiredArgs=new Set,mx.availableArgs=new Set(["this","kind","expressions","exists","temporary","materialized","cascade","restrict","constraints","purge","cluster","concurrently","sync","iceberg"]);var tu=mx,Nx=class Nx extends d{constructor(e={}){super(e)}};n(Nx,"ExportExpr"),Nx.key="export",Nx.requiredArgs=new Set(["this","options"]),Nx.availableArgs=new Set(["this","connection","options"]);var rq=Nx,Ix=class Ix extends d{constructor(e={}){super(e)}};n(Ix,"FilterExpr"),Ix.key="filter",Ix.requiredArgs=new Set(["this","expression"]),Ix.availableArgs=new Set(["this","expression"]);var Xr=Ix,yx=class yx extends d{constructor(e={}){super(e)}};n(yx,"CheckExpr"),yx.key="check",yx.requiredArgs=new Set(["this"]),yx.availableArgs=new Set(["this"]);var iq=yx,Cx=class Cx extends d{constructor(e={}){super(e)}};n(Cx,"ChangesExpr"),Cx.key="changes",Cx.requiredArgs=new Set(["information"]),Cx.availableArgs=new Set(["information","atBefore","end"]);var Iy=Cx,bx=class bx extends d{constructor(e={}){super(e)}};n(bx,"ConnectExpr"),bx.key="connect",bx.requiredArgs=new Set(["connect"]),bx.availableArgs=new Set(["start","connect","nocycle"]);var yy=bx,Px=class Px extends d{constructor(e={}){super(e)}};n(Px,"CopyParameterExpr"),Px.key="copyParameter",Px.requiredArgs=new Set(["this"]),Px.availableArgs=new Set(["this","expression","expressions"]);var Cy=Px,Lx=class Lx extends d{constructor(e={}){super(e)}};n(Lx,"CredentialsExpr"),Lx.key="credentials",Lx.requiredArgs=new Set,Lx.availableArgs=new Set(["credentials","encryption","storage","iamRole","region"]);var by=Lx,wx=class wx extends d{constructor(e={}){super(e)}};n(wx,"PriorExpr"),wx.key="prior",wx.requiredArgs=new Set(["this"]),wx.availableArgs=new Set(["this"]);var Py=wx,Mx=class Mx extends d{constructor(e={}){super(e)}};n(Mx,"DirectoryExpr"),Mx.key="directory",Mx.requiredArgs=new Set(["this"]),Mx.availableArgs=new Set(["this","local","rowFormat"]);var su=Mx,kx=class kx extends d{constructor(e={}){super(e)}};n(kx,"DirectoryStageExpr"),kx.key="directoryStage",kx.requiredArgs=new Set(["this"]),kx.availableArgs=new Set(["this"]);var nq=kx,Dx=class Dx extends d{constructor(e={}){super(e)}};n(Dx,"ForeignKeyExpr"),Dx.key="foreignKey",Dx.requiredArgs=new Set,Dx.availableArgs=new Set(["expressions","reference","delete","update","options"]);var Ly=Dx,qx=class qx extends d{constructor(e={}){super(e)}};n(qx,"ColumnPrefixExpr"),qx.key="columnPrefix",qx.requiredArgs=new Set(["this","expression"]),qx.availableArgs=new Set(["this","expression"]);var aq=qx,Ux=class Ux extends d{constructor(e={}){super(e)}};n(Ux,"PrimaryKeyExpr"),Ux.key="primaryKey",Ux.requiredArgs=new Set(["expressions"]),Ux.availableArgs=new Set(["this","expressions","options","include"]);var ru=Ux,vx=class vx extends d{constructor(e={}){super(e)}};n(vx,"IntoExpr"),vx.key="into",vx.requiredArgs=new Set,vx.availableArgs=new Set(["this","temporary","unlogged","bulkCollect","expressions"]);var iu=vx,Fx=class Fx extends d{constructor(e={}){super(e)}get name(){return this.args.this?.name||""}get aliasOrName(){return this.args.this?.aliasOrName??""}};n(Fx,"FromExpr"),Fx.key="from",Fx.requiredArgs=new Set(["this"]),Fx.availableArgs=new Set(["this"]);var rt=Fx,Bx=class Bx extends d{constructor(e={}){super(e)}};n(Bx,"HavingExpr"),Bx.key="having",Bx.requiredArgs=new Set(["this"]),Bx.availableArgs=new Set(["this"]);var xs=Bx,$x=class $x extends d{constructor(e={}){super(e)}};n($x,"HintExpr"),$x.key="hint",$x.requiredArgs=new Set(["expressions"]),$x.availableArgs=new Set(["expressions"]);var Ps=$x,Gx=class Gx extends d{constructor(e={}){super(e)}};n(Gx,"JoinHintExpr"),Gx.key="joinHint",Gx.requiredArgs=new Set(["this","expressions"]),Gx.availableArgs=new Set(["this","expressions"]);var gn=Gx,Yx=class Yx extends d{constructor(e={}){super(e)}get outputName(){return this.name}get quoted(){return!!this.args.quoted}};n(Yx,"IdentifierExpr"),Yx.key="identifier",Yx.requiredArgs=new Set(["this"]),Yx.availableArgs=new Set(["this","quoted","global","temporary"]);var F=Yx,Vx=class Vx extends d{constructor(e={}){super(e)}};n(Vx,"OpclassExpr"),Vx.key="opclass",Vx.requiredArgs=new Set(["this","expression"]),Vx.availableArgs=new Set(["this","expression"]);var wy=Vx,Hx=class Hx extends d{constructor(e={}){super(e)}};n(Hx,"IndexExpr"),Hx.key="index",Hx.requiredArgs=new Set,Hx.availableArgs=new Set(["this","table","unique","primary","amp","params"]);var My=Hx,_x=class _x extends d{constructor(e={}){super(e)}};n(_x,"IndexParametersExpr"),_x.key="indexParameters",_x.requiredArgs=new Set,_x.availableArgs=new Set(["using","include","columns","withStorage","partitionBy","tablespace","where","on"]);var ky=_x,Wx=class Wx extends d{constructor(e={}){super(e)}};n(Wx,"ConditionalInsertExpr"),Wx.key="conditionalInsert",Wx.requiredArgs=new Set(["this"]),Wx.availableArgs=new Set(["this","expression","else"]);var Dy=Wx,jx=class jx extends d{constructor(e={}){super(e)}};n(jx,"MultitableInsertsExpr"),jx.key="multitableInserts",jx.requiredArgs=new Set(["expressions","kind","source"]),jx.availableArgs=new Set(["expressions","kind","source"]);var nu=jx,Xx=class Xx extends d{constructor(e={}){super(e)}};n(Xx,"OnConflictExpr"),Xx.key="onConflict",Xx.requiredArgs=new Set,Xx.availableArgs=new Set(["duplicate","expressions","action","conflictKeys","indexPredicate","constraint","where"]);var qy=Xx,Jx=class Jx extends d{constructor(e={}){super(e)}};n(Jx,"OnConditionExpr"),Jx.key="onCondition",Jx.requiredArgs=new Set,Jx.availableArgs=new Set(["error","empty","null"]);var Uy=Jx,zx=class zx extends d{constructor(e={}){super(e)}};n(zx,"ReturningExpr"),zx.key="returning",zx.requiredArgs=new Set(["expressions"]),zx.availableArgs=new Set(["expressions","into"]);var BA=zx,Qx=class Qx extends d{constructor(e={}){super(e)}};n(Qx,"IntroducerExpr"),Qx.key="introducer",Qx.requiredArgs=new Set(["this","expression"]),Qx.availableArgs=new Set(["this","expression"]);var vy=Qx,Zx=class Zx extends d{constructor(e={}){super(e)}};n(Zx,"NationalExpr"),Zx.key="national",Zx.requiredArgs=new Set(["this"]),Zx.availableArgs=new Set(["this"]);var Fy=Zx,Kx=class Kx extends d{constructor(e={}){super(e)}};n(Kx,"LoadDataExpr"),Kx.key="loadData",Kx.requiredArgs=new Set(["this","inpath"]),Kx.availableArgs=new Set(["this","local","overwrite","inpath","partition","inputFormat","serde"]);var By=Kx,ef=class ef extends d{constructor(e={}){super(e)}};n(ef,"PartitionExpr"),ef.key="partition",ef.requiredArgs=new Set(["expressions"]),ef.availableArgs=new Set(["expressions","subpartition"]);var $y=ef,tf=class tf extends d{constructor(e={}){super(e)}};n(tf,"PartitionRangeExpr"),tf.key="partitionRange",tf.requiredArgs=new Set(["this"]),tf.availableArgs=new Set(["this","expression","expressions"]);var oq=tf,sf=class sf extends d{constructor(e={}){super(e)}};n(sf,"PartitionIdExpr"),sf.key="partitionId",sf.requiredArgs=new Set(["this"]),sf.availableArgs=new Set(["this"]);var cq=sf,rf=class rf extends d{constructor(e={}){super(e)}};n(rf,"FetchExpr"),rf.key="fetch",rf.requiredArgs=new Set,rf.availableArgs=new Set(["direction","count","limitOptions"]);var hr=rf,nf=class nf extends d{constructor(e={}){super(e)}};n(nf,"GrantExpr"),nf.key="grant",nf.requiredArgs=new Set(["privileges","securable","principals"]),nf.availableArgs=new Set(["privileges","kind","securable","principals","grantOption"]);var Gy=nf,af=class af extends d{constructor(e={}){super(e)}};n(af,"RevokeExpr"),af.key="revoke",af.requiredArgs=new Set(["privileges","securable","principals"]),af.availableArgs=new Set(["privileges","kind","securable","principals","grantOption","cascade"]);var Yy=af,of=class of extends d{constructor(e={}){super(e)}};n(of,"GroupExpr"),of.key="group",of.requiredArgs=new Set,of.availableArgs=new Set(["expressions","groupingSets","cube","rollup","totals","all"]);var Yr=of,cf=class cf extends d{constructor(e={}){super(e)}};n(cf,"CubeExpr"),cf.key="cube",cf.requiredArgs=new Set,cf.availableArgs=new Set(["expressions"]);var Vy=cf,pf=class pf extends d{constructor(e={}){super(e)}};n(pf,"RollupExpr"),pf.key="rollup",pf.requiredArgs=new Set,pf.availableArgs=new Set(["expressions"]);var OA=pf,lf=class lf extends d{constructor(e={}){super(e)}};n(lf,"GroupingSetsExpr"),lf.key="groupingSets",lf.requiredArgs=new Set(["expressions"]),lf.availableArgs=new Set(["expressions"]);var Hy=lf,uf=class uf extends d{constructor(e={}){super(e)}};n(uf,"LambdaExpr"),uf.key="lambda",uf.requiredArgs=new Set(["this","expressions"]),uf.availableArgs=new Set(["this","expressions","colon"]);var ps=uf,hf=class hf extends d{constructor(e={}){super(e)}};n(hf,"LimitExpr"),hf.key="limit",hf.requiredArgs=new Set(["expression"]),hf.availableArgs=new Set(["this","expression","offset","limitOptions","expressions"]);var Dt=hf,gf=class gf extends d{constructor(e={}){super(e)}};n(gf,"LimitOptionsExpr"),gf.key="limitOptions",gf.requiredArgs=new Set,gf.availableArgs=new Set(["percent","rows","withTies"]);var _y=gf,Ef=class Ef extends d{constructor(e={}){super(e)}on(e,t={}){let{append:s,dialect:r,copy:i,...o}=t,c=Array.from(J(e)),p=FI(c,{instance:this,arg:"on",append:s,dialect:r,copy:i,...o});return p.args.kind==="cross"&&p.setArgKey("kind",void 0),p}using(e,t={}){let{append:s,dialect:r,copy:i,...o}=t,c=Array.from(J(e)),p=Hh(c,{instance:this,arg:"using",append:s,dialect:r,copy:i,...o});return p.args.kind==="cross"&&p.setArgKey("kind",void 0),p}get method(){return this.text("method").toUpperCase()}get kind(){return this.text("kind").toUpperCase()}get side(){return this.text("side").toUpperCase()}get hint(){return this.text("hint").toUpperCase()}get aliasOrName(){return this.args.this?.aliasOrName??""}get isSemiOrAntiJoin(){return this.args.kind!==void 0&&["semi","anti"].includes(this.args.kind)}};n(Ef,"JoinExpr"),Ef.key="join",Ef.requiredArgs=new Set(["this"]),Ef.availableArgs=new Set(["this","on","side","kind","using","method","global","hint","matchCondition","directed","expressions","pivots"]);var fe=Ef,Af=class Af extends d{constructor(e={}){super(e)}};n(Af,"MatchRecognizeMeasureExpr"),Af.key="matchRecognizeMeasure",Af.requiredArgs=new Set(["this"]),Af.availableArgs=new Set(["this","windowFrame"]);var Wy=Af,df=class df extends d{constructor(e={}){super(e)}};n(df,"MatchRecognizeExpr"),df.key="matchRecognize",df.requiredArgs=new Set,df.availableArgs=new Set(["partitionBy","order","measures","rows","after","pattern","define","alias"]);var jy=df,xf=class xf extends d{constructor(e={}){super(e)}};n(xf,"FinalExpr"),xf.key="final",xf.requiredArgs=new Set(["this"]),xf.availableArgs=new Set(["this"]);var _I=xf,ff=class ff extends d{constructor(e={}){super(e)}};n(ff,"OffsetExpr"),ff.key="offset",ff.requiredArgs=new Set(["expression"]),ff.availableArgs=new Set(["this","expression","expressions"]);var Cn=ff,Tf=class Tf extends d{constructor(e={}){super(e)}};n(Tf,"OrderExpr"),Tf.key="order",Tf.requiredArgs=new Set(["expressions"]),Tf.availableArgs=new Set(["this","expressions","siblings"]);var ye=Tf,Sf=class Sf extends d{constructor(e={}){super(e)}};n(Sf,"WithFillExpr"),Sf.key="withFill",Sf.requiredArgs=new Set,Sf.availableArgs=new Set(["from","to","step","interpolate"]);var Xy=Sf,Rf=class Rf extends d{constructor(e={}){super(e)}};n(Rf,"SkipJsonColumnExpr"),Rf.key="skipJsonColumn",Rf.requiredArgs=new Set(["expression"]),Rf.availableArgs=new Set(["regexp","expression"]);var Jy=Rf,Of=class Of extends d{constructor(e={}){super(e)}get name(){return this.args.this?.name||""}};n(Of,"OrderedExpr"),Of.key="ordered",Of.requiredArgs=new Set(["this","nullsFirst"]),Of.availableArgs=new Set(["this","desc","nullsFirst","withFill"]);var hs=Of,mf=class mf extends d{constructor(e={}){super(e)}};n(mf,"PropertyExpr"),mf.key="property",mf.requiredArgs=new Set(["this","value"]),mf.availableArgs=new Set(["this","value"]);var w=mf,Nf=class Nf extends d{constructor(e={}){super(e)}};n(Nf,"GrantPrivilegeExpr"),Nf.key="grantPrivilege",Nf.requiredArgs=new Set(["this"]),Nf.availableArgs=new Set(["this","expressions"]);var zy=Nf,If=class If extends d{constructor(e={}){super(e)}};n(If,"GrantPrincipalExpr"),If.key="grantPrincipal",If.requiredArgs=new Set(["this"]),If.availableArgs=new Set(["this","kind"]);var Qy=If,yf=class yf extends d{constructor(e={}){super(e)}};n(yf,"AllowedValuesPropertyExpr"),yf.key="allowedValuesProperty",yf.requiredArgs=new Set(["expressions"]),yf.availableArgs=new Set(["expressions"]);var Vn=yf,Cf=class Cf extends d{constructor(e={}){super(e)}};n(Cf,"PartitionByRangePropertyDynamicExpr"),Cf.key="partitionByRangePropertyDynamic",Cf.requiredArgs=new Set(["start","end","every"]),Cf.availableArgs=new Set(["this","start","end","every"]);var pq=Cf,bf=class bf extends d{constructor(e={}){super(e)}};n(bf,"RollupIndexExpr"),bf.key="rollupIndex",bf.requiredArgs=new Set(["this","expressions"]),bf.availableArgs=new Set(["this","expressions","fromIndex","properties"]);var lq=bf,Pf=class Pf extends d{constructor(e={}){super(e)}};n(Pf,"PartitionListExpr"),Pf.key="partitionList",Pf.requiredArgs=new Set(["this","expressions"]),Pf.availableArgs=new Set(["this","expressions"]);var uq=Pf,Lf=class Lf extends d{constructor(e={}){super(e)}};n(Lf,"PartitionBoundSpecExpr"),Lf.key="partitionBoundSpec",Lf.requiredArgs=new Set,Lf.availableArgs=new Set(["this","expression","fromExpressions","toExpressions"]);var au=Lf,wf=class wf extends d{constructor(e={}){super(e)}};n(wf,"QueryTransformExpr"),wf.key="queryTransform",wf.requiredArgs=new Set(["expressions","commandScript"]),wf.availableArgs=new Set(["expressions","commandScript","schema","rowFormatBefore","recordWriter","rowFormatAfter","recordReader"]);var hq=wf,Mf=class Mf extends d{constructor(e={}){super(e)}};n(Mf,"SemanticViewExpr"),Mf.key="semanticView",Mf.requiredArgs=new Set(["this"]),Mf.availableArgs=new Set(["this","metrics","dimensions","facts","where"]);var gq=Mf,kf=class kf extends d{constructor(e={}){super(e)}};n(kf,"LocationExpr"),kf.key="location",kf.requiredArgs=new Set,kf.availableArgs=new Set;var Eq=kf,Df=class Df extends d{constructor(e={}){super(e)}};n(Df,"QualifyExpr"),Df.key="qualify",Df.requiredArgs=new Set(["this"]),Df.availableArgs=new Set(["this"]);var Xs=Df,qf=class qf extends d{constructor(e={}){super(e)}};n(qf,"InputOutputFormatExpr"),qf.key="inputOutputFormat",qf.requiredArgs=new Set,qf.availableArgs=new Set(["inputFormat","outputFormat"]);var Zy=qf,Uf=class Uf extends d{constructor(e={}){super(e)}};n(Uf,"ReturnExpr"),Uf.key="return",Uf.requiredArgs=new Set(["this"]),Uf.availableArgs=new Set(["this"]);var ou=Uf,vf=class vf extends d{constructor(e={}){super(e)}};n(vf,"ReferenceExpr"),vf.key="reference",vf.requiredArgs=new Set(["this"]),vf.availableArgs=new Set(["this","expressions","options"]);var Ky=vf,Ff=class Ff extends d{constructor(e={}){super(e)}in(e,t,s={}){let{copy:r=!0,unnest:i,...o}=s;return new lt({this:$e(this,r),expressions:e?.map(c=>ht(c,{copy:r})),query:t?j(t,{...o,copy:r}):void 0,unnest:i?new Ee({expressions:Array.from(J(i)).map(c=>j(c,{...o,copy:r}))}):void 0})}};n(Ff,"TupleExpr"),Ff.key="tuple",Ff.requiredArgs=new Set,Ff.availableArgs=new Set(["expressions"]);var Ze=Ff,Ij={match:!1,laterals:!1,joins:!1,connect:!1,pivots:!1,prewhere:!1,where:!1,group:!1,having:!1,qualify:!1,windows:!1,distribute:!1,sort:!1,cluster:!1,order:!1,limit:!1,offset:!1,locks:!1,sample:!1,settings:!1,format:!1,options:!1},Bf=class Bf extends d{constructor(e={}){super(e)}};n(Bf,"QueryOptionExpr"),Bf.key="queryOption",Bf.requiredArgs=new Set(["this"]),Bf.availableArgs=new Set(["this","expression"]);var Aq=Bf,$f=class $f extends d{constructor(e={}){super(e)}};n($f,"WithTableHintExpr"),$f.key="withTableHint",$f.requiredArgs=new Set(["expressions"]),$f.availableArgs=new Set(["expressions"]);var cu=$f,Gf=class Gf extends d{constructor(e={}){super(e)}};n(Gf,"IndexTableHintExpr"),Gf.key="indexTableHint",Gf.requiredArgs=new Set(["this"]),Gf.availableArgs=new Set(["this","expressions","target"]);var eC=Gf,Yf=class Yf extends d{constructor(e={}){super(e)}};n(Yf,"HistoricalDataExpr"),Yf.key="historicalData",Yf.requiredArgs=new Set(["this","kind","expression"]),Yf.availableArgs=new Set(["this","kind","expression"]);var tC=Yf,Vf=class Vf extends d{constructor(e={}){super(e)}};n(Vf,"PutExpr"),Vf.key="put",Vf.requiredArgs=new Set(["this","target"]),Vf.availableArgs=new Set(["this","target","properties"]);var XA=Vf,Hf=class Hf extends d{constructor(e={}){super(e)}};n(Hf,"GetExpr"),Hf.key="get",Hf.requiredArgs=new Set(["this","target"]),Hf.availableArgs=new Set(["this","target","properties"]);var bb=Hf,_f=class _f extends d{constructor(e={}){super(e)}get name(){let e=this.args.this;return!e||e instanceof E?"":e instanceof d?e.name||"":e.toString()}get db(){return this.text("db")}get catalog(){return this.text("catalog")}get selects(){return[]}get namedSelects(){return[]}get parts(){let e=[];for(let t of["catalog","db","this"]){let s=this.args[t];s instanceof ge?e.push(...s.flatten()):s instanceof d&&e.push(s)}return e}toColumn(e={}){let{copy:t=!0}=e,s=this.parts,r=s[s.length-1],i;if(r instanceof F){let c=s.slice(0,4).reverse(),p=s.slice(4);i=$n({col:c[0],table:c[1],db:c[2],catalog:c[3]},{fields:p,copy:t})}else i=r;let o=this.args.alias;if(o){let c=o.args.this,p=typeof c=="string"||Y(c,F)?c:void 0;i=Be(i,p,{copy:t})}return i}};n(_f,"TableExpr"),_f.key="table",_f.requiredArgs=new Set,_f.availableArgs=new Set(["this","alias","db","catalog","laterals","joins","pivots","hints","systemTime","version","format","pattern","ordinality","when","only","partition","changes","rowsFrom","sample","indexed"]);var W=_f,Wf=class Wf extends d{constructor(e={}){super(e)}};n(Wf,"VarExpr"),Wf.key="var",Wf.requiredArgs=new Set(["this"]),Wf.availableArgs=new Set(["this"]);var Ve=Wf,jf=class jf extends d{constructor(e={}){super(e)}};n(jf,"VersionExpr"),jf.key="version",jf.requiredArgs=new Set(["this","kind"]),jf.availableArgs=new Set(["this","kind","expression"]);var sC=jf,Xf=class Xf extends d{constructor(e={}){super(e)}};n(Xf,"SchemaExpr"),Xf.key="schema",Xf.requiredArgs=new Set,Xf.availableArgs=new Set(["this","expressions"]);var Rt=Xf,Jf=class Jf extends d{constructor(e={}){super(e)}};n(Jf,"LockExpr"),Jf.key="lock",Jf.requiredArgs=new Set(["update"]),Jf.availableArgs=new Set(["update","expressions","wait","key"]);var $A=Jf,zf=class zf extends d{constructor(e={}){super(e)}};n(zf,"TableSampleExpr"),zf.key="tableSample",zf.requiredArgs=new Set,zf.availableArgs=new Set(["expressions","method","bucketNumerator","bucketDenominator","bucketField","percent","rows","size","seed"]);var rC=zf,rw=class rw extends d{constructor(e={}){super(e)}get this(){return this.args.this}};n(rw,"TagExpr"),rw.key="tag",rw.availableArgs=new Set(["this","prefix","postfix"]);var dq=rw,Qf=class Qf extends d{constructor(e={}){super(e)}get unpivot(){return!!this.args.unpivot}get fields(){return this.args.fields||[]}};n(Qf,"PivotExpr"),Qf.key="pivot",Qf.requiredArgs=new Set([]),Qf.availableArgs=new Set(["this","alias","expressions","fields","unpivot","using","group","columns","includeNulls","defaultOnNull","into","with"]);var Ln=Qf,Zf=class Zf extends d{constructor(e={}){super(e)}};n(Zf,"UnpivotColumnsExpr"),Zf.key="unpivotColumns",Zf.requiredArgs=new Set(["this","expressions"]),Zf.availableArgs=new Set(["this","expressions"]);var iC=Zf,Kf=class Kf extends d{constructor(e={}){super(e)}};n(Kf,"WindowSpecExpr"),Kf.key="windowSpec",Kf.requiredArgs=new Set,Kf.availableArgs=new Set(["kind","start","startSide","end","endSide","exclude"]);var pu=Kf,eT=class eT extends d{constructor(e={}){super(e)}};n(eT,"PreWhereExpr"),eT.key="preWhere",eT.requiredArgs=new Set(["this"]),eT.availableArgs=new Set(["this"]);var nC=eT,tT=class tT extends d{constructor(e={}){super(e)}};n(tT,"WhereExpr"),tT.key="where",tT.requiredArgs=new Set(["this"]),tT.availableArgs=new Set(["this"]);var St=tT,sT=class sT extends d{constructor(e={}){super(e)}get name(){return"*"}get outputName(){return this.name}};n(sT,"StarExpr"),sT.key="star",sT.requiredArgs=new Set,sT.availableArgs=new Set(["except","replace","rename"]);var Ne=sT,rT=class rT extends d{constructor(e={}){super(e)}get name(){return this.args.this?.name??""}};n(rT,"DataTypeParamExpr"),rT.key="dataTypeParam",rT.requiredArgs=new Set(["this"]),rT.availableArgs=new Set(["this","expression"]);var Jr=rT,me=class me extends d{constructor(e={}){super(e)}static build(e,t={}){let{udt:s=!1,copy:r=!0,dialect:i,...o}=t,c;if(typeof e=="string"){if(e==="unknown")return new me({...o,this:"unknown"});if(Object.values(At).includes(e))return new me({...o,this:e});try{c=mD(e,{read:i,into:me,errorLevel:0})}catch(h){if(h instanceof Ke){if(s)return new me({this:"user-defined",kind:e,...o});throw h}else throw h}}else{if((e instanceof F||e instanceof ge)&&s)return new me({...o,this:"user-defined",kind:e});if(e instanceof me)return $e(e,r);throw new Error(`Invalid data type: ${typeof e}. Expected string, DataTypeExprKind, or DataTypeExpr`)}for(let[p,u]of Object.entries(o))c?.setArgKey(p,u);return c}toString(){let e=this.args.this;return e===void 0?super.toString():e instanceof d?e.toString():String(e)}isType(e,t){let s=t?.checkNullable??!1,r=this.args.nullable;for(let i of J(e)){let o=me.build(i,{copy:!1,udt:!0}),c=o?.args.nullable,p;if(o?.args.expressions||s&&(r||c)||this.args.this==="user-defined"||o?.args.this==="user-defined"?p=this.equals(o):p=this.args.this===o?.args.this,p)return!0}return!1}};n(me,"DataTypeExpr"),me.key="dataType",me.requiredArgs=new Set(["this"]),me.availableArgs=new Set(["this","expressions","nested","values","prefix","kind","nullable"]),me.STRUCT_TYPES=new Set(["file","nested","object","struct","union"]),me.ARRAY_TYPES=new Set(["array","list"]),me.NESTED_TYPES=new Set([...me.STRUCT_TYPES,...me.ARRAY_TYPES,"map"]),me.TEXT_TYPES=new Set(["char","nchar","nvarchar","text","varchar","name"]),me.SIGNED_INTEGER_TYPES=new Set(["bigint","int","int128","int256","mediumint","smallint","tinyint"]),me.UNSIGNED_INTEGER_TYPES=new Set(["ubigint","uint","uint128","uint256","umediumint","usmallint","utinyint"]),me.INTEGER_TYPES=new Set([...me.SIGNED_INTEGER_TYPES,...me.UNSIGNED_INTEGER_TYPES,"bit"]),me.FLOAT_TYPES=new Set(["double","float"]),me.REAL_TYPES=new Set([...me.FLOAT_TYPES,"bigdecimal","decimal","decimal32","decimal64","decimal128","decimal256","decfloat","money","smallmoney","udecimal","udouble"]),me.NUMERIC_TYPES=new Set([...me.INTEGER_TYPES,...me.REAL_TYPES]),me.TEMPORAL_TYPES=new Set(["date","date32","datetime","datetime2","datetime64","smalldatetime","time","timestamp","timestampntz","timestampltz","timestamptz","timestampMs","timestampNs","timestampS","timetz"]);var N=me,iT=class iT extends d{constructor(e={}){super(e)}};n(iT,"TypeExpr"),iT.key="type",iT.requiredArgs=new Set,iT.availableArgs=new Set;var xq=iT,nT=class nT extends d{constructor(e={}){super(e)}};n(nT,"CommandExpr"),nT.key="command",nT.requiredArgs=new Set(["this"]),nT.availableArgs=new Set(["this","expression"]);var $r=nT,aT=class aT extends d{constructor(e={}){super(e)}};n(aT,"TransactionExpr"),aT.key="transaction",aT.requiredArgs=new Set,aT.availableArgs=new Set(["this","modes","mark"]);var aC=aT,oT=class oT extends d{constructor(e={}){super(e)}};n(oT,"CommitExpr"),oT.key="commit",oT.requiredArgs=new Set,oT.availableArgs=new Set(["chain","this","durability"]);var oC=oT,cT=class cT extends d{constructor(e={}){super(e)}};n(cT,"RollbackExpr"),cT.key="rollback",cT.requiredArgs=new Set,cT.availableArgs=new Set(["savepoint","this"]);var cC=cT,pT=class pT extends d{constructor(e={}){super(e)}get kind(){let e=this.args.kind;return e?e.toUpperCase():void 0}get actions(){return this.args.actions||[]}};n(pT,"AlterExpr"),pT.key="alter",pT.requiredArgs=new Set(["kind","actions"]),pT.availableArgs=new Set(["this","kind","actions","exists","only","options","cluster","notValid","check","cascade","iceberg"]);var lu=pT,lT=class lT extends d{constructor(e={}){super(e)}};n(lT,"AlterSessionExpr"),lT.key="alterSession",lT.requiredArgs=new Set(["expressions"]),lT.availableArgs=new Set(["expressions","unset"]);var mA=lT,uT=class uT extends d{constructor(e={}){super(e)}};n(uT,"AnalyzeExpr"),uT.key="analyze",uT.requiredArgs=new Set,uT.availableArgs=new Set(["kind","this","options","mode","partition","expression","properties"]);var NA=uT,hT=class hT extends d{constructor(e={}){super(e)}};n(hT,"AnalyzeStatisticsExpr"),hT.key="analyzeStatistics",hT.requiredArgs=new Set(["kind"]),hT.availableArgs=new Set(["kind","option","this","expressions"]);var pC=hT,gT=class gT extends d{constructor(e={}){super(e)}};n(gT,"AnalyzeHistogramExpr"),gT.key="analyzeHistogram",gT.requiredArgs=new Set(["this","expressions"]),gT.availableArgs=new Set(["this","expressions","expression","updateOptions"]);var lC=gT,ET=class ET extends d{constructor(e={}){super(e)}};n(ET,"AnalyzeSampleExpr"),ET.key="analyzeSample",ET.requiredArgs=new Set(["kind","sample"]),ET.availableArgs=new Set(["kind","sample"]);var uC=ET,AT=class AT extends d{constructor(e={}){super(e)}};n(AT,"AnalyzeListChainedRowsExpr"),AT.key="analyzeListChainedRows",AT.requiredArgs=new Set,AT.availableArgs=new Set(["expression"]);var hC=AT,dT=class dT extends d{constructor(e={}){super(e)}};n(dT,"AnalyzeDeleteExpr"),dT.key="analyzeDelete",dT.requiredArgs=new Set,dT.availableArgs=new Set(["kind"]);var gC=dT,xT=class xT extends d{constructor(e={}){super(e)}};n(xT,"AnalyzeWithExpr"),xT.key="analyzeWith",xT.requiredArgs=new Set(["expressions"]),xT.availableArgs=new Set(["expressions"]);var uu=xT,fT=class fT extends d{constructor(e={}){super(e)}};n(fT,"AnalyzeValidateExpr"),fT.key="analyzeValidate",fT.requiredArgs=new Set(["kind"]),fT.availableArgs=new Set(["kind","this","expression"]);var EC=fT,TT=class TT extends d{constructor(e={}){super(e)}};n(TT,"AnalyzeColumnsExpr"),TT.key="analyzeColumns",TT.requiredArgs=new Set(["this"]),TT.availableArgs=new Set(["this"]);var hu=TT,ST=class ST extends d{constructor(e={}){super(e)}};n(ST,"UsingDataExpr"),ST.key="usingData",ST.requiredArgs=new Set(["this"]),ST.availableArgs=new Set(["this"]);var gu=ST,RT=class RT extends d{constructor(e={}){super(e)}};n(RT,"AddConstraintExpr"),RT.key="addConstraint",RT.requiredArgs=new Set(["expressions"]),RT.availableArgs=new Set(["expressions"]);var IA=RT,OT=class OT extends d{constructor(e={}){super(e)}};n(OT,"AddPartitionExpr"),OT.key="addPartition",OT.requiredArgs=new Set(["this"]),OT.availableArgs=new Set(["this","exists","location"]);var AC=OT,mT=class mT extends d{constructor(e={}){super(e)}};n(mT,"AttachOptionExpr"),mT.key="attachOption",mT.requiredArgs=new Set(["this"]),mT.availableArgs=new Set(["this","expression"]);var fq=mT,NT=class NT extends d{constructor(e={}){super(e)}};n(NT,"DropPartitionExpr"),NT.key="dropPartition",NT.requiredArgs=new Set(["expressions"]),NT.availableArgs=new Set(["expressions","exists"]);var dC=NT,IT=class IT extends d{constructor(e={}){super(e)}};n(IT,"ReplacePartitionExpr"),IT.key="replacePartition",IT.requiredArgs=new Set(["expression","source"]),IT.availableArgs=new Set(["expression","source"]);var Tq=IT,yT=class yT extends d{constructor(e={}){super(e)}get outputName(){return typeof this.args.alias=="string"?this.args.alias:this.args.alias?.name??""}};n(yT,"AliasExpr"),yT.key="alias",yT.requiredArgs=new Set(["this"]),yT.availableArgs=new Set(["this","alias"]);var Oe=yT,CT=class CT extends d{constructor(e={}){super(e)}};n(CT,"PivotAnyExpr"),CT.key="pivotAny",CT.requiredArgs=new Set,CT.availableArgs=new Set(["this"]);var wn=CT,bT=class bT extends d{constructor(e={}){super(e)}get aliases(){return this.args.expressions??[]}};n(bT,"AliasesExpr"),bT.key="aliases",bT.requiredArgs=new Set(["this","expressions"]),bT.availableArgs=new Set(["this","expressions"]);var Hn=bT,PT=class PT extends d{constructor(e={}){super(e)}};n(PT,"AtIndexExpr"),PT.key="atIndex",PT.requiredArgs=new Set(["this","expression"]),PT.availableArgs=new Set(["this","expression"]);var xC=PT,LT=class LT extends d{constructor(e={}){super(e)}};n(LT,"AtTimeZoneExpr"),LT.key="atTimeZone",LT.requiredArgs=new Set(["this","zone"]),LT.availableArgs=new Set(["this","zone"]);var gs=LT,wT=class wT extends d{constructor(e={}){super(e)}};n(wT,"FromTimeZoneExpr"),wT.key="fromTimeZone",wT.requiredArgs=new Set(["this","zone"]),wT.availableArgs=new Set(["this","zone"]);var Sq=wT,MT=class MT extends d{constructor(e={}){super(e)}};n(MT,"FormatPhraseExpr"),MT.key="formatPhrase",MT.requiredArgs=new Set(["this","format"]),MT.availableArgs=new Set(["this","format"]);var Rq=MT,kT=class kT extends d{constructor(e={}){super(e)}};n(kT,"DistinctExpr"),kT.key="distinct",kT.requiredArgs=new Set,kT.availableArgs=new Set(["expressions","on"]);var et=kT,DT=class DT extends d{constructor(e={}){super(e)}};n(DT,"ForInExpr"),DT.key="forIn",DT.requiredArgs=new Set(["this","expression"]),DT.availableArgs=new Set(["this","expression"]);var Oq=DT,ui=class ui extends d{static isVarLike(e){return e instanceof Ve||e instanceof $||e instanceof I}static initTimeArgs(e){let t=e.unit;if(t&&ui.isVarLike(t)&&!(t instanceof $&&t.parts.length!==1))e.unit=new Ve({this:(ui.UNABBREVIATED_UNIT_NAME[t.name.toUpperCase()]||t.name).toUpperCase()});else if(t instanceof Ad){let s=t.args.this;s&&t.setArgKey("this",new Ve({this:s.name.toUpperCase()}))}return e}constructor(e={}){super(ui.initTimeArgs(e))}get unit(){return this.args.unit}};n(ui,"TimeUnitExpr"),ui.key="timeUnit",ui.availableArgs=new Set(["unit"]),ui.UNABBREVIATED_UNIT_NAME={D:"DAY",H:"HOUR",M:"MINUTE",MS:"MILLISECOND",NS:"NANOSECOND",Q:"QUARTER",S:"SECOND",US:"MICROSECOND",W:"WEEK",Y:"YEAR"};var te=ui,qT=class qT extends d{constructor(e={}){super(e)}};n(qT,"IgnoreNullsExpr"),qT.key="ignoreNulls",qT.requiredArgs=new Set(["this"]),qT.availableArgs=new Set(["this"]);var yA=qT,UT=class UT extends d{constructor(e={}){super(e)}};n(UT,"RespectNullsExpr"),UT.key="respectNulls",UT.requiredArgs=new Set(["this"]),UT.availableArgs=new Set(["this"]);var CA=UT,vT=class vT extends d{constructor(e={}){super(e)}};n(vT,"HavingMaxExpr"),vT.key="havingMax",vT.requiredArgs=new Set(["this","expression","max"]),vT.availableArgs=new Set(["this","expression","max"]);var gr=vT,FT=class FT extends d{constructor(e={}){super(e)}};n(FT,"TranslateCharactersExpr"),FT.key="translateCharacters",FT.requiredArgs=new Set(["this","expression"]),FT.availableArgs=new Set(["this","expression","withError"]);var mq=FT,BT=class BT extends d{constructor(e={}){super(e)}};n(BT,"PositionalColumnExpr"),BT.key="positionalColumn",BT.requiredArgs=new Set(["this"]),BT.availableArgs=new Set(["this"]);var Pb=BT,$T=class $T extends d{constructor(e={}){super(e)}};n($T,"OverflowTruncateBehaviorExpr"),$T.key="overflowTruncateBehavior",$T.requiredArgs=new Set(["withCount"]),$T.availableArgs=new Set(["this","withCount"]);var fC=$T,GT=class GT extends d{constructor(e={}){super(e)}};n(GT,"JsonExpr"),GT.key="json",GT.requiredArgs=new Set,GT.availableArgs=new Set(["this","with","unique"]);var TC=GT,YT=class YT extends d{constructor(e={}){super(e)}get outputName(){let t=this.args.expressions?.[this.args.expressions.length-1]?.args.this;return typeof t=="string"?t:""}};n(YT,"JsonPathExpr"),YT.key="jsonPath",YT.requiredArgs=new Set(["expressions"]),YT.availableArgs=new Set(["expressions","escape"]);var Er=YT,VT=class VT extends d{constructor(e={}){super(e)}};n(VT,"JsonPathPartExpr"),VT.key="jsonPathPart",VT.requiredArgs=new Set,VT.availableArgs=new Set;var Ut=VT,HT=class HT extends d{constructor(e={}){super(e)}};n(HT,"FormatJsonExpr"),HT.key="formatJson",HT.requiredArgs=new Set(["this"]),HT.availableArgs=new Set(["this"]);var SC=HT,_T=class _T extends d{constructor(e={}){super(e)}};n(_T,"JsonKeyValueExpr"),_T.key="jsonKeyValue",_T.requiredArgs=new Set(["this","expression"]),_T.availableArgs=new Set(["this","expression"]);var RC=_T,WT=class WT extends d{constructor(e={}){super(e)}};n(WT,"JsonColumnDefExpr"),WT.key="jsonColumnDef",WT.requiredArgs=new Set,WT.availableArgs=new Set(["this","kind","path","nestedSchema","ordinality"]);var OC=WT,jT=class jT extends d{constructor(e={}){super(e)}};n(jT,"JsonSchemaExpr"),jT.key="jsonSchema",jT.requiredArgs=new Set(["expressions"]),jT.availableArgs=new Set(["expressions"]);var mC=jT,XT=class XT extends d{constructor(e={}){super(e)}};n(XT,"JsonValueExpr"),XT.key="jsonValue",XT.requiredArgs=new Set(["this","path"]),XT.availableArgs=new Set(["this","path","returning","onCondition"]);var NC=XT,JT=class JT extends d{constructor(e={}){super(e)}};n(JT,"OpenJsonColumnDefExpr"),JT.key="openJsonColumnDef",JT.requiredArgs=new Set(["this","kind"]),JT.availableArgs=new Set(["this","kind","path","asJson"]);var IC=JT,zT=class zT extends d{constructor(e={}){super(e)}};n(zT,"JsonExtractQuoteExpr"),zT.key="jsonExtractQuote",zT.requiredArgs=new Set(["option"]),zT.availableArgs=new Set(["option","scalar"]);var Nq=zT,QT=class QT extends d{constructor(e={}){super(e)}};n(QT,"ScopeResolutionExpr"),QT.key="scopeResolution",QT.requiredArgs=new Set(["expression"]),QT.availableArgs=new Set(["this","expression"]);var bA=QT,ZT=class ZT extends d{constructor(e={}){super(e)}};n(ZT,"SliceExpr"),ZT.key="slice",ZT.requiredArgs=new Set,ZT.availableArgs=new Set(["this","expression","step"]);var On=ZT,KT=class KT extends d{constructor(e={}){super(e)}};n(KT,"StreamExpr"),KT.key="stream",KT.requiredArgs=new Set(["this"]),KT.availableArgs=new Set(["this"]);var Eu=KT,eS=class eS extends d{constructor(e={}){super(e)}};n(eS,"ModelAttributeExpr"),eS.key="modelAttribute",eS.requiredArgs=new Set(["this","expression"]),eS.availableArgs=new Set(["this","expression"]);var Iq=eS,tS=class tS extends d{constructor(e={}){super(e)}};n(tS,"WeekStartExpr"),tS.key="weekStart",tS.requiredArgs=new Set(["this"]),tS.availableArgs=new Set(["this"]);var zL=tS,sS=class sS extends d{constructor(e={}){super(e)}};n(sS,"XmlNamespaceExpr"),sS.key="xmlNamespace",sS.requiredArgs=new Set(["this"]),sS.availableArgs=new Set(["this"]);var yC=sS,rS=class rS extends d{constructor(e={}){super(e)}};n(rS,"XmlKeyValueOptionExpr"),rS.key="xmlKeyValueOption",rS.requiredArgs=new Set(["this"]),rS.availableArgs=new Set(["this","expression"]);var yq=rS,iS=class iS extends d{constructor(e={}){super(e)}};n(iS,"UseExpr"),iS.key="use",iS.requiredArgs=new Set,iS.availableArgs=new Set(["this","expressions","kind"]);var CC=iS,nS=class nS extends d{constructor(e={}){super(e)}};n(nS,"WhenExpr"),nS.key="when",nS.requiredArgs=new Set(["matched","then"]),nS.availableArgs=new Set(["matched","source","condition","then"]);var _n=nS,aS=class aS extends d{constructor(e={}){super(e)}};n(aS,"WhensExpr"),aS.key="whens",aS.requiredArgs=new Set(["expressions"]),aS.availableArgs=new Set(["expressions"]);var Au=aS,oS=class oS extends d{constructor(e={}){super(e)}};n(oS,"SemicolonExpr"),oS.key="semicolon",oS.requiredArgs=new Set,oS.availableArgs=new Set;var bC=oS,cS=class cS extends d{constructor(e={}){super(e)}};n(cS,"TableColumnExpr"),cS.key="tableColumn",cS.requiredArgs=new Set(["this"]),cS.availableArgs=new Set(["this"]);var Gl=cS,pS=class pS extends d{constructor(e={}){super(e)}};n(pS,"VariadicExpr"),pS.key="variadic",pS.requiredArgs=new Set(["this"]),pS.availableArgs=new Set(["this"]);var Lb=pS,lS=class lS extends d{constructor(e={}){super(e)}};n(lS,"StoredProcedureExpr"),lS.key="storedProcedure",lS.requiredArgs=new Set(["this"]),lS.availableArgs=new Set(["this","expressions","wrapped"]);var Cq=lS,uS=class uS extends d{constructor(e={}){super(e)}};n(uS,"BlockExpr"),uS.key="block",uS.requiredArgs=new Set(["expressions"]),uS.availableArgs=new Set(["expressions"]);var GA=uS,hS=class hS extends d{constructor(e={}){super(e)}};n(hS,"IfBlockExpr"),hS.key="ifBlock",hS.requiredArgs=new Set(["this","true"]),hS.availableArgs=new Set(["this","true","false"]);var bq=hS,gS=class gS extends d{constructor(e={}){super(e)}};n(gS,"WhileBlockExpr"),gS.key="whileBlock",gS.requiredArgs=new Set(["this","body"]),gS.availableArgs=new Set(["this","body"]);var PC=gS,ES=class ES extends d{constructor(e={}){super(e)}};n(ES,"EndStatementExpr"),ES.key="endStatement",ES.requiredArgs=new Set,ES.availableArgs=new Set;var du=ES,AS=class AS extends d{constructor(e={}){super(e)}get name(){return this.args.this?.args.this?.toString?.()??""}};n(AS,"ExecuteExpr"),AS.key="execute",AS.requiredArgs=new Set(["this"]),AS.availableArgs=new Set(["this","expressions"]);var BM=AS,jM=class jM extends BM{};n(jM,"ExecuteSqlExpr"),jM.key="executeSql";var Pq=jM,dS=class dS extends An{constructor(e={}){super(e)}};n(dS,"CteExpr"),dS.key="cte",dS.requiredArgs=new Set(["this","alias"]),dS.availableArgs=new Set(["this","alias","scalar","materialized","keyExpressions"]);var Bt=dS,XM=class XM extends be{constructor(e={}){super(e)}};n(XM,"BitStringExpr"),XM.key="bitString";var LC=XM,iw=class iw extends be{constructor(e={}){super(e)}};n(iw,"HexStringExpr"),iw.key="hexString",iw.availableArgs=new Set(["this","isInteger"]);var xu=iw,nw=class nw extends be{constructor(e={}){super(e)}};n(nw,"ByteStringExpr"),nw.key="byteString",nw.availableArgs=new Set(["this","isBytes"]);var wC=nw,JM=class JM extends be{constructor(e={}){super(e)}};n(JM,"RawStringExpr"),JM.key="rawString";var Mn=JM,aw=class aw extends be{constructor(e={}){super(e)}};n(aw,"UnicodeStringExpr"),aw.key="unicodeString",aw.availableArgs=new Set(["this","escape"]);var MC=aw,xS=class xS extends be{constructor(e={}){super(e)}get table(){return this.text("table")}get db(){return this.text("db")}get catalog(){return this.text("catalog")}get outputName(){return this.name}get parts(){let e=[];for(let t of["catalog","db","table","this"]){let s=this.args[t];s&&e.push(s)}return e}toDot(e={}){let{includeDots:t=!0}=e,s=this.parts,r=this.parent;if(t)for(;r instanceof ge&&r.args.expression!==void 0;)s.push(r.args.expression),r=r.parent;return 1<s.length?ge.build(s.map(i=>i.copy())):s[0]}};n(xS,"ColumnExpr"),xS.key="column",xS.requiredArgs=new Set(["this"]),xS.availableArgs=new Set(["this","table","db","catalog","joinMark"]);var $=xS,zM=class zM extends ${constructor(e={}){super(e)}};n(zM,"PseudocolumnExpr"),zM.key="pseudocolumn";var WI=zM,QM=class QM extends ce{constructor(e={}){super(e)}};n(QM,"AutoIncrementColumnConstraintExpr"),QM.key="autoIncrementColumnConstraint";var kC=QM,fS=class fS extends yn{constructor(e={}){super(e)}};n(fS,"ZeroFillColumnConstraintExpr"),fS.key="zeroFillColumnConstraint",fS.requiredArgs=new Set,fS.availableArgs=new Set;var wb=fS,TS=class TS extends ce{constructor(e={}){super(e)}};n(TS,"PeriodForSystemTimeConstraintExpr"),TS.key="periodForSystemTimeConstraint",TS.requiredArgs=new Set(["this","expression"]),TS.availableArgs=new Set(["this","expression"]);var DC=TS,SS=class SS extends ce{constructor(e={}){super(e)}};n(SS,"CaseSpecificColumnConstraintExpr"),SS.key="caseSpecificColumnConstraint",SS.requiredArgs=new Set(["not"]),SS.availableArgs=new Set(["not"]);var kn=SS,ZM=class ZM extends ce{constructor(e={}){super(e)}};n(ZM,"CharacterSetColumnConstraintExpr"),ZM.key="characterSetColumnConstraint";var fu=ZM,ow=class ow extends ce{constructor(e={}){super(e)}};n(ow,"CheckColumnConstraintExpr"),ow.key="checkColumnConstraint",ow.availableArgs=new Set(["this","enforced"]);var qC=ow,cw=class cw extends ce{constructor(e={}){super(e)}};n(cw,"AssumeColumnConstraintExpr"),cw.key="assumeColumnConstraint",cw.availableArgs=new Set(["this"]);var Mb=cw,KM=class KM extends ce{constructor(e={}){super(e)}};n(KM,"ClusteredColumnConstraintExpr"),KM.key="clusteredColumnConstraint";var Tu=KM,ek=class ek extends ce{constructor(e={}){super(e)}};n(ek,"CollateColumnConstraintExpr"),ek.key="collateColumnConstraint";var Su=ek,tk=class tk extends ce{constructor(e={}){super(e)}};n(tk,"CommentColumnConstraintExpr"),tk.key="commentColumnConstraint";var Ru=tk,pw=class pw extends ce{constructor(e={}){super(e)}};n(pw,"CompressColumnConstraintExpr"),pw.key="compressColumnConstraint",pw.requiredArgs=new Set;var PA=pw,sk=class sk extends ce{constructor(e={}){super(e)}};n(sk,"DateFormatColumnConstraintExpr"),sk.key="dateFormatColumnConstraint";var Ou=sk,rk=class rk extends ce{constructor(e={}){super(e)}};n(rk,"DefaultColumnConstraintExpr"),rk.key="defaultColumnConstraint";var mu=rk,ik=class ik extends ce{constructor(e={}){super(e)}};n(ik,"EncodeColumnConstraintExpr"),ik.key="encodeColumnConstraint";var Nu=ik,nk=class nk extends ce{constructor(e={}){super(e)}};n(nk,"ExcludeColumnConstraintExpr"),nk.key="excludeColumnConstraint";var Iu=nk,lw=class lw extends ce{constructor(e={}){super(e)}};n(lw,"EphemeralColumnConstraintExpr"),lw.key="ephemeralColumnConstraint",lw.requiredArgs=new Set;var yu=lw,uw=class uw extends ce{constructor(e={}){super(e)}};n(uw,"GeneratedAsIdentityColumnConstraintExpr"),uw.key="generatedAsIdentityColumnConstraint",uw.availableArgs=new Set(["this","expression","onNull","start","increment","minvalue","maxvalue","cycle","order"]);var Jl=uw,RS=class RS extends ce{constructor(e={}){super(e)}};n(RS,"GeneratedAsRowColumnConstraintExpr"),RS.key="generatedAsRowColumnConstraint",RS.requiredArgs=new Set,RS.availableArgs=new Set(["start","hidden"]);var UC=RS,OS=class OS extends ce{constructor(e={}){super(e)}};n(OS,"IndexColumnConstraintExpr"),OS.key="indexColumnConstraint",OS.requiredArgs=new Set,OS.availableArgs=new Set(["this","expressions","kind","indexType","options","expression","granularity"]);var Lq=OS,ak=class ak extends ce{constructor(e={}){super(e)}};n(ak,"InlineLengthColumnConstraintExpr"),ak.key="inlineLengthColumnConstraint";var Cu=ak,ok=class ok extends ce{constructor(e={}){super(e)}};n(ok,"NonClusteredColumnConstraintExpr"),ok.key="nonClusteredColumnConstraint";var bu=ok,mS=class mS extends ce{constructor(e={}){super(e)}};n(mS,"NotForReplicationColumnConstraintExpr"),mS.key="notForReplicationColumnConstraint",mS.requiredArgs=new Set,mS.availableArgs=new Set;var Pu=mS,hw=class hw extends ce{constructor(e={}){super(e)}};n(hw,"MaskingPolicyColumnConstraintExpr"),hw.key="maskingPolicyColumnConstraint",hw.availableArgs=new Set(["this","expressions"]);var wq=hw,NS=class NS extends ce{constructor(e={}){super(e)}};n(NS,"NotNullColumnConstraintExpr"),NS.key="notNullColumnConstraint",NS.requiredArgs=new Set,NS.availableArgs=new Set(["allowNull"]);var LA=NS,ck=class ck extends ce{constructor(e={}){super(e)}};n(ck,"OnUpdateColumnConstraintExpr"),ck.key="onUpdateColumnConstraint";var Lu=ck,IS=class IS extends ce{constructor(e={}){super(e)}};n(IS,"PrimaryKeyColumnConstraintExpr"),IS.key="primaryKeyColumnConstraint",IS.requiredArgs=new Set,IS.availableArgs=new Set(["desc","options"]);var vC=IS,pk=class pk extends ce{constructor(e={}){super(e)}};n(pk,"TitleColumnConstraintExpr"),pk.key="titleColumnConstraint";var wu=pk,yS=class yS extends ce{constructor(e={}){super(e)}};n(yS,"UniqueColumnConstraintExpr"),yS.key="uniqueColumnConstraint",yS.requiredArgs=new Set,yS.availableArgs=new Set(["this","indexType","onConflict","nulls","options"]);var Mu=yS,CS=class CS extends ce{constructor(e={}){super(e)}};n(CS,"UppercaseColumnConstraintExpr"),CS.key="uppercaseColumnConstraint",CS.requiredArgs=new Set,CS.availableArgs=new Set;var ku=CS,lk=class lk extends ce{constructor(e={}){super(e)}};n(lk,"PathColumnConstraintExpr"),lk.key="pathColumnConstraint";var Du=lk,uk=class uk extends ce{constructor(e={}){super(e)}};n(uk,"ProjectionPolicyColumnConstraintExpr"),uk.key="projectionPolicyColumnConstraint";var kb=uk,gw=class gw extends ce{constructor(e={}){super(e)}};n(gw,"ComputedColumnConstraintExpr"),gw.key="computedColumnConstraint",gw.availableArgs=new Set(["this","persisted","notNull","dataType"]);var Dn=gw,bS=class bS extends ce{constructor(e={}){super(e)}};n(bS,"InOutColumnConstraintExpr"),bS.key="inOutColumnConstraint",bS.requiredArgs=new Set,bS.availableArgs=new Set(["input","output","variadic"]);var FC=bS,PS=class PS extends bs{constructor(e={}){super(e)}};n(PS,"CopyExpr"),PS.key="copy",PS.requiredArgs=new Set(["this","kind"]),PS.availableArgs=new Set(["this","kind","files","credentials","format","params"]);var BC=PS,LS=class LS extends V(dn,bs,d){constructor(e={}){super(e)}with(e,t,s={}){let{recursive:r,materialized:i,append:o,dialect:c,copy:p,...u}=s;return z$({instance:this,alias:e,as:t,recursive:r,materialized:i,append:o,dialect:c,copy:p,...u})}};n(LS,"InsertExpr"),LS.key="insert",LS.requiredArgs=new Set,LS.availableArgs=new Set(["hint","with","isFunction","this","expression","conflict","returning","overwrite","exists","alternative","where","ignore","byName","stored","partition","settings","source","default"]);var es=LS,hi=class hi extends be{static number(e){let t=new hi({this:String(e),isString:!1}),s=typeof e=="number"?e:parseFloat(String(e));if(!isNaN(s)&&s<0){let r=typeof e=="string"&&e.startsWith("-")?e.slice(1):String(Math.abs(s));t=new hi({this:r,isString:!1}),t=new Pt({this:t})}return t}static string(e){return new hi({this:String(e),isString:!0})}constructor(e={}){super(e)}get outputName(){return this.name}toValue(){if(this.isNumber){let e=parseFloat(this.args.this);if(!isNaN(e))return e}return this.args.this}};n(hi,"LiteralExpr"),hi.key="literal",hi.requiredArgs=new Set(["this","isString"]),hi.availableArgs=new Set(["this","isString"]);var I=hi,hk=class hk extends ye{constructor(e={}){super(e)}};n(hk,"ClusterExpr"),hk.key="cluster";var rr=hk,gk=class gk extends ye{constructor(e={}){super(e)}};n(gk,"DistributeExpr"),gk.key="distribute";var $C=gk,Ek=class Ek extends ye{constructor(e={}){super(e)}};n(Ek,"SortExpr"),Ek.key="sort";var zl=Ek,wS=class wS extends w{constructor(e={}){super(e)}};n(wS,"AlgorithmPropertyExpr"),wS.key="algorithmProperty",wS.requiredArgs=new Set(["this"]),wS.availableArgs=new Set(["this"]);var Wn=wS,MS=class MS extends w{constructor(e={}){super(e)}};n(MS,"AutoIncrementPropertyExpr"),MS.key="autoIncrementProperty",MS.requiredArgs=new Set(["this"]),MS.availableArgs=new Set(["this"]);var jn=MS,kS=class kS extends w{constructor(e={}){super(e)}};n(kS,"AutoRefreshPropertyExpr"),kS.key="autoRefreshProperty",kS.requiredArgs=new Set(["this"]),kS.availableArgs=new Set(["this"]);var Xn=kS,DS=class DS extends w{constructor(e={}){super(e)}};n(DS,"BackupPropertyExpr"),DS.key="backupProperty",DS.requiredArgs=new Set(["this"]),DS.availableArgs=new Set(["this"]);var Jn=DS,qS=class qS extends w{constructor(e={}){super(e)}};n(qS,"BuildPropertyExpr"),qS.key="buildProperty",qS.requiredArgs=new Set(["this"]),qS.availableArgs=new Set(["this"]);var Mq=qS,US=class US extends w{constructor(e={}){super(e)}};n(US,"BlockCompressionPropertyExpr"),US.key="blockCompressionProperty",US.requiredArgs=new Set,US.availableArgs=new Set(["autotemp","always","default","manual","never"]);var qu=US,vS=class vS extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(vS,"CharacterSetPropertyExpr"),vS.key="characterSetProperty",vS.requiredArgs=new Set(["this","default"]),vS.availableArgs=new Set(["this","default"]);var zr=vS,FS=class FS extends w{constructor(e={}){super(e)}};n(FS,"ChecksumPropertyExpr"),FS.key="checksumProperty",FS.requiredArgs=new Set,FS.availableArgs=new Set(["on","default"]);var Uu=FS,BS=class BS extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(BS,"CollatePropertyExpr"),BS.key="collateProperty",BS.requiredArgs=new Set(["this"]),BS.availableArgs=new Set(["this","default"]);var zn=BS,$S=class $S extends w{constructor(e={}){super(e)}};n($S,"CopyGrantsPropertyExpr"),$S.key="copyGrantsProperty",$S.requiredArgs=new Set,$S.availableArgs=new Set;var Qn=$S,GS=class GS extends w{constructor(e={}){super(e)}};n(GS,"DataBlocksizePropertyExpr"),GS.key="dataBlocksizeProperty",GS.requiredArgs=new Set,GS.availableArgs=new Set(["size","units","minimum","maximum","default"]);var vu=GS,YS=class YS extends w{constructor(e={}){super(e)}};n(YS,"DataDeletionPropertyExpr"),YS.key="dataDeletionProperty",YS.requiredArgs=new Set(["on"]),YS.availableArgs=new Set(["on","filterColumn","retentionPeriod"]);var Fu=YS,VS=class VS extends w{constructor(e={}){super(e)}};n(VS,"DefinerPropertyExpr"),VS.key="definerProperty",VS.requiredArgs=new Set(["this"]),VS.availableArgs=new Set(["this"]);var Zn=VS,HS=class HS extends w{constructor(e={}){super(e)}};n(HS,"DistKeyPropertyExpr"),HS.key="distKeyProperty",HS.requiredArgs=new Set(["this"]),HS.availableArgs=new Set(["this"]);var Kn=HS,_S=class _S extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(_S,"DistributedByPropertyExpr"),_S.key="distributedByProperty",_S.requiredArgs=new Set(["kind"]),_S.availableArgs=new Set(["expressions","kind","buckets","order"]);var ea=_S,WS=class WS extends w{constructor(e={}){super(e)}};n(WS,"DistStylePropertyExpr"),WS.key="distStyleProperty",WS.requiredArgs=new Set(["this"]),WS.availableArgs=new Set(["this"]);var ta=WS,jS=class jS extends w{constructor(e={}){super(e)}};n(jS,"DuplicateKeyPropertyExpr"),jS.key="duplicateKeyProperty",jS.requiredArgs=new Set(["expressions"]),jS.availableArgs=new Set(["expressions"]);var Bu=jS,XS=class XS extends w{constructor(e={}){super(e)}};n(XS,"EnginePropertyExpr"),XS.key="engineProperty",XS.requiredArgs=new Set(["this"]),XS.availableArgs=new Set(["this"]);var sa=XS,JS=class JS extends w{constructor(e={}){super(e)}};n(JS,"UuidPropertyExpr"),JS.key="uuidProperty",JS.requiredArgs=new Set(["this"]),JS.availableArgs=new Set(["this"]);var kq=JS,zS=class zS extends w{constructor(e={}){super(e)}};n(zS,"HandlerPropertyExpr"),zS.key="handlerProperty",zS.requiredArgs=new Set(["this"]),zS.availableArgs=new Set(["this"]);var ra=zS,QS=class QS extends w{constructor(e={}){super(e)}};n(QS,"ParameterStylePropertyExpr"),QS.key="parameterStyleProperty",QS.requiredArgs=new Set(["this"]),QS.availableArgs=new Set(["this"]);var ia=QS,ZS=class ZS extends w{constructor(e={}){super(e)}};n(ZS,"HeapPropertyExpr"),ZS.key="heapProperty",ZS.requiredArgs=new Set,ZS.availableArgs=new Set;var na=ZS,KS=class KS extends w{constructor(e={}){super(e)}};n(KS,"ToTablePropertyExpr"),KS.key="toTableProperty",KS.requiredArgs=new Set(["this"]),KS.availableArgs=new Set(["this"]);var aa=KS,eR=class eR extends w{constructor(e={}){super(e)}};n(eR,"ExecuteAsPropertyExpr"),eR.key="executeAsProperty",eR.requiredArgs=new Set(["this"]),eR.availableArgs=new Set(["this"]);var nr=eR,tR=class tR extends w{constructor(e={}){super(e)}};n(tR,"ExternalPropertyExpr"),tR.key="externalProperty",tR.requiredArgs=new Set,tR.availableArgs=new Set(["this"]);var oa=tR,sR=class sR extends w{constructor(e={}){super(e)}};n(sR,"FallbackPropertyExpr"),sR.key="fallbackProperty",sR.requiredArgs=new Set(["no"]),sR.availableArgs=new Set(["no","protection"]);var $u=sR,rR=class rR extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(rR,"FileFormatPropertyExpr"),rR.key="fileFormatProperty",rR.requiredArgs=new Set,rR.availableArgs=new Set(["this","expressions","hiveFormat"]);var ir=rR,iR=class iR extends w{constructor(e={}){super(e)}};n(iR,"CredentialsPropertyExpr"),iR.key="credentialsProperty",iR.requiredArgs=new Set(["expressions"]),iR.availableArgs=new Set(["expressions"]);var ld=iR,nR=class nR extends w{constructor(e={}){super(e)}};n(nR,"FreespacePropertyExpr"),nR.key="freespaceProperty",nR.requiredArgs=new Set(["this"]),nR.availableArgs=new Set(["this","percent"]);var Gu=nR,aR=class aR extends w{constructor(e={}){super(e)}};n(aR,"GlobalPropertyExpr"),aR.key="globalProperty",aR.requiredArgs=new Set,aR.availableArgs=new Set;var ca=aR,oR=class oR extends w{constructor(e={}){super(e)}};n(oR,"IcebergPropertyExpr"),oR.key="icebergProperty",oR.requiredArgs=new Set,oR.availableArgs=new Set;var pa=oR,cR=class cR extends w{constructor(e={}){super(e)}};n(cR,"InheritsPropertyExpr"),cR.key="inheritsProperty",cR.requiredArgs=new Set(["expressions"]),cR.availableArgs=new Set(["expressions"]);var la=cR,pR=class pR extends w{constructor(e={}){super(e)}};n(pR,"InputModelPropertyExpr"),pR.key="inputModelProperty",pR.requiredArgs=new Set(["this"]),pR.availableArgs=new Set(["this"]);var ua=pR,lR=class lR extends w{constructor(e={}){super(e)}};n(lR,"OutputModelPropertyExpr"),lR.key="outputModelProperty",lR.requiredArgs=new Set(["this"]),lR.availableArgs=new Set(["this"]);var ha=lR,uR=class uR extends w{constructor(e={}){super(e)}};n(uR,"IsolatedLoadingPropertyExpr"),uR.key="isolatedLoadingProperty",uR.requiredArgs=new Set,uR.availableArgs=new Set(["no","concurrent","target"]);var Yu=uR,hR=class hR extends w{constructor(e={}){super(e)}};n(hR,"JournalPropertyExpr"),hR.key="journalProperty",hR.requiredArgs=new Set,hR.availableArgs=new Set(["no","dual","before","local","after"]);var Vu=hR,gR=class gR extends w{constructor(e={}){super(e)}};n(gR,"LanguagePropertyExpr"),gR.key="languageProperty",gR.requiredArgs=new Set(["this"]),gR.availableArgs=new Set(["this"]);var Qr=gR,ER=class ER extends w{constructor(e={}){super(e)}};n(ER,"EnviromentPropertyExpr"),ER.key="enviromentProperty",ER.requiredArgs=new Set(["expressions"]),ER.availableArgs=new Set(["expressions"]);var ga=ER,AR=class AR extends w{constructor(e={}){super(e)}};n(AR,"ClusteredByPropertyExpr"),AR.key="clusteredByProperty",AR.requiredArgs=new Set(["expressions","buckets"]),AR.availableArgs=new Set(["expressions","sortedBy","buckets"]);var Ea=AR,dR=class dR extends w{constructor(e={}){super(e)}};n(dR,"DictPropertyExpr"),dR.key="dictProperty",dR.requiredArgs=new Set(["this","kind"]),dR.availableArgs=new Set(["this","kind","settings"]);var Hu=dR,Ak=class Ak extends w{constructor(e={}){super(e)}};n(Ak,"DictSubPropertyExpr"),Ak.key="dictSubProperty";var GC=Ak,xR=class xR extends w{constructor(e={}){super(e)}};n(xR,"DictRangeExpr"),xR.key="dictRange",xR.requiredArgs=new Set(["this","min","max"]),xR.availableArgs=new Set(["this","min","max"]);var _u=xR,fR=class fR extends w{constructor(e={}){super(e)}};n(fR,"DynamicPropertyExpr"),fR.key="dynamicProperty",fR.requiredArgs=new Set,fR.availableArgs=new Set;var Aa=fR,TR=class TR extends w{constructor(e={}){super(e)}};n(TR,"OnClusterExpr"),TR.key="onCluster",TR.requiredArgs=new Set(["this"]),TR.availableArgs=new Set(["this"]);var Dq=TR,SR=class SR extends w{constructor(e={}){super(e)}};n(SR,"EmptyPropertyExpr"),SR.key="emptyProperty",SR.requiredArgs=new Set,SR.availableArgs=new Set;var da=SR,RR=class RR extends w{constructor(e={}){super(e)}};n(RR,"LikePropertyExpr"),RR.key="likeProperty",RR.requiredArgs=new Set(["this"]),RR.availableArgs=new Set(["this","expressions"]);var Wu=RR,OR=class OR extends w{constructor(e={}){super(e)}};n(OR,"LocationPropertyExpr"),OR.key="locationProperty",OR.requiredArgs=new Set(["this"]),OR.availableArgs=new Set(["this"]);var Zr=OR,mR=class mR extends w{constructor(e={}){super(e)}};n(mR,"LockPropertyExpr"),mR.key="lockProperty",mR.requiredArgs=new Set(["this"]),mR.availableArgs=new Set(["this"]);var ud=mR,NR=class NR extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(NR,"LockingPropertyExpr"),NR.key="lockingProperty",NR.requiredArgs=new Set(["kind","lockType"]),NR.availableArgs=new Set(["this","kind","forOrIn","lockType","override"]);var ju=NR,IR=class IR extends w{constructor(e={}){super(e)}};n(IR,"LogPropertyExpr"),IR.key="logProperty",IR.requiredArgs=new Set(["no"]),IR.availableArgs=new Set(["no"]);var xa=IR,yR=class yR extends w{constructor(e={}){super(e)}};n(yR,"MaterializedPropertyExpr"),yR.key="materializedProperty",yR.requiredArgs=new Set,yR.availableArgs=new Set(["this"]);var fa=yR,CR=class CR extends w{constructor(e={}){super(e)}get value(){return this.args.value}};n(CR,"MergeBlockRatioPropertyExpr"),CR.key="mergeBlockRatioProperty",CR.requiredArgs=new Set,CR.availableArgs=new Set(["this","no","default","percent"]);var qn=CR,bR=class bR extends w{constructor(e={}){super(e)}};n(bR,"NoPrimaryIndexPropertyExpr"),bR.key="noPrimaryIndexProperty",bR.requiredArgs=new Set,bR.availableArgs=new Set;var Ta=bR,PR=class PR extends w{constructor(e={}){super(e)}};n(PR,"OnPropertyExpr"),PR.key="onProperty",PR.requiredArgs=new Set(["this"]),PR.availableArgs=new Set(["this"]);var Vr=PR,LR=class LR extends w{constructor(e={}){super(e)}};n(LR,"OnCommitPropertyExpr"),LR.key="onCommitProperty",LR.requiredArgs=new Set,LR.availableArgs=new Set(["delete"]);var Hr=LR,wR=class wR extends w{constructor(e={}){super(e)}};n(wR,"PartitionedByPropertyExpr"),wR.key="partitionedByProperty",wR.requiredArgs=new Set(["this"]),wR.availableArgs=new Set(["this"]);var Cs=wR,MR=class MR extends w{constructor(e={}){super(e)}};n(MR,"PartitionedByBucketExpr"),MR.key="partitionedByBucket",MR.requiredArgs=new Set(["this","expression"]),MR.availableArgs=new Set(["this","expression"]);var Xu=MR,kR=class kR extends w{constructor(e={}){super(e)}};n(kR,"PartitionByTruncateExpr"),kR.key="partitionByTruncate",kR.requiredArgs=new Set(["this","expression"]),kR.availableArgs=new Set(["this","expression"]);var Ju=kR,DR=class DR extends w{constructor(e={}){super(e)}};n(DR,"PartitionByRangePropertyExpr"),DR.key="partitionByRangeProperty",DR.requiredArgs=new Set(["partitionExpressions","createExpressions"]),DR.availableArgs=new Set(["partitionExpressions","createExpressions"]);var qq=DR,qR=class qR extends w{constructor(e={}){super(e)}};n(qR,"RollupPropertyExpr"),qR.key="rollupProperty",qR.requiredArgs=new Set(["expressions"]),qR.availableArgs=new Set(["expressions"]);var Db=qR,UR=class UR extends w{constructor(e={}){super(e)}};n(UR,"PartitionByListPropertyExpr"),UR.key="partitionByListProperty",UR.requiredArgs=new Set(["partitionExpressions","createExpressions"]),UR.availableArgs=new Set(["partitionExpressions","createExpressions"]);var Uq=UR,vR=class vR extends w{constructor(e={}){super(e)}};n(vR,"RefreshTriggerPropertyExpr"),vR.key="refreshTriggerProperty",vR.requiredArgs=new Set,vR.availableArgs=new Set(["method","kind","every","unit","starts"]);var qb=vR,FR=class FR extends w{constructor(e={}){super(e)}};n(FR,"UniqueKeyPropertyExpr"),FR.key="uniqueKeyProperty",FR.requiredArgs=new Set(["expressions"]),FR.availableArgs=new Set(["expressions"]);var vq=FR,BR=class BR extends w{constructor(e={}){super(e)}};n(BR,"PartitionedOfPropertyExpr"),BR.key="partitionedOfProperty",BR.requiredArgs=new Set(["this","expression"]),BR.availableArgs=new Set(["this","expression"]);var zu=BR,$R=class $R extends w{constructor(e={}){super(e)}};n($R,"StreamingTablePropertyExpr"),$R.key="streamingTableProperty",$R.requiredArgs=new Set,$R.availableArgs=new Set;var Sa=$R,GR=class GR extends w{constructor(e={}){super(e)}};n(GR,"RemoteWithConnectionModelPropertyExpr"),GR.key="remoteWithConnectionModelProperty",GR.requiredArgs=new Set(["this"]),GR.availableArgs=new Set(["this"]);var Ra=GR,YR=class YR extends w{constructor(e={}){super(e)}};n(YR,"ReturnsPropertyExpr"),YR.key="returnsProperty",YR.requiredArgs=new Set,YR.availableArgs=new Set(["this","isTable","table","null"]);var Kr=YR,VR=class VR extends w{constructor(e={}){super(e)}};n(VR,"StrictPropertyExpr"),VR.key="strictProperty",VR.requiredArgs=new Set,VR.availableArgs=new Set;var Oa=VR,HR=class HR extends w{constructor(e={}){super(e)}};n(HR,"RowFormatPropertyExpr"),HR.key="rowFormatProperty",HR.requiredArgs=new Set(["this"]),HR.availableArgs=new Set(["this"]);var ma=HR,_R=class _R extends w{constructor(e={}){super(e)}};n(_R,"RowFormatDelimitedPropertyExpr"),_R.key="rowFormatDelimitedProperty",_R.requiredArgs=new Set,_R.availableArgs=new Set(["fields","escaped","collectionItems","mapKeys","lines","null","serde"]);var Qu=_R,WR=class WR extends w{constructor(e={}){super(e)}};n(WR,"RowFormatSerdePropertyExpr"),WR.key="rowFormatSerdeProperty",WR.requiredArgs=new Set(["this"]),WR.availableArgs=new Set(["this","serdeProperties"]);var Zu=WR,jR=class jR extends w{constructor(e={}){super(e)}};n(jR,"SamplePropertyExpr"),jR.key="sampleProperty",jR.requiredArgs=new Set(["this"]),jR.availableArgs=new Set(["this"]);var Na=jR,XR=class XR extends w{constructor(e={}){super(e)}};n(XR,"SchemaCommentPropertyExpr"),XR.key="schemaCommentProperty",XR.requiredArgs=new Set(["this"]),XR.availableArgs=new Set(["this"]);var Ia=XR,JR=class JR extends w{constructor(e={}){super(e)}};n(JR,"SerdePropertiesExpr"),JR.key="serdeProperties",JR.requiredArgs=new Set(["expressions"]),JR.availableArgs=new Set(["expressions","with"]);var Ku=JR,zR=class zR extends w{constructor(e={}){super(e)}};n(zR,"SetPropertyExpr"),zR.key="setProperty",zR.requiredArgs=new Set(["multi"]),zR.availableArgs=new Set(["multi"]);var _r=zR,QR=class QR extends w{constructor(e={}){super(e)}};n(QR,"SharingPropertyExpr"),QR.key="sharingProperty",QR.requiredArgs=new Set,QR.availableArgs=new Set(["this"]);var ya=QR,ZR=class ZR extends w{constructor(e={}){super(e)}};n(ZR,"SetConfigPropertyExpr"),ZR.key="setConfigProperty",ZR.requiredArgs=new Set(["this"]),ZR.availableArgs=new Set(["this"]);var JA=ZR,KR=class KR extends w{constructor(e={}){super(e)}};n(KR,"SettingsPropertyExpr"),KR.key="settingsProperty",KR.requiredArgs=new Set(["expressions"]),KR.availableArgs=new Set(["expressions"]);var Ca=KR,eO=class eO extends w{constructor(e={}){super(e)}};n(eO,"SortKeyPropertyExpr"),eO.key="sortKeyProperty",eO.requiredArgs=new Set(["this"]),eO.availableArgs=new Set(["this","compound"]);var ba=eO,tO=class tO extends w{constructor(e={}){super(e)}};n(tO,"SqlReadWritePropertyExpr"),tO.key="sqlReadWriteProperty",tO.requiredArgs=new Set(["this"]),tO.availableArgs=new Set(["this"]);var vs=tO,sO=class sO extends w{constructor(e={}){super(e)}};n(sO,"SqlSecurityPropertyExpr"),sO.key="sqlSecurityProperty",sO.requiredArgs=new Set(["this"]),sO.availableArgs=new Set(["this"]);var Pa=sO,rO=class rO extends w{constructor(e={}){super(e)}};n(rO,"StabilityPropertyExpr"),rO.key="stabilityProperty",rO.requiredArgs=new Set(["this"]),rO.availableArgs=new Set(["this"]);var Fs=rO,iO=class iO extends w{constructor(e={}){super(e)}};n(iO,"StorageHandlerPropertyExpr"),iO.key="storageHandlerProperty",iO.requiredArgs=new Set(["this"]),iO.availableArgs=new Set(["this"]);var eh=iO,nO=class nO extends w{constructor(e={}){super(e)}};n(nO,"TemporaryPropertyExpr"),nO.key="temporaryProperty",nO.requiredArgs=new Set,nO.availableArgs=new Set(["this"]);var $s=nO,aO=class aO extends w{constructor(e={}){super(e)}};n(aO,"SecurePropertyExpr"),aO.key="secureProperty",aO.requiredArgs=new Set,aO.availableArgs=new Set;var La=aO,oO=class oO extends w{};n(oO,"ApiPropertyExpr"),oO.key="apiProperty",oO.requiredArgs=new Set,oO.availableArgs=new Set;var zA=oO,cO=class cO extends w{};n(cO,"ApplicationPropertyExpr"),cO.key="applicationProperty",cO.requiredArgs=new Set,cO.availableArgs=new Set;var QA=cO,pO=class pO extends w{};n(pO,"CatalogPropertyExpr"),pO.key="catalogProperty",pO.requiredArgs=new Set,pO.availableArgs=new Set;var ZA=pO,lO=class lO extends w{};n(lO,"ComputePropertyExpr"),lO.key="computeProperty",lO.requiredArgs=new Set,lO.availableArgs=new Set;var KA=lO,uO=class uO extends w{};n(uO,"DatabasePropertyExpr"),uO.key="databaseProperty",uO.requiredArgs=new Set,uO.availableArgs=new Set;var ed=uO,hO=class hO extends w{};n(hO,"HybridPropertyExpr"),hO.key="hybridProperty",hO.requiredArgs=new Set,hO.availableArgs=new Set;var td=hO,gO=class gO extends w{};n(gO,"MaskingPropertyExpr"),gO.key="maskingProperty",gO.requiredArgs=new Set,gO.availableArgs=new Set;var sd=gO,EO=class EO extends w{};n(EO,"NetworkPropertyExpr"),EO.key="networkProperty",EO.requiredArgs=new Set,EO.availableArgs=new Set;var rd=EO,AO=class AO extends w{};n(AO,"RowAccessPropertyExpr"),AO.key="rowAccessProperty",AO.requiredArgs=new Set,AO.availableArgs=new Set;var id=AO,dO=class dO extends w{};n(dO,"SecurityIntegrationPropertyExpr"),dO.key="securityIntegrationProperty",dO.requiredArgs=new Set,dO.availableArgs=new Set;var nd=dO,xO=class xO extends V(ce,w){constructor(e={}){super(e)}};n(xO,"TagsExpr"),xO.key="tags",xO.requiredArgs=new Set(["expressions"]),xO.availableArgs=new Set(["expressions"]);var ad=xO,fO=class fO extends w{constructor(e={}){super(e)}};n(fO,"TransformModelPropertyExpr"),fO.key="transformModelProperty",fO.requiredArgs=new Set(["expressions"]),fO.availableArgs=new Set(["expressions"]);var wa=fO,TO=class TO extends w{constructor(e={}){super(e)}};n(TO,"TransientPropertyExpr"),TO.key="transientProperty",TO.requiredArgs=new Set,TO.availableArgs=new Set(["this"]);var Ma=TO,SO=class SO extends w{constructor(e={}){super(e)}};n(SO,"UnloggedPropertyExpr"),SO.key="unloggedProperty",SO.requiredArgs=new Set,SO.availableArgs=new Set;var ka=SO,RO=class RO extends w{constructor(e={}){super(e)}};n(RO,"UsingTemplatePropertyExpr"),RO.key="usingTemplateProperty",RO.requiredArgs=new Set(["this"]),RO.availableArgs=new Set(["this"]);var od=RO,OO=class OO extends w{constructor(e={}){super(e)}};n(OO,"ViewAttributePropertyExpr"),OO.key="viewAttributeProperty",OO.requiredArgs=new Set(["this"]),OO.availableArgs=new Set(["this"]);var Da=OO,mO=class mO extends w{constructor(e={}){super(e)}};n(mO,"VolatilePropertyExpr"),mO.key="volatileProperty",mO.requiredArgs=new Set,mO.availableArgs=new Set(["this"]);var qa=mO,NO=class NO extends w{constructor(e={}){super(e)}};n(NO,"WithDataPropertyExpr"),NO.key="withDataProperty",NO.requiredArgs=new Set(["no"]),NO.availableArgs=new Set(["no","statistics"]);var th=NO,IO=class IO extends w{constructor(e={}){super(e)}};n(IO,"WithJournalTablePropertyExpr"),IO.key="withJournalTableProperty",IO.requiredArgs=new Set(["this"]),IO.availableArgs=new Set(["this"]);var Ua=IO,yO=class yO extends w{constructor(e={}){super(e)}};n(yO,"WithSchemaBindingPropertyExpr"),yO.key="withSchemaBindingProperty",yO.requiredArgs=new Set(["this"]),yO.availableArgs=new Set(["this"]);var va=yO,CO=class CO extends w{constructor(e={}){super(e)}};n(CO,"WithSystemVersioningPropertyExpr"),CO.key="withSystemVersioningProperty",CO.requiredArgs=new Set(["with"]),CO.availableArgs=new Set(["on","this","dataConsistency","retentionPeriod","with"]);var sh=CO,bO=class bO extends w{constructor(e={}){super(e)}};n(bO,"WithProcedureOptionsExpr"),bO.key="withProcedureOptions",bO.requiredArgs=new Set(["expressions"]),bO.availableArgs=new Set(["expressions"]);var Fa=bO,PO=class PO extends w{constructor(e={}){super(e)}};n(PO,"EncodePropertyExpr"),PO.key="encodeProperty",PO.requiredArgs=new Set(["this"]),PO.availableArgs=new Set(["this","properties","key"]);var hd=PO,LO=class LO extends w{constructor(e={}){super(e)}};n(LO,"IncludePropertyExpr"),LO.key="includeProperty",LO.requiredArgs=new Set(["this"]),LO.availableArgs=new Set(["this","alias","columnDef"]);var gd=LO,wO=class wO extends w{constructor(e={}){super(e)}};n(wO,"ForcePropertyExpr"),wO.key="forceProperty",wO.requiredArgs=new Set,wO.availableArgs=new Set;var cd=wO,Ws=class Ws extends d{constructor(e={}){super(e)}static fromDict(e){let t=[];for(let[s,r]of Object.entries(e)){let i=Ws.NAME_TO_PROPERTY[s.toUpperCase()];i?t.push(new i({this:ht(r)})):t.push(new w({this:I.string(s),value:ht(r)}))}return new Ws({expressions:t})}};n(Ws,"PropertiesExpr"),Ws.key="properties",Ws.requiredArgs=new Set(["expressions"]),Ws.availableArgs=new Set(["expressions"]),Ws.NAME_TO_PROPERTY={ALGORITHM:Wn,AUTO_INCREMENT:jn,"CHARACTER SET":zr,CLUSTERED_BY:Ea,COLLATE:zn,COMMENT:Ia,CREDENTIALS:ld,DEFINER:Zn,DISTKEY:Kn,DISTRIBUTED_BY:ea,DISTSTYLE:ta,ENGINE:sa,"EXECUTE AS":nr,FORMAT:ir,LANGUAGE:Qr,LOCATION:Zr,LOCK:ud,PARTITIONED_BY:Cs,RETURNS:Kr,ROW_FORMAT:ma,SORTKEY:ba,ENCODE:hd,INCLUDE:gd},Ws.PROPERTY_TO_NAME=Object.fromEntries(Object.entries(Ws.NAME_TO_PROPERTY).map(([e,t])=>[t.key,e]));var He=Ws,Wa=class Wa extends ee{constructor(e={}){super(e)}select(e,t={}){let{copy:s=!0,...r}=t,i=Array.from(J(e)),o=$e(this,s),c=o.args.this;re(c,ee),ct(c.unnest(),ee)?.select(i,{...r,copy:!1});let p=o.args.expression;return re(p,ee),ct(p.unnest(),ee)?.select(i,{...r,copy:!1,append:t?.append??!0}),o}get namedSelects(){let e=this;for(;e instanceof Wa;){let t=e.args.this?.unnest();re(t,ee),e=t}return e.namedSelects}get isStar(){let e=this.args.this?.isStar,t=this.args.expression?.isStar;return e||t||!1}get selects(){let e=this;for(;e instanceof Wa;){let t=e.args.this?.unnest();re(t,ee),e=t}return e.selects}get left(){return this.args.this}get right(){return this.args.expression}get kind(){return this.args.kind}get side(){return this.text("side").toUpperCase()}};n(Wa,"SetOperationExpr"),Wa.key="setOperation",Wa.requiredArgs=new Set(["this","expression"]),Wa.availableArgs=new Set(["with","this","expression","distinct","byName","side","kind","on","match","laterals","joins","connect","pivots","prewhere","where","group","having","qualify","windows","distribute","sort","cluster","order","limit","offset","locks","sample","settings","format","options"]);var Ge=Wa,MO=class MO extends bs{constructor(e={}){super(e)}table(e,t={}){let{dialect:s,copy:r=!0}=t;return JE(e,{instance:this,arg:"this",into:W,prefix:void 0,dialect:s,copy:r})}set(e,t={}){let{append:s=!0,dialect:r,copy:i=!0}=t,o=Array.from(J(e));return Hh(o,{instance:this,arg:"expressions",append:s,into:d,prefix:void 0,dialect:r,copy:i})}where(e,t={}){let{append:s=!0,dialect:r,copy:i=!0}=t;return FI(e,{instance:this,arg:"where",append:s,into:St,dialect:r,copy:i})}from(e,t={}){let{dialect:s,copy:r=!0}=t;return e?JE(e,{instance:this,arg:"from",into:rt,prefix:"FROM",dialect:s,copy:r}):this}with(e,t,s={}){let{recursive:r=!1,append:i=!0,copy:o=!0,...c}=s;return z$({instance:this,alias:e,as:t,...c,recursive:r,append:i,copy:o})}};n(MO,"UpdateExpr"),MO.key="update",MO.requiredArgs=new Set,MO.availableArgs=new Set(["with","this","expressions","from","where","returning","order","limit","options"]);var us=MO,_h=class _h extends ee{constructor(e={}){super(e)}get namedSelects(){let e=[];for(let t of this.args.expressions||[])t.aliasOrName?e.push(t.outputName):t instanceof Hn&&e.push(...t.aliases.map(s=>s.name));return e}get isStar(){return this.args.expressions?.some(e=>typeof e=="object"&&"isStar"in e&&e.isStar)??!1}get selects(){return this.args.expressions||[]}from(e,t={}){let{dialect:s,copy:r=!0,...i}=t;return JE(e,{...i,instance:this,arg:"from",into:rt,prefix:"FROM",dialect:s,copy:r})}groupBy(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t,c=Array.from(J(e));return c.length===0?i?this.copy():this:xd(c,{...o,instance:this,arg:"group",append:s,copy:i,prefix:"GROUP BY",into:Yr,dialect:r})}sortBy(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return xd(e,{...o,instance:this,arg:"sort",append:s,copy:i,prefix:"SORT BY",into:zl,dialect:r})}clusterBy(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return xd(e,{...o,instance:this,arg:"cluster",append:s,copy:i,prefix:"CLUSTER BY",into:rr,dialect:r})}having(e,t={}){let{append:s=!0,dialect:r=void 0,copy:i=!0,...o}=t;return FI(e,{instance:this,arg:"having",append:s,into:xs,dialect:r,copy:i,...o})}orderBy(e,t={}){let{append:s=!0,dialect:r=void 0,copy:i=!0,...o}=t;return xd(e,{instance:this,arg:"order",append:s,copy:i,prefix:"ORDER BY",into:ye,dialect:r,...o})}select(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return Hh(e,{instance:this,arg:"expressions",append:s,dialect:r,into:d,copy:i,...o})}lateral(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return Hh(e,{...o,instance:this,arg:"laterals",append:s,into:bt,prefix:"LATERAL VIEW",dialect:r,copy:i})}join(e,t={}){let{on:s,using:r,append:i=!0,joinType:o,joinAlias:c,dialect:p,copy:u=!0,...h}=t,g={dialect:p},x;try{x=j(e,{...g,into:fe,prefix:"JOIN"})}catch{try{x=j(e,{...g,into:fe})}catch{x=j(e,{...g})}}let f=x instanceof fe?x:new fe({this:x});f.args.this instanceof _h&&f.args.this?.replace(f.args.this?.subquery());let T={left:"left",right:"right",full:"full"};if(o){let y=T[o]??o,b=j(y,{...g,into:"JOIN_TYPE"});b.args.method&&f.setArgKey("method",b.args.method),b.args.side&&f.setArgKey("side",b.args.side),b.args.kind&&f.setArgKey("kind",b.args.kind)}if(s){let y=ve(Array.from(J(s)),{dialect:p,copy:u});f.setArgKey("on",y)}return r&&(f=Hh(Array.from(J(r)),{instance:f,arg:"using",append:i,copy:u,into:F})),c&&f.setArgKey("this",Be(f.args.this,c,{table:!0})),Hh([f],{instance:this,arg:"joins",append:i,copy:u})}window(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return Hh(e,{...o,instance:this,arg:"windows",append:s,into:Ue,dialect:r,copy:i})}qualify(e,t={}){let{append:s=!0,dialect:r,copy:i=!0,...o}=t;return FI(e,{...o,instance:this,arg:"qualify",append:s,into:Xs,dialect:r,copy:i})}distinct(e,t={}){let{distinct:s=!0,copy:r=!0,...i}=t,o=$e(this,r),p=(e?e.some(h=>h===!1):!1)?!1:s,u=e?e.filter(h=>h!==void 0&&h!==!1&&h!==!0):[];if(0<u.length){let h=u.map(x=>j(x,{copy:r,into:d})),g=new Ze({expressions:h});o.setArgKey("distinct",p?new et({on:g}):void 0)}else o.setArgKey("distinct",p?new et({}):void 0);return o}ctas(e,t={}){let{properties:s,dialect:r,copy:i=!0}=t,o=$e(this,i),c=j((e instanceof d,e),{dialect:r,into:W}),p;return s&&(p=He.fromDict(s)),new ss({this:c,kind:"table",expression:o,properties:p})}lock(e={}){let{update:t=!0,copy:s=!0}=e,r=$e(this,s);return r.setArgKey("locks",[new $A({update:new I({this:String(Number(t)),isString:!1})})]),r}hint(e,t={}){let{dialect:s,copy:r=!0}=t,o=(e!==void 0?Array.from(J(e)):[]).map(p=>j(p,{dialect:s,into:d})),c=$e(this,r);return c.setArgKey("hint",new Ps({expressions:o})),c}};n(_h,"SelectExpr"),_h.key="select",_h.requiredArgs=new Set,_h.availableArgs=new Set(["with","kind","expressions","hint","distinct","into","from","operationModifiers","exclude","match","laterals","joins","connect","pivots","prewhere","where","group","having","qualify","windows","distribute","sort","cluster","order","limit","offset","locks","sample","settings","format","options","for"]);var se=_h,ja=class ja extends V(An,ee){constructor(e={}){super(e)}unnest(){let e=this;for(;e instanceof ja;){let t=e.args.this;if(!t||(e=t,e===this))break}return e}unwrap(){let e=this;for(;e.sameParent&&e.isWrapper;){let t=e.parent;if(!(t instanceof ja))break;e=t}return e}select(e,t={}){let{copy:s=!0,...r}=t,i=$e(this,s),o=i?.unnest();return o instanceof se&&o.select(e,{...r,copy:!1}),i}get isWrapper(){return Object.entries(this.args).every(([e,t])=>e==="this"||t===void 0)}get isStar(){let e=this.args.this;return e?e.isStar:!1}get outputName(){return this.alias}};n(ja,"SubqueryExpr"),ja.key="subquery",ja.requiredArgs=new Set(["this"]),ja.availableArgs=new Set(["this","alias","with","match","laterals","joins","connect","pivots","prewhere","where","group","having","qualify","windows","distribute","sort","cluster","order","limit","offset","locks","sample","settings","format","options"]);var he=ja,kO=class kO extends be{constructor(e={}){super(e)}};n(kO,"WindowExpr"),kO.key="window",kO.requiredArgs=new Set(["this"]),kO.availableArgs=new Set(["this","partitionBy","order","spec","alias","over","first"]);var Ue=kO,Ew=class Ew extends be{constructor(e={}){super(e)}};n(Ew,"ParameterExpr"),Ew.key="parameter",Ew.availableArgs=new Set(["this","expression"]);var YC=Ew,Aw=class Aw extends be{constructor(e={}){super(e)}};n(Aw,"SessionParameterExpr"),Aw.key="sessionParameter",Aw.availableArgs=new Set(["this","kind"]);var VC=Aw,DO=class DO extends be{constructor(e={}){super(e)}get name(){return(this.args.this instanceof d?this.args.this.name:this.args.this)||"?"}};n(DO,"PlaceholderExpr"),DO.key="placeholder",DO.requiredArgs=new Set,DO.availableArgs=new Set(["this","kind","widget","jdbc"]);var ar=DO,qO=class qO extends be{constructor(e={}){super(e)}get name(){return"NULL"}toValue(){}};n(qO,"NullExpr"),qO.key="null",qO.requiredArgs=new Set,qO.availableArgs=new Set;var Lt=qO,dk=class dk extends be{constructor(e={}){super(e)}toValue(){return!!this.args.this}};n(dk,"BooleanExpr"),dk.key="boolean";var at=dk,dw=class dw extends N{constructor(e={}){super(e)}};n(dw,"PseudoTypeExpr"),dw.key="pseudoType",dw.availableArgs=new Set(["this"]);var HC=dw,xw=class xw extends N{constructor(e={}){super(e)}};n(xw,"ObjectIdentifierExpr"),xw.key="objectIdentifier",xw.availableArgs=new Set(["this"]);var _C=xw,UO=class UO extends be{constructor(e={}){super(e)}get left(){return this.args.this}get right(){return this.args.expression}};n(UO,"BinaryExpr"),UO.key="binary",UO.requiredArgs=new Set(["this","expression"]),UO.availableArgs=new Set(["this","expression"]);var v=UO,vO=class vO extends be{constructor(e={}){super(e)}};n(vO,"UnaryExpr"),vO.key="unary",vO.requiredArgs=new Set(["this"]),vO.availableArgs=new Set(["this"]);var qs=vO,xk=class xk extends Oe{constructor(e={}){super(e)}};n(xk,"PivotAliasExpr"),xk.key="pivotAlias";var WC=xk,FO=class FO extends be{constructor(e={}){super(e)}get outputName(){return this.args.expressions?.length===1?this.args.expressions[0].outputName:super.outputName}};n(FO,"BracketExpr"),FO.key="bracket",FO.requiredArgs=new Set,FO.availableArgs=new Set(["this","expressions","offset","safe","returnsListForMaps","jsonAccess"]);var wt=FO,BO=class BO extends te{constructor(e={}){super(e)}interval(){return new qe({this:this.args.expression?.copy(),unit:this.unit?.copy()})}};n(BO,"IntervalOpExpr"),BO.key="intervalOp",BO.requiredArgs=new Set(["expression"]),BO.availableArgs=new Set(["unit","expression"]);var Zs=BO,$O=class $O extends d{constructor(e={}){super(e)}};n($O,"IntervalSpanExpr"),$O.key="intervalSpan",$O.requiredArgs=new Set(["this","expression"]),$O.availableArgs=new Set(["this","expression"]);var Wr=$O,GO=class GO extends te{constructor(e={}){super(e)}};n(GO,"IntervalExpr"),GO.key="interval",GO.requiredArgs=new Set,GO.availableArgs=new Set(["this","unit"]);var qe=GO,Ir=class Ir extends be{constructor(e={}){super(e)}static fromArgList(e){let t=this.argOrder;if(t.length===0&&(t=Array.from(this.availableArgs)),this.isVarLenArgs){let s=t.slice(0,-1),r=s.length,i={};for(let o=0;o<s.length;o++)i[s[o]]=e[o];return i[t[t.length-1]]=e.slice(r),new this(i)}else{let s={};for(let r=0;r<t.length;r++)s[t[r]]=e[r];return new this(s)}}static sqlNames(){if(this===Ir)throw new Error("SQL name is only supported by concrete function implementations");if(!Object.hasOwn(this,"_sqlNames")){let t=this.name.replace(/Expr$/,"").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").toUpperCase();this._sqlNames=[t]}return this._sqlNames}static sqlName(){let e=this.sqlNames();if(!e.length)throw new Error(`Expected non-empty 'sql_names' for Func: ${this.name}.`);return e[0]}static defaultParserMappings(){let e={};for(let t of this.sqlNames())e[t]=this.fromArgList.bind(this);return e}static register(){this===Ir||this===D||iV(this)}};n(Ir,"FuncExpr"),Ir.key="func",Ir.requiredArgs=new Set,Ir.isVarLenArgs=!1,Ir.argOrder=[],Ir._sqlNames=[];var E=Ir,fw=class fw extends E{constructor(e={}){super(e)}};n(fw,"AggFuncExpr"),fw.key="aggFunc",fw.argOrder=["this"];var D=fw,YO=class YO extends Ut{constructor(e={}){super(e)}};n(YO,"JsonPathFilterExpr"),YO.key="jsonPathFilter",YO.requiredArgs=new Set(["this"]),YO.availableArgs=new Set(["this"]);var Vs=YO,VO=class VO extends Ut{constructor(e={}){super(e)}};n(VO,"JsonPathKeyExpr"),VO.key="jsonPathKey",VO.requiredArgs=new Set(["this"]),VO.availableArgs=new Set(["this"]);var kt=VO,Tw=class Tw extends Ut{constructor(e={}){super(e)}};n(Tw,"JsonPathRecursiveExpr"),Tw.key="jsonPathRecursive",Tw.availableArgs=new Set(["this"]);var fr=Tw,HO=class HO extends Ut{constructor(e={}){super(e)}};n(HO,"JsonPathRootExpr"),HO.key="jsonPathRoot",HO.requiredArgs=new Set,HO.availableArgs=new Set;var Qt=HO,_O=class _O extends Ut{constructor(e={}){super(e)}};n(_O,"JsonPathScriptExpr"),_O.key="jsonPathScript",_O.requiredArgs=new Set(["this"]),_O.availableArgs=new Set(["this"]);var Hs=_O,Sw=class Sw extends Ut{constructor(e={}){super(e)}};n(Sw,"JsonPathSliceExpr"),Sw.key="jsonPathSlice",Sw.availableArgs=new Set(["start","end","step"]);var Tr=Sw,WO=class WO extends Ut{constructor(e={}){super(e)}};n(WO,"JsonPathSelectorExpr"),WO.key="jsonPathSelector",WO.requiredArgs=new Set(["this"]),WO.availableArgs=new Set(["this"]);var ci=WO,jO=class jO extends Ut{constructor(e={}){super(e)}};n(jO,"JsonPathSubscriptExpr"),jO.key="jsonPathSubscript",jO.requiredArgs=new Set(["this"]),jO.availableArgs=new Set(["this"]);var ts=jO,XO=class XO extends Ut{constructor(e={}){super(e)}};n(XO,"JsonPathUnionExpr"),XO.key="jsonPathUnion",XO.requiredArgs=new Set(["expressions"]),XO.availableArgs=new Set(["expressions"]);var Sr=XO,JO=class JO extends Ut{constructor(e={}){super(e)}};n(JO,"JsonPathWildcardExpr"),JO.key="jsonPathWildcard",JO.requiredArgs=new Set,JO.availableArgs=new Set;var qt=JO,zO=class zO extends bs{constructor(e={}){super(e)}};n(zO,"MergeExpr"),zO.key="merge",zO.requiredArgs=new Set(["this","using","whens"]),zO.availableArgs=new Set(["this","using","on","usingCond","whens","with","returning"]);var YA=zO,Rw=class Rw extends Ct{constructor(e={}){super(e)}};n(Rw,"LateralExpr"),Rw.key="lateral",Rw.availableArgs=new Set(["this","view","outer","alias","crossApply","ordinality"]);var bt=Rw,Ow=class Ow extends Ct{constructor(e={}){super(e)}};n(Ow,"TableFromRowsExpr"),Ow.key="tableFromRows",Ow.availableArgs=new Set(["this","alias","joins","pivots","sample"]);var _l=Ow,fk=class fk extends Ge{constructor(e={}){super(e)}};n(fk,"UnionExpr"),fk.key="union";var or=fk,Tk=class Tk extends Ge{constructor(e={}){super(e)}};n(Tk,"ExceptExpr"),Tk.key="except";var cr=Tk,Sk=class Sk extends Ge{constructor(e={}){super(e)}};n(Sk,"IntersectExpr"),Sk.key="intersect";var ei=Sk,QO=class QO extends Ct{constructor(e={}){super(e)}};n(QO,"ValuesExpr"),QO.key="values",QO.requiredArgs=new Set(["expressions"]),QO.availableArgs=new Set(["expressions","alias","order","limit","offset"]);var tr=QO,Rk=class Rk extends ke{constructor(e={}){super(e)}};n(Rk,"SubqueryPredicateExpr"),Rk.key="subqueryPredicate";var Us=Rk,Ok=class Ok extends v{constructor(e={}){super(e)}};n(Ok,"AddExpr"),Ok.key="add";var we=Ok,mk=class mk extends v{constructor(e={}){super(e)}};n(mk,"ConnectorExpr"),mk.key="connector";var Ae=mk,mw=class mw extends v{constructor(e={}){super(e)}};n(mw,"BitwiseAndExpr"),mw.key="bitwiseAnd",mw.availableArgs=new Set(["this","expression","padside"]);var rh=mw,Nw=class Nw extends v{constructor(e={}){super(e)}};n(Nw,"BitwiseLeftShiftExpr"),Nw.key="bitwiseLeftShift",Nw.availableArgs=new Set(["this","expression","requiresInt128"]);var jC=Nw,Iw=class Iw extends v{constructor(e={}){super(e)}};n(Iw,"BitwiseOrExpr"),Iw.key="bitwiseOr",Iw.availableArgs=new Set(["this","expression","padside"]);var XC=Iw,yw=class yw extends v{constructor(e={}){super(e)}};n(yw,"BitwiseRightShiftExpr"),yw.key="bitwiseRightShift",yw.availableArgs=new Set(["this","expression","requiresInt128"]);var ih=yw,Cw=class Cw extends v{constructor(e={}){super(e)}};n(Cw,"BitwiseXorExpr"),Cw.key="bitwiseXor",Cw.availableArgs=new Set(["this","expression","padside"]);var JC=Cw,bw=class bw extends v{constructor(e={}){super(e)}get left(){return this.args.this}get right(){return this.args.expression}};n(bw,"DivExpr"),bw.key="div",bw.availableArgs=new Set(["this","expression","typed","safe"]);var Mt=bw,Nk=class Nk extends v{constructor(e={}){super(e)}};n(Nk,"OverlapsExpr"),Nk.key="overlaps";var zC=Nk,Ik=class Ik extends v{constructor(e={}){super(e)}};n(Ik,"ExtendsLeftExpr"),Ik.key="extendsLeft";var nh=Ik,yk=class yk extends v{constructor(e={}){super(e)}};n(yk,"ExtendsRightExpr"),yk.key="extendsRight";var ah=yk,Pw=class Pw extends v{constructor(e={}){super(e)}get isStar(){return this.args.expression?.isStar??!1}get name(){return this.args.expression?.name??""}get outputName(){return this.name}static build(e){if(e.length<2)throw new Error("Dot requires >= 2 expressions.");return e.reduce((t,s)=>new Pw({this:t,expression:s}))}get parts(){let[e,...t]=this.flatten(),s=[...t];s.reverse();for(let r of U_){let i=e.args[r];i instanceof d&&s.push(i)}return s.reverse(),s}};n(Pw,"DotExpr"),Pw.key="dot";var ge=Pw,Lw=class Lw extends v{constructor(e={}){super(e)}};n(Lw,"DPipeExpr"),Lw.key="dPipe",Lw.availableArgs=new Set(["this","expression","safe"]);var jt=Lw,ZO=class ZO extends V(v,ke){constructor(e={}){super(e)}};n(ZO,"EqExpr"),ZO.key="eq",ZO.requiredArgs=new Set(["this","expression"]),ZO.availableArgs=new Set(["this","expression"]);var Me=ZO,KO=class KO extends V(v,ke){constructor(e={}){super(e)}};n(KO,"NullSafeEqExpr"),KO.key="nullSafeEq",KO.requiredArgs=new Set(["this","expression"]),KO.availableArgs=new Set(["this","expression"]);var Ks=KO,em=class em extends V(v,ke){constructor(e={}){super(e)}};n(em,"NullSafeNeqExpr"),em.key="nullSafeNeq",em.requiredArgs=new Set(["this","expression"]),em.availableArgs=new Set(["this","expression"]);var Ur=em,Ck=class Ck extends v{constructor(e={}){super(e)}};n(Ck,"PropertyEqExpr"),Ck.key="propertyEq";var ot=Ck,bk=class bk extends v{constructor(e={}){super(e)}};n(bk,"DistanceExpr"),bk.key="distance";var QC=bk,Pk=class Pk extends v{constructor(e={}){super(e)}};n(Pk,"EscapeExpr"),Pk.key="escape";var Ba=Pk,tm=class tm extends V(v,ke){constructor(e={}){super(e)}};n(tm,"GlobExpr"),tm.key="glob",tm.requiredArgs=new Set(["this","expression"]),tm.availableArgs=new Set(["this","expression"]);var wA=tm,sm=class sm extends V(v,ke){constructor(e={}){super(e)}};n(sm,"GtExpr"),sm.key="gt",sm.requiredArgs=new Set(["this","expression"]),sm.availableArgs=new Set(["this","expression"]);var je=sm,rm=class rm extends V(v,ke){constructor(e={}){super(e)}};n(rm,"GteExpr"),rm.key="gte",rm.requiredArgs=new Set(["this","expression"]),rm.availableArgs=new Set(["this","expression"]);var Je=rm,im=class im extends V(v,ke){constructor(e={}){super(e)}};n(im,"ILikeExpr"),im.key="iLike",im.requiredArgs=new Set(["this","expression"]),im.availableArgs=new Set(["this","expression"]);var Gs=im,Lk=class Lk extends v{constructor(e={}){super(e)}};n(Lk,"IntDivExpr"),Lk.key="intDiv";var Un=Lk,nm=class nm extends V(v,ke){constructor(e={}){super(e)}};n(nm,"IsExpr"),nm.key="is",nm.requiredArgs=new Set(["this","expression"]),nm.availableArgs=new Set(["this","expression"]);var ze=nm,wk=class wk extends v{constructor(e={}){super(e)}};n(wk,"KwargExpr"),wk.key="kwarg";var oh=wk,am=class am extends V(v,ke){constructor(e={}){super(e)}};n(am,"LikeExpr"),am.key="like",am.requiredArgs=new Set(["this","expression"]),am.availableArgs=new Set(["this","expression"]);var Zt=am,om=class om extends V(v,ke){constructor(e={}){super(e)}};n(om,"MatchExpr"),om.key="match",om.requiredArgs=new Set(["this","expression"]),om.availableArgs=new Set(["this","expression"]);var Fq=om,cm=class cm extends V(v,ke){constructor(e={}){super(e)}};n(cm,"LtExpr"),cm.key="lt",cm.requiredArgs=new Set(["this","expression"]),cm.availableArgs=new Set(["this","expression"]);var Fe=cm,pm=class pm extends V(v,ke){constructor(e={}){super(e)}};n(pm,"LteExpr"),pm.key="lte",pm.requiredArgs=new Set(["this","expression"]),pm.availableArgs=new Set(["this","expression"]);var nt=pm,Mk=class Mk extends v{constructor(e={}){super(e)}};n(Mk,"ModExpr"),Mk.key="mod";var jr=Mk,kk=class kk extends v{constructor(e={}){super(e)}};n(kk,"MulExpr"),kk.key="mul";var Ts=kk,lm=class lm extends V(v,ke){constructor(e={}){super(e)}};n(lm,"NeqExpr"),lm.key="neq",lm.requiredArgs=new Set(["this","expression"]),lm.availableArgs=new Set(["this","expression"]);var xt=lm,Dk=class Dk extends v{constructor(e={}){super(e)}};n(Dk,"NestedJsonSelectExpr"),Dk.key="nestedJsonSelect";var Bq=Dk,um=class um extends v{constructor(e={}){super(e)}};n(um,"OperatorExpr"),um.key="operator",um.requiredArgs=new Set(["this","operator","expression"]),um.availableArgs=new Set(["this","operator","expression"]);var ch=um,hm=class hm extends V(v,ke){constructor(e={}){super(e)}};n(hm,"SimilarToExpr"),hm.key="similarTo",hm.requiredArgs=new Set(["this","expression"]),hm.availableArgs=new Set(["this","expression"]);var ZC=hm,qk=class qk extends v{constructor(e={}){super(e)}};n(qk,"SubExpr"),qk.key="sub";var Ce=qk,Uk=class Uk extends v{constructor(e={}){super(e)}};n(Uk,"AdjacentExpr"),Uk.key="adjacent";var ph=Uk,vk=class vk extends qs{constructor(e={}){super(e)}};n(vk,"BitwiseNotExpr"),vk.key="bitwiseNot";var lh=vk,Fk=class Fk extends qs{constructor(e={}){super(e)}};n(Fk,"NotExpr"),Fk.key="not";var Le=Fk,Bk=class Bk extends qs{constructor(e={}){super(e)}get outputName(){return this.args.this?.name??""}};n(Bk,"ParenExpr"),Bk.key="paren";var Re=Bk,$k=class $k extends qs{constructor(e={}){super(e)}toValue(){return this.isNumber?(this.args.this?.toValue()??0)*-1:super.toValue()}};n($k,"NegExpr"),$k.key="neg";var Pt=$k,gm=class gm extends ke{constructor(e={}){super(e)}};n(gm,"BetweenExpr"),gm.key="between",gm.requiredArgs=new Set(["this","low","high"]),gm.availableArgs=new Set(["this","low","high","symmetric"]);var Ss=gm,ww=class ww extends ke{constructor(e={}){super(e)}};n(ww,"InExpr"),ww.key="in",ww.availableArgs=new Set(["this","expressions","query","unnest","field","isGlobal"]);var lt=ww,Em=class Em extends E{constructor(e={}){super(e)}};n(Em,"SafeFuncExpr"),Em.key="safeFunc",Em.argOrder=["this"],Em.register();var Ub=Em,Am=class Am extends E{constructor(e={}){super(e)}};n(Am,"TypeofExpr"),Am.key="typeof",Am.argOrder=["this"],Am.register();var $q=Am,dm=class dm extends E{constructor(e={}){super(e)}};n(dm,"AcosExpr"),dm.key="acos",dm.argOrder=["this"],dm.register();var Wb=dm,xm=class xm extends E{constructor(e={}){super(e)}};n(xm,"AcoshExpr"),xm.key="acosh",xm.argOrder=["this"],xm.register();var jb=xm,fm=class fm extends E{constructor(e={}){super(e)}};n(fm,"AsinExpr"),fm.key="asin",fm.argOrder=["this"],fm.register();var Xb=fm,Tm=class Tm extends E{constructor(e={}){super(e)}};n(Tm,"AsinhExpr"),Tm.key="asinh",Tm.argOrder=["this"],Tm.register();var Jb=Tm,Wh=class Wh extends E{constructor(e={}){super(e)}};n(Wh,"AtanExpr"),Wh.key="atan",Wh.availableArgs=new Set(["this","expression"]),Wh.argOrder=["this","expression"],Wh.register();var zb=Wh,Sm=class Sm extends E{constructor(e={}){super(e)}};n(Sm,"AtanhExpr"),Sm.key="atanh",Sm.argOrder=["this"],Sm.register();var Qb=Sm,Xa=class Xa extends E{constructor(e={}){super(e)}};n(Xa,"Atan2Expr"),Xa.key="atan2",Xa.requiredArgs=new Set(["this","expression"]),Xa.availableArgs=new Set(["this","expression"]),Xa.argOrder=["this","expression"],Xa.register();var Gq=Xa,Rm=class Rm extends E{constructor(e={}){super(e)}};n(Rm,"CotExpr"),Rm.key="cot",Rm.argOrder=["this"],Rm.register();var Zb=Rm,Om=class Om extends E{constructor(e={}){super(e)}};n(Om,"CothExpr"),Om.key="coth",Om.argOrder=["this"],Om.register();var Yq=Om,mm=class mm extends E{constructor(e={}){super(e)}};n(mm,"CosExpr"),mm.key="cos",mm.argOrder=["this"],mm.register();var Kb=mm,Nm=class Nm extends E{constructor(e={}){super(e)}};n(Nm,"CscExpr"),Nm.key="csc",Nm.argOrder=["this"],Nm.register();var Vq=Nm,Im=class Im extends E{constructor(e={}){super(e)}};n(Im,"CschExpr"),Im.key="csch",Im.argOrder=["this"],Im.register();var Hq=Im,ym=class ym extends E{constructor(e={}){super(e)}};n(ym,"SecExpr"),ym.key="sec",ym.argOrder=["this"],ym.register();var _q=ym,Cm=class Cm extends E{constructor(e={}){super(e)}};n(Cm,"SechExpr"),Cm.key="sech",Cm.argOrder=["this"],Cm.register();var Wq=Cm,bm=class bm extends E{constructor(e={}){super(e)}};n(bm,"SinExpr"),bm.key="sin",bm.argOrder=["this"],bm.register();var eP=bm,Pm=class Pm extends E{constructor(e={}){super(e)}};n(Pm,"SinhExpr"),Pm.key="sinh",Pm.argOrder=["this"],Pm.register();var tP=Pm,Lm=class Lm extends E{constructor(e={}){super(e)}};n(Lm,"TanExpr"),Lm.key="tan",Lm.argOrder=["this"],Lm.register();var sP=Lm,wm=class wm extends E{constructor(e={}){super(e)}};n(wm,"TanhExpr"),wm.key="tanh",wm.argOrder=["this"],wm.register();var rP=wm,Mm=class Mm extends E{constructor(e={}){super(e)}};n(Mm,"DegreesExpr"),Mm.key="degrees",Mm.argOrder=["this"],Mm.register();var iP=Mm,km=class km extends E{constructor(e={}){super(e)}};n(km,"CoshExpr"),km.key="cosh",km.argOrder=["this"],km.register();var nP=km,Ja=class Ja extends E{constructor(e={}){super(e)}};n(Ja,"CosineDistanceExpr"),Ja.key="cosineDistance",Ja.requiredArgs=new Set(["this","expression"]),Ja.availableArgs=new Set(["this","expression"]),Ja.argOrder=["this","expression"],Ja.register();var jq=Ja,za=class za extends E{constructor(e={}){super(e)}};n(za,"DotProductExpr"),za.key="dotProduct",za.requiredArgs=new Set(["this","expression"]),za.availableArgs=new Set(["this","expression"]),za.argOrder=["this","expression"],za.register();var Xq=za,Qa=class Qa extends E{constructor(e={}){super(e)}};n(Qa,"EuclideanDistanceExpr"),Qa.key="euclideanDistance",Qa.requiredArgs=new Set(["this","expression"]),Qa.availableArgs=new Set(["this","expression"]),Qa.argOrder=["this","expression"],Qa.register();var Jq=Qa,Za=class Za extends E{constructor(e={}){super(e)}};n(Za,"ManhattanDistanceExpr"),Za.key="manhattanDistance",Za.requiredArgs=new Set(["this","expression"]),Za.availableArgs=new Set(["this","expression"]),Za.argOrder=["this","expression"],Za.register();var zq=Za,Ka=class Ka extends E{constructor(e={}){super(e)}};n(Ka,"JarowinklerSimilarityExpr"),Ka.key="jarowinklerSimilarity",Ka.requiredArgs=new Set(["this","expression"]),Ka.availableArgs=new Set(["this","expression","caseInsensitive"]),Ka.argOrder=["this","expression"],Ka.register();var Qq=Ka,Dm=class Dm extends E{constructor(e={}){super(e)}};n(Dm,"BitwiseCountExpr"),Dm.key="bitwiseCount",Dm.argOrder=["this"],Dm.register();var Zq=Dm,qm=class qm extends E{constructor(e={}){super(e)}};n(qm,"BitmapBucketNumberExpr"),qm.key="bitmapBucketNumber",qm.argOrder=["this"],qm.register();var Kq=qm,Um=class Um extends E{constructor(e={}){super(e)}};n(Um,"BitmapCountExpr"),Um.key="bitmapCount",Um.argOrder=["this"],Um.register();var eU=Um,vm=class vm extends E{constructor(e={}){super(e)}};n(vm,"BitmapBitPositionExpr"),vm.key="bitmapBitPosition",vm.argOrder=["this"],vm.register();var tU=vm,Fm=class Fm extends E{constructor(e={}){super(e)}};n(Fm,"ByteLengthExpr"),Fm.key="byteLength",Fm.argOrder=["this"],Fm.register();var sU=Fm,jh=class jh extends E{constructor(e={}){super(e)}};n(jh,"BoolnotExpr"),jh.key="boolnot",jh.availableArgs=new Set(["this","roundInput"]),jh.argOrder=["this","roundInput"],jh.register();var rU=jh,eo=class eo extends E{constructor(e={}){super(e)}};n(eo,"BoolandExpr"),eo.key="booland",eo.requiredArgs=new Set(["this","expression"]),eo.availableArgs=new Set(["this","expression","roundInput"]),eo.argOrder=["this","expression","roundInput"],eo.register();var iU=eo,to=class to extends E{constructor(e={}){super(e)}};n(to,"BoolorExpr"),to.key="boolor",to.requiredArgs=new Set(["this","expression"]),to.availableArgs=new Set(["this","expression","roundInput"]),to.argOrder=["this","expression","roundInput"],to.register();var nU=to,Bm=class Bm extends E{constructor(e={}){super(e)}};n(Bm,"JsonBoolExpr"),Bm.key="jsonBool",Bm.argOrder=["this"],Bm.register();var aU=Bm,so=class so extends E{constructor(e={}){super(e)}};n(so,"ArrayRemoveExpr"),so.key="arrayRemove",so.requiredArgs=new Set(["this","expression"]),so.availableArgs=new Set(["this","expression","nullPropagation"]),so.argOrder=["this","expression","nullPropagation"],so.register();var uh=so,$m=class $m extends E{constructor(e={}){super(e)}};n($m,"AbsExpr"),$m.key="abs",$m.argOrder=["this"],$m.register();var aP=$m,Xh=class Xh extends E{constructor(e={}){super(e)}};n(Xh,"ApproxTopKEstimateExpr"),Xh.key="approxTopKEstimate",Xh.availableArgs=new Set(["this","expression"]),Xh.argOrder=["this","expression"],Xh.register();var oU=Xh,Jh=class Jh extends E{constructor(e={}){super(e)}};n(Jh,"CityHash64Expr"),Jh.key="cityHash64",Jh.isVarLenArgs=!0,Jh.availableArgs=new Set(["expressions"]),Jh.register();var cU=Jh,yr=class yr extends E{constructor(e={}){super(e)}};n(yr,"FarmFingerprintExpr"),yr.key="farmFingerprint",yr.isVarLenArgs=!0,yr._sqlNames=["FARM_FINGERPRINT","FARMFINGERPRINT64"],yr.requiredArgs=new Set(["expressions"]),yr.availableArgs=new Set(["expressions"]),yr.argOrder=["expressions"],yr.register();var pU=yr,Gm=class Gm extends E{constructor(e={}){super(e)}};n(Gm,"FlattenExpr"),Gm.key="flatten",Gm.argOrder=["this"],Gm.register();var lU=Gm,zh=class zh extends E{constructor(e={}){super(e)}};n(zh,"Float64Expr"),zh.key="float64",zh.availableArgs=new Set(["this","expression"]),zh.argOrder=["this","expression"],zh.register();var uU=zh,ro=class ro extends E{constructor(e={}){super(e)}};n(ro,"TransformExpr"),ro.key="transform",ro.requiredArgs=new Set(["this","expression"]),ro.availableArgs=new Set(["this","expression"]),ro.argOrder=["this","expression"],ro.register();var hU=ro,io=class io extends E{constructor(e={}){super(e)}};n(io,"TranslateExpr"),io.key="translate",io.requiredArgs=new Set(["this","from","to"]),io.availableArgs=new Set(["this","from","to"]),io.argOrder=["this","from","to"],io.register();var oP=io,no=class no extends E{constructor(e={}){super(e)}get name(){let e=this.args.this;return e===void 0?"":e instanceof d?e.name:e.toString()}};n(no,"AnonymousExpr"),no.key="anonymous",no.isVarLenArgs=!0,no.availableArgs=new Set(["this","expressions"]),no.argOrder=["this","expressions"],no.register();var Qe=no,ao=class ao extends E{constructor(e={}){super(e)}};n(ao,"ApplyExpr"),ao.key="apply",ao.requiredArgs=new Set(["this","expression"]),ao.availableArgs=new Set(["this","expression"]),ao.argOrder=["this","expression"],ao.register();var gU=ao,gi=class gi extends E{constructor(e={}){super(e)}};n(gi,"ArrayExpr"),gi.key="array",gi.isVarLenArgs=!0,gi.requiredArgs=new Set,gi.availableArgs=new Set(["expressions","bracketNotation","structNameInheritance"]),gi.argOrder=["expressions","bracketNotation","structNameInheritance"],gi.register();var ue=gi,Ym=class Ym extends E{constructor(e={}){super(e)}};n(Ym,"AsciiExpr"),Ym.key="ascii",Ym.argOrder=["this"],Ym.register();var cP=Ym,Vm=class Vm extends E{constructor(e={}){super(e)}};n(Vm,"ToArrayExpr"),Vm.key="toArray",Vm.argOrder=["this"],Vm.register();var EU=Vm,Qh=class Qh extends E{constructor(e={}){super(e)}};n(Qh,"ToBooleanExpr"),Qh.key="toBoolean",Qh.availableArgs=new Set(["this","safe"]),Qh.argOrder=["this","safe"],Qh.register();var AU=Qh,Zh=class Zh extends E{constructor(e={}){super(e)}};n(Zh,"ToVariantExpr"),Zh.key="toVariant",Zh.availableArgs=new Set(["this"]),Zh.argOrder=["this"],Zh.register();var dU=Zh,Ei=class Ei extends E{constructor(e={}){super(e)}};n(Ei,"ListExpr"),Ei.key="list",Ei.requiredArgs=new Set,Ei.isVarLenArgs=!0,Ei.availableArgs=new Set(["expressions"]),Ei.argOrder=["expressions"],Ei.register();var KC=Ei,oo=class oo extends E{constructor(e={}){super(e)}};n(oo,"PadExpr"),oo.key="pad",oo.requiredArgs=new Set(["this","expression","isLeft"]),oo.availableArgs=new Set(["this","expression","fillPattern","isLeft"]),oo.argOrder=["this","expression","fillPattern","isLeft"],oo.register();var eb=oo,Kh=class Kh extends E{constructor(e={}){super(e)}};n(Kh,"ToCharExpr"),Kh.key="toChar",Kh.availableArgs=new Set(["this","format","nlsparam","isNumeric"]),Kh.argOrder=["this","format","nlsparam","isNumeric"],Kh.register();var QL=Kh,Hm=class Hm extends E{constructor(e={}){super(e)}};n(Hm,"ToCodePointsExpr"),Hm.key="toCodePoints",Hm.argOrder=["this"],Hm.register();var xU=Hm,eg=class eg extends E{constructor(e={}){super(e)}};n(eg,"ToNumberExpr"),eg.key="toNumber",eg.availableArgs=new Set(["this","format","nlsparam","precision","scale","safe","safeName"]),eg.argOrder=["this","format","nlsparam","precision","scale","safe","safeName"],eg.register();var fU=eg,tg=class tg extends E{constructor(e={}){super(e)}};n(tg,"ToDoubleExpr"),tg.key="toDouble",tg.availableArgs=new Set(["this","format","safe"]),tg.argOrder=["this","format","safe"],tg.register();var pP=tg,sg=class sg extends E{constructor(e={}){super(e)}};n(sg,"ToDecfloatExpr"),sg.key="toDecfloat",sg.availableArgs=new Set(["this","format"]),sg.argOrder=["this","format"],sg.register();var TU=sg,rg=class rg extends E{constructor(e={}){super(e)}};n(rg,"TryToDecfloatExpr"),rg.key="tryToDecfloat",rg.availableArgs=new Set(["this","format"]),rg.argOrder=["this","format"],rg.register();var SU=rg,ig=class ig extends E{constructor(e={}){super(e)}};n(ig,"ToFileExpr"),ig.key="toFile",ig.availableArgs=new Set(["this","path","safe"]),ig.argOrder=["this","path","safe"],ig.register();var RU=ig,_m=class _m extends E{constructor(e={}){super(e)}};n(_m,"CodePointsToBytesExpr"),_m.key="codePointsToBytes",_m.argOrder=["this"],_m.register();var OU=_m,ng=class ng extends E{constructor(e={}){super(e)}};n(ng,"ColumnsExpr"),ng.key="columns",ng.availableArgs=new Set(["this","unpack"]),ng.argOrder=["this","unpack"],ng.register();var tb=ng,co=class co extends E{constructor(e={}){super(e)}};n(co,"ConvertExpr"),co.key="convert",co.requiredArgs=new Set(["this","expression"]),co.availableArgs=new Set(["this","expression","style","safe"]),co.argOrder=["this","expression","style","safe"],co.register();var mU=co,po=class po extends E{constructor(e={}){super(e)}};n(po,"ConvertToCharsetExpr"),po.key="convertToCharset",po.requiredArgs=new Set(["this","dest"]),po.availableArgs=new Set(["this","dest","source"]),po.argOrder=["this","dest","source"],po.register();var vb=po,lo=class lo extends E{constructor(e={}){super(e)}};n(lo,"ConvertTimezoneExpr"),lo.key="convertTimezone",lo.requiredArgs=new Set(["targetTz","timestamp"]),lo.availableArgs=new Set(["sourceTz","targetTz","timestamp","options"]),lo.argOrder=["sourceTz","targetTz","timestamp","options"],lo.register();var vn=lo,Wm=class Wm extends E{constructor(e={}){super(e)}};n(Wm,"CodePointsToStringExpr"),Wm.key="codePointsToString",Wm.argOrder=["this"],Wm.register();var NU=Wm,uo=class uo extends E{constructor(e={}){super(e)}};n(uo,"GenerateSeriesExpr"),uo.key="generateSeries",uo.requiredArgs=new Set(["start","end"]),uo.availableArgs=new Set(["start","end","step","isEndExclusive"]),uo.argOrder=["start","end","step","isEndExclusive"],uo.register();var As=uo,ho=class ho extends V(E,Ct){constructor(e={}){super(e)}};n(ho,"GeneratorExpr"),ho.key="generator",ho.argOrder=["rowcount","timelimit"],ho.requiredArgs=new Set,ho.availableArgs=new Set(["rowcount","timelimit"]),ho.register();var IU=ho,Ai=class Ai extends E{constructor(e={}){super(e)}};n(Ai,"AiClassifyExpr"),Ai.key="aiClassify",Ai._sqlNames=["AI_CLASSIFY"],Ai.requiredArgs=new Set(["this","categories"]),Ai.availableArgs=new Set(["this","categories","config"]),Ai.argOrder=["this","categories","config"],Ai.register();var yU=Ai,go=class go extends E{constructor(e={}){super(e)}};n(go,"ArrayAllExpr"),go.key="arrayAll",go.requiredArgs=new Set(["this","expression"]),go.availableArgs=new Set(["this","expression"]),go.argOrder=["this","expression"],go.register();var CU=go,Eo=class Eo extends E{constructor(e={}){super(e)}};n(Eo,"ArrayAnyExpr"),Eo.key="arrayAny",Eo.requiredArgs=new Set(["this","expression"]),Eo.availableArgs=new Set(["this","expression"]),Eo.argOrder=["this","expression"],Eo.register();var bU=Eo,Ao=class Ao extends E{constructor(e={}){super(e)}};n(Ao,"ArrayAppendExpr"),Ao.key="arrayAppend",Ao.requiredArgs=new Set(["this","expression"]),Ao.availableArgs=new Set(["this","expression","nullPropagation"]),Ao.argOrder=["this","expression","nullPropagation"],Ao.register();var sb=Ao,xo=class xo extends E{constructor(e={}){super(e)}};n(xo,"ArrayPrependExpr"),xo.key="arrayPrepend",xo.requiredArgs=new Set(["this","expression"]),xo.availableArgs=new Set(["this","expression","nullPropagation"]),xo.argOrder=["this","expression","nullPropagation"],xo.register();var rb=xo,di=class di extends E{constructor(e={}){super(e)}};n(di,"ArrayConcatExpr"),di.key="arrayConcat",di._sqlNames=["ARRAY_CONCAT","ARRAY_CAT"],di.isVarLenArgs=!0,di.availableArgs=new Set(["this","expressions","nullPropagation"]),di.argOrder=["this","expressions","nullPropagation"],di.register();var hh=di,jm=class jm extends E{constructor(e={}){super(e)}};n(jm,"ArrayCompactExpr"),jm.key="arrayCompact",jm.argOrder=["this"],jm.register();var PU=jm,Xm=class Xm extends E{constructor(e={}){super(e)}};n(Xm,"ArrayDistinctExpr"),Xm.key="arrayDistinct",Xm.argOrder=["this","checkNull"],Xm.register();var LU=Xm,ag=class ag extends E{constructor(e={}){super(e)}};n(ag,"ArrayExceptExpr"),ag.key="arrayExcept",ag.availableArgs=new Set(["this","expression","isMultiset"]),ag.argOrder=["this","expression"],ag.register();var wU=ag,Jm=class Jm extends E{constructor(e={}){super(e)}};n(Jm,"ArrayMaxExpr"),Jm.key="arrayMax",Jm.argOrder=["this"],Jm.register();var MU=Jm,zm=class zm extends E{constructor(e={}){super(e)}};n(zm,"ArrayMinExpr"),zm.key="arrayMin",zm.argOrder=["this"],zm.register();var kU=zm,fo=class fo extends E{constructor(e={}){super(e)}};n(fo,"ArrayInsertExpr"),fo.key="arrayInsert",fo.requiredArgs=new Set(["this","position","expression"]),fo.availableArgs=new Set(["this","position","expression","offset"]),fo.argOrder=["this","position","expression","offset"],fo.register();var DU=fo,To=class To extends E{constructor(e={}){super(e)}};n(To,"ArrayRemoveAtExpr"),To.key="arrayRemoveAt",To.requiredArgs=new Set(["this","position"]),To.availableArgs=new Set(["this","position"]),To.argOrder=["this","position"],To.register();var qU=To,xi=class xi extends E{constructor(e={}){super(e)}};n(xi,"ArrayConstructCompactExpr"),xi.key="arrayConstructCompact",xi.requiredArgs=new Set,xi.isVarLenArgs=!0,xi.availableArgs=new Set(["expressions"]),xi.argOrder=["expressions"],xi.register();var UU=xi,fi=class fi extends V(v,E){constructor(e={}){super(e)}};n(fi,"ArrayContainsExpr"),fi.key="arrayContains",fi._sqlNames=["ARRAY_CONTAINS","ARRAY_HAS"],fi.argOrder=["this","expression"],fi.requiredArgs=new Set(["this","expression"]),fi.availableArgs=new Set(["this","expression","ensureVariant","checkNull"]),fi.register();var lP=fi,So=class So extends V(v,E){constructor(e={}){super(e)}};n(So,"ArrayContainsAllExpr"),So.key="arrayContainsAll",So._sqlNames=["ARRAY_CONTAINS_ALL","ARRAY_HAS_ALL"],So.requiredArgs=new Set(["this","expression"]),So.availableArgs=new Set(["this","expression"]),So.register();var Fn=So,Ti=class Ti extends E{constructor(e={}){super(e)}};n(Ti,"ArrayFilterExpr"),Ti.key="arrayFilter",Ti._sqlNames=["FILTER","ARRAY_FILTER"],Ti.requiredArgs=new Set(["this","expression"]),Ti.availableArgs=new Set(["this","expression"]),Ti.argOrder=["this","expression"],Ti.register();var Va=Ti,og=class og extends E{constructor(e={}){super(e)}};n(og,"ArrayFirstExpr"),og.key="arrayFirst",og.availableArgs=new Set(["this","expression"]),og.argOrder=["this","expression"],og.register();var uP=og,Qm=class Qm extends E{constructor(e={}){super(e)}};n(Qm,"ArrayLastExpr"),Qm.key="arrayLast",Qm.argOrder=["this"],Qm.register();var hP=Qm,cg=class cg extends V(v,E){constructor(e={}){super(e)}};n(cg,"ArrayPositionExpr"),cg.key="arrayPosition",cg.availableArgs=new Set(["this","expression","zeroBased"]),cg.argOrder=["this","expression"],cg.register();var vU=cg,Zm=class Zm extends E{constructor(e={}){super(e)}};n(Zm,"ArrayReverseExpr"),Zm.key="arrayReverse",Zm.argOrder=["this"],Zm.register();var gP=Zm,Ro=class Ro extends E{constructor(e={}){super(e)}};n(Ro,"ArraySliceExpr"),Ro.key="arraySlice",Ro.requiredArgs=new Set(["this","start"]),Ro.availableArgs=new Set(["this","start","end","step","zeroBased"]),Ro.argOrder=["this","start","end","step"],Ro.register();var EP=Ro,Si=class Si extends E{constructor(e={}){super(e)}};n(Si,"ArrayToStringExpr"),Si.key="arrayToString",Si._sqlNames=["ARRAY_TO_STRING","ARRAY_JOIN"],Si.requiredArgs=new Set(["this","expression"]),Si.availableArgs=new Set(["this","expression","null","nullIsEmpty","nullDelimIsNull"]),Si.argOrder=["this","expression","null"],Si.register();var AP=Si,Cr=class Cr extends E{constructor(e={}){super(e)}};n(Cr,"ArrayIntersectExpr"),Cr.key="arrayIntersect",Cr.isVarLenArgs=!0,Cr._sqlNames=["ARRAY_INTERSECT","ARRAY_INTERSECTION"],Cr.requiredArgs=new Set(["expressions"]),Cr.availableArgs=new Set(["expressions","isMultiset"]),Cr.argOrder=["expressions"],Cr.register();var MA=Cr,Ri=class Ri extends E{constructor(e={}){super(e)}};n(Ri,"StPointExpr"),Ri.key="stPoint",Ri._sqlNames=["ST_POINT","ST_MAKEPOINT"],Ri.requiredArgs=new Set(["this","expression"]),Ri.availableArgs=new Set(["this","expression","null"]),Ri.argOrder=["this","expression","null"],Ri.register();var FU=Ri,Oo=class Oo extends E{constructor(e={}){super(e)}};n(Oo,"StDistanceExpr"),Oo.key="stDistance",Oo.requiredArgs=new Set(["this","expression"]),Oo.availableArgs=new Set(["this","expression","useSpheroid"]),Oo.argOrder=["this","expression","useSpheroid"],Oo.register();var BU=Oo,pg=class pg extends E{constructor(e={}){super(e)}};n(pg,"StringExpr"),pg.key="string",pg.availableArgs=new Set(["this","zone"]),pg.argOrder=["this","zone"],pg.register();var dP=pg,mo=class mo extends E{constructor(e={}){super(e)}};n(mo,"StringToArrayExpr"),mo.key="stringToArray",mo._sqlNames=["STRING_TO_ARRAY","SPLIT_BY_STRING","STRTOK_TO_ARRAY"],mo.availableArgs=new Set(["this","expression","null"]),mo.argOrder=["this","expression","null"],mo.register();var $U=mo,lg=class lg extends V(v,E){constructor(e={}){super(e)}};n(lg,"ArrayOverlapsExpr"),lg.key="arrayOverlaps",lg.requiredArgs=new Set(["this","expression"]),lg.availableArgs=new Set(["this","expression","nullsafe"]),lg.register();var Fb=lg,No=class No extends E{constructor(e={}){super(e)}};n(No,"ArraySizeExpr"),No.key="arraySize",No._sqlNames=["ARRAY_SIZE","ARRAY_LENGTH"],No.availableArgs=new Set(["this","expression"]),No.argOrder=["this","expression"],No.register();var Rr=No,ug=class ug extends E{constructor(e={}){super(e)}};n(ug,"ArraySortExpr"),ug.key="arraySort",ug.availableArgs=new Set(["this","expression"]),ug.argOrder=["this","expression"],ug.register();var GU=ug,hg=class hg extends E{constructor(e={}){super(e)}};n(hg,"ArraySumExpr"),hg.key="arraySum",hg.availableArgs=new Set(["this","expression"]),hg.argOrder=["this","expression"],hg.register();var YU=hg,Oi=class Oi extends E{constructor(e={}){super(e)}};n(Oi,"ArraysZipExpr"),Oi.key="arraysZip",Oi.requiredArgs=new Set,Oi.isVarLenArgs=!0,Oi.availableArgs=new Set(["expressions"]),Oi.argOrder=["expressions"],Oi.register();var VU=Oi,Io=class Io extends E{constructor(e={}){super(e)}when(e,t,s={}){let{copy:r=!0}=s,i=$e(this,r);return i.append("ifs",new xe({this:j(e,s),true:j(t,s)})),i}else(e,t={}){let{copy:s=!0}=t,r=$e(this,s);return r.setArgKey("default",j(e,t)),r}};n(Io,"CaseExpr"),Io.key="case",Io.requiredArgs=new Set(["ifs"]),Io.availableArgs=new Set(["this","ifs","default"]),Io.argOrder=["this","ifs","default"],Io.register();var ut=Io,yo=class yo extends E{constructor(e={}){super(e)}get name(){return this.args.this.name||""}get to(){return this.args.to}get outputName(){return this.name}isType(e,t={}){let s=this.args.to;return s&&s instanceof N?s.isType(e):!1}};n(yo,"CastExpr"),yo.key="cast",yo.requiredArgs=new Set(["this","to"]),yo.availableArgs=new Set(["this","to","format","safe","action","default"]),yo.argOrder=["this","to","format","safe","action","default"],yo.register();var z=yo,Km=class Km extends E{constructor(e={}){super(e)}};n(Km,"JustifyDaysExpr"),Km.key="justifyDays",Km.argOrder=["this"],Km.register();var xP=Km,eN=class eN extends E{constructor(e={}){super(e)}};n(eN,"JustifyHoursExpr"),eN.key="justifyHours",eN.argOrder=["this"],eN.register();var fP=eN,tN=class tN extends E{constructor(e={}){super(e)}};n(tN,"JustifyIntervalExpr"),tN.key="justifyInterval",tN.argOrder=["this"],tN.register();var TP=tN,sN=class sN extends E{constructor(e={}){super(e)}};n(sN,"TryExpr"),sN.key="try",sN.argOrder=["this"],sN.register();var HU=sN,Co=class Co extends E{constructor(e={}){super(e)}};n(Co,"CastToStrTypeExpr"),Co.key="castToStrType",Co.requiredArgs=new Set(["this","to"]),Co.availableArgs=new Set(["this","to"]),Co.argOrder=["this","to"],Co.register();var ib=Co,rN=class rN extends E{constructor(e={}){super(e)}};n(rN,"CheckJsonExpr"),rN.key="checkJson",rN.argOrder=["this"],rN.register();var _U=rN,gg=class gg extends E{constructor(e={}){super(e)}};n(gg,"CheckXmlExpr"),gg.key="checkXml",gg.availableArgs=new Set(["this","disableAutoConvert"]),gg.argOrder=["this","disableAutoConvert"],gg.register();var WU=gg,Eg=class Eg extends V(v,E){constructor(e={}){super(e)}};n(Eg,"CollateExpr"),Eg.key="collate",Eg.requiredArgs=new Set(["this","expression"]),Eg.availableArgs=new Set(["this","expression"]),Eg.register();var kA=Eg,iN=class iN extends E{constructor(e={}){super(e)}};n(iN,"CollationExpr"),iN.key="collation",iN.argOrder=["this"],iN.register();var jU=iN,bo=class bo extends E{constructor(e={}){super(e)}};n(bo,"CeilExpr"),bo.key="ceil",bo._sqlNames=["CEIL","CEILING"],bo.availableArgs=new Set(["this","decimals","to"]),bo.argOrder=["this","decimals","to"],bo.register();var ti=bo,mi=class mi extends E{constructor(e={}){super(e)}};n(mi,"CoalesceExpr"),mi.key="coalesce",mi._sqlNames=["COALESCE","IFNULL","NVL"],mi.isVarLenArgs=!0,mi.availableArgs=new Set(["this","expressions","isNvl","isNull"]),mi.argOrder=["this","expressions","isNvl","isNull"],mi.register();var tt=mi,br=class br extends E{constructor(e={}){super(e)}};n(br,"ChrExpr"),br.key="chr",br._sqlNames=["CHR","CHAR"],br.isVarLenArgs=!0,br.requiredArgs=new Set(["expressions"]),br.availableArgs=new Set(["expressions","charset"]),br.argOrder=["expressions","charset"],br.register();var gh=br,Ni=class Ni extends E{constructor(e={}){super(e)}static fromArgList(e){let t=super.fromArgList(e);return t.getArgKey("safe")===void 0&&t.setArgKey("safe",!0),t.getArgKey("coalesce")===void 0&&t.setArgKey("coalesce",!1),t}};n(Ni,"ConcatExpr"),Ni.key="concat",Ni.isVarLenArgs=!0,Ni.requiredArgs=new Set(["expressions"]),Ni.availableArgs=new Set(["expressions","safe","coalesce"]),Ni.argOrder=["expressions"],Ni.register();var $t=Ni,Po=class Po extends E{constructor(e={}){super(e)}};n(Po,"ContainsExpr"),Po.key="contains",Po.requiredArgs=new Set(["this","expression"]),Po.availableArgs=new Set(["this","expression","jsonScope"]),Po.argOrder=["this","expression","jsonScope"],Po.register();var SP=Po,nN=class nN extends E{constructor(e={}){super(e)}};n(nN,"ConnectByRootExpr"),nN.key="connectByRoot",nN.argOrder=["this"],nN.register();var Eh=nN,aN=class aN extends E{constructor(e={}){super(e)}};n(aN,"CbrtExpr"),aN.key="cbrt",aN.argOrder=["this"],aN.register();var Ah=aN,Lo=class Lo extends E{constructor(e={}){super(e)}};n(Lo,"CurrentAccountExpr"),Lo.key="currentAccount",Lo.requiredArgs=new Set,Lo.availableArgs=new Set,Lo.argOrder=["this"],Lo.register();var XU=Lo,wo=class wo extends E{constructor(e={}){super(e)}};n(wo,"CurrentAccountNameExpr"),wo.key="currentAccountName",wo.requiredArgs=new Set,wo.availableArgs=new Set,wo.argOrder=["this"],wo.register();var JU=wo,Mo=class Mo extends E{constructor(e={}){super(e)}};n(Mo,"CurrentAvailableRolesExpr"),Mo.key="currentAvailableRoles",Mo.requiredArgs=new Set,Mo.availableArgs=new Set,Mo.argOrder=["this"],Mo.register();var zU=Mo,ko=class ko extends E{constructor(e={}){super(e)}};n(ko,"CurrentClientExpr"),ko.key="currentClient",ko.requiredArgs=new Set,ko.availableArgs=new Set,ko.argOrder=["this"],ko.register();var QU=ko,Do=class Do extends E{constructor(e={}){super(e)}};n(Do,"CurrentIpAddressExpr"),Do.key="currentIpAddress",Do.requiredArgs=new Set,Do.availableArgs=new Set,Do.argOrder=["this"],Do.register();var ZU=Do,qo=class qo extends E{constructor(e={}){super(e)}};n(qo,"CurrentDatabaseExpr"),qo.key="currentDatabase",qo.requiredArgs=new Set,qo.availableArgs=new Set,qo.argOrder=["this"],qo.register();var KU=qo,Ag=class Ag extends E{constructor(e={}){super(e)}};n(Ag,"CurrentSchemasExpr"),Ag.key="currentSchemas",Ag.requiredArgs=new Set,Ag.argOrder=["this"],Ag.register();var ev=Ag,Uo=class Uo extends E{constructor(e={}){super(e)}};n(Uo,"CurrentSecondaryRolesExpr"),Uo.key="currentSecondaryRoles",Uo.requiredArgs=new Set,Uo.availableArgs=new Set,Uo.argOrder=["this"],Uo.register();var tv=Uo,vo=class vo extends E{constructor(e={}){super(e)}};n(vo,"CurrentSessionExpr"),vo.key="currentSession",vo.requiredArgs=new Set,vo.availableArgs=new Set,vo.argOrder=["this"],vo.register();var sv=vo,Fo=class Fo extends E{constructor(e={}){super(e)}};n(Fo,"CurrentStatementExpr"),Fo.key="currentStatement",Fo.requiredArgs=new Set,Fo.availableArgs=new Set,Fo.argOrder=["this"],Fo.register();var rv=Fo,Bo=class Bo extends E{constructor(e={}){super(e)}};n(Bo,"CurrentVersionExpr"),Bo.key="currentVersion",Bo.requiredArgs=new Set,Bo.availableArgs=new Set,Bo.argOrder=["this"],Bo.register();var RP=Bo,$o=class $o extends E{constructor(e={}){super(e)}};n($o,"CurrentTransactionExpr"),$o.key="currentTransaction",$o.requiredArgs=new Set,$o.availableArgs=new Set,$o.argOrder=["this"],$o.register();var iv=$o,Go=class Go extends E{constructor(e={}){super(e)}};n(Go,"CurrentWarehouseExpr"),Go.key="currentWarehouse",Go.requiredArgs=new Set,Go.availableArgs=new Set,Go.argOrder=["this"],Go.register();var nv=Go,dg=class dg extends E{constructor(e={}){super(e)}};n(dg,"CurrentDateExpr"),dg.key="currentDate",dg.requiredArgs=new Set,dg.argOrder=["this"],dg.register();var pr=dg,xg=class xg extends E{constructor(e={}){super(e)}};n(xg,"CurrentDatetimeExpr"),xg.key="currentDatetime",xg.requiredArgs=new Set,xg.argOrder=["this"],xg.register();var OP=xg,fg=class fg extends E{constructor(e={}){super(e)}};n(fg,"CurrentTimeExpr"),fg.key="currentTime",fg.requiredArgs=new Set,fg.argOrder=["this"],fg.register();var si=fg,Tg=class Tg extends E{constructor(e={}){super(e)}};n(Tg,"LocaltimeExpr"),Tg.key="localtime",Tg.requiredArgs=new Set,Tg.argOrder=["this"],Tg.register();var dh=Tg,Sg=class Sg extends E{constructor(e={}){super(e)}};n(Sg,"LocaltimestampExpr"),Sg.key="localtimestamp",Sg.requiredArgs=new Set,Sg.argOrder=["this"],Sg.register();var nb=Sg,Rg=class Rg extends E{constructor(e={}){super(e)}};n(Rg,"SystimestampExpr"),Rg.key="systimestamp",Rg.requiredArgs=new Set,Rg.argOrder=["this"],Rg.register();var av=Rg,Ii=class Ii extends E{constructor(e={}){super(e)}};n(Ii,"CurrentTimestampExpr"),Ii.key="currentTimestamp",Ii._sqlNames=["CURRENT_TIMESTAMP"],Ii.requiredArgs=new Set,Ii.availableArgs=new Set(["this","sysdate"]),Ii.argOrder=["this","sysdate"],Ii.register();var ri=Ii,Yo=class Yo extends E{constructor(e={}){super(e)}};n(Yo,"CurrentTimestampLtzExpr"),Yo.key="currentTimestampLtz",Yo.requiredArgs=new Set,Yo.availableArgs=new Set,Yo.argOrder=["this"],Yo.register();var mP=Yo,Vo=class Vo extends E{constructor(e={}){super(e)}};n(Vo,"CurrentTimezoneExpr"),Vo.key="currentTimezone",Vo.requiredArgs=new Set,Vo.availableArgs=new Set,Vo.argOrder=["this"],Vo.register();var ov=Vo,Ho=class Ho extends E{constructor(e={}){super(e)}};n(Ho,"CurrentOrganizationNameExpr"),Ho.key="currentOrganizationName",Ho.requiredArgs=new Set,Ho.availableArgs=new Set,Ho.argOrder=["this"],Ho.register();var cv=Ho,Og=class Og extends E{constructor(e={}){super(e)}};n(Og,"CurrentSchemaExpr"),Og.key="currentSchema",Og.requiredArgs=new Set,Og.argOrder=["this"],Og.register();var NP=Og,mg=class mg extends E{constructor(e={}){super(e)}};n(mg,"CurrentUserExpr"),mg.key="currentUser",mg.requiredArgs=new Set,mg.argOrder=["this"],mg.register();var xh=mg,_o=class _o extends E{constructor(e={}){super(e)}};n(_o,"CurrentCatalogExpr"),_o.key="currentCatalog",_o.requiredArgs=new Set,_o.availableArgs=new Set,_o.argOrder=["this"],_o.register();var Mh=_o,Wo=class Wo extends E{constructor(e={}){super(e)}};n(Wo,"CurrentRegionExpr"),Wo.key="currentRegion",Wo.requiredArgs=new Set,Wo.availableArgs=new Set,Wo.argOrder=["this"],Wo.register();var pv=Wo,jo=class jo extends E{constructor(e={}){super(e)}};n(jo,"CurrentRoleExpr"),jo.key="currentRole",jo.requiredArgs=new Set,jo.availableArgs=new Set,jo.argOrder=["this"],jo.register();var ab=jo,Xo=class Xo extends E{constructor(e={}){super(e)}};n(Xo,"CurrentRoleTypeExpr"),Xo.key="currentRoleType",Xo.requiredArgs=new Set,Xo.availableArgs=new Set,Xo.argOrder=["this"],Xo.register();var lv=Xo,Jo=class Jo extends E{constructor(e={}){super(e)}};n(Jo,"CurrentOrganizationUserExpr"),Jo.key="currentOrganizationUser",Jo.requiredArgs=new Set,Jo.availableArgs=new Set,Jo.argOrder=["this"],Jo.register();var uv=Jo,zo=class zo extends E{constructor(e={}){super(e)}};n(zo,"SessionUserExpr"),zo.key="sessionUser",zo.requiredArgs=new Set,zo.availableArgs=new Set,zo.argOrder=["this"],zo.register();var kh=zo,Qo=class Qo extends E{constructor(e={}){super(e)}};n(Qo,"UtcDateExpr"),Qo.key="utcDate",Qo.requiredArgs=new Set,Qo.availableArgs=new Set,Qo.argOrder=["this"],Qo.register();var Bb=Qo,Ng=class Ng extends E{constructor(e={}){super(e)}};n(Ng,"UtcTimeExpr"),Ng.key="utcTime",Ng.requiredArgs=new Set,Ng.argOrder=["this"],Ng.register();var $b=Ng,Ig=class Ig extends E{constructor(e={}){super(e)}};n(Ig,"UtcTimestampExpr"),Ig.key="utcTimestamp",Ig.requiredArgs=new Set,Ig.argOrder=["this"],Ig.register();var Gb=Ig,Zo=class Zo extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(Zo,"DateAddExpr"),Zo.key="dateAdd",Zo.argOrder=["this","expression","unit"],Zo.requiredArgs=new Set(["this","expression"]),Zo.availableArgs=new Set(["this","expression","unit"]),Zo.register();var ft=Zo,Ko=class Ko extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(Ko,"DateBinExpr"),Ko.key="dateBin",Ko.argOrder=["this","expression","unit","zone","origin"],Ko.requiredArgs=new Set(["this","expression"]),Ko.availableArgs=new Set(["this","expression","unit","zone","origin"]),Ko.register();var hv=Ko,ec=class ec extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(ec,"DateSubExpr"),ec.key="dateSub",ec.argOrder=["this","expression","unit"],ec.requiredArgs=new Set(["this","expression"]),ec.availableArgs=new Set(["this","expression","unit"]),ec.register();var Xt=ec,yi=class yi extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(yi,"DateDiffExpr"),yi.key="dateDiff",yi.argOrder=["this","expression","unit","zone","bigInt","datePartBoundary"],yi._sqlNames=["DATEDIFF","DATE_DIFF"],yi.requiredArgs=new Set(["this","expression"]),yi.availableArgs=new Set(["this","expression","unit","zone","bigInt","datePartBoundary"]),yi.register();var _s=yi,Ci=class Ci extends E{constructor(e={}){let t=e.unabbreviate??!0,s=e.unit;if(te.isVarLike(s)&&!(s instanceof $&&s.parts.length!==1)){let r=s.name.toUpperCase();t&&r in te.UNABBREVIATED_UNIT_NAME&&(r=te.UNABBREVIATED_UNIT_NAME[r]),e.unit=I.string(r)}delete e.unabbreviate,super(e)}get unit(){return this.args.unit}};n(Ci,"DateTruncExpr"),Ci.key="dateTrunc",Ci._sqlNames=["DATE_TRUNC"],Ci.requiredArgs=new Set(["unit","this"]),Ci.availableArgs=new Set(["unit","this","zone","inputTypePreserved"]),Ci.argOrder=["unit","this","zone","inputTypePreserved"],Ci.register();var ls=Ci,yg=class yg extends E{constructor(e={}){super(e)}};n(yg,"DatetimeExpr"),yg.key="datetime",yg.availableArgs=new Set(["this","expression"]),yg.argOrder=["this","expression"],yg.register();var IP=yg,tc=class tc extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(tc,"DatetimeAddExpr"),tc.key="datetimeAdd",tc.argOrder=["this","expression","unit"],tc.requiredArgs=new Set(["this","expression"]),tc.availableArgs=new Set(["this","expression","unit"]),tc.register();var Ds=tc,sc=class sc extends V(E,Zs){constructor(e={}){super(te.initTimeArgs(e))}};n(sc,"DatetimeSubExpr"),sc.key="datetimeSub",sc.argOrder=["this","expression","unit"],sc.requiredArgs=new Set(["this","expression"]),sc.availableArgs=new Set(["this","expression","unit"]),sc.register();var Qs=sc,rc=class rc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(rc,"DatetimeDiffExpr"),rc.key="datetimeDiff",rc.argOrder=["this","expression","unit"],rc.requiredArgs=new Set(["this","expression"]),rc.availableArgs=new Set(["this","expression","unit"]),rc.register();var yP=rc,ic=class ic extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(ic,"DatetimeTruncExpr"),ic.key="datetimeTrunc",ic.argOrder=["this","unit","zone"],ic.requiredArgs=new Set(["this","unit"]),ic.availableArgs=new Set(["this","unit","zone"]),ic.register();var gv=ic,oN=class oN extends E{constructor(e={}){super(e)}};n(oN,"DateFromUnixDateExpr"),oN.key="dateFromUnixDate",oN.argOrder=["this"],oN.register();var Ev=oN,Cg=class Cg extends E{constructor(e={}){super(e)}};n(Cg,"DayOfWeekExpr"),Cg.key="dayOfWeek",Cg._sqlNames=["DAY_OF_WEEK","DAYOFWEEK"],Cg.argOrder=["this"],Cg.register();var CP=Cg,bg=class bg extends E{constructor(e={}){super(e)}};n(bg,"DayOfWeekIsoExpr"),bg.key="dayOfWeekIso",bg._sqlNames=["DAYOFWEEK_ISO","ISODOW"],bg.argOrder=["this"],bg.register();var bP=bg,Pg=class Pg extends E{constructor(e={}){super(e)}};n(Pg,"DayOfMonthExpr"),Pg.key="dayOfMonth",Pg.argOrder=["this"],Pg._sqlNames=["DAY_OF_MONTH","DAYOFMONTH"],Pg.register();var PP=Pg,Lg=class Lg extends E{constructor(e={}){super(e)}};n(Lg,"DayOfYearExpr"),Lg.key="dayOfYear",Lg.argOrder=["this"],Lg._sqlNames=["DAY_OF_YEAR","DAYOFYEAR"],Lg.register();var LP=Lg,wg=class wg extends E{constructor(e={}){super(e)}};n(wg,"DaynameExpr"),wg.key="dayname",wg.availableArgs=new Set(["this","abbreviated"]),wg.argOrder=["this","abbreviated"],wg.register();var wP=wg,cN=class cN extends E{constructor(e={}){super(e)}};n(cN,"ToDaysExpr"),cN.key="toDays",cN.argOrder=["this"],cN.register();var Av=cN,pN=class pN extends E{static sqlNames(){return["WEEK_OF_YEAR","WEEKOFYEAR"]}constructor(e={}){super(e)}};n(pN,"WeekOfYearExpr"),pN.key="weekOfYear",pN.argOrder=["this"],pN.register();var MP=pN,Mg=class Mg extends E{constructor(e={}){super(e)}};n(Mg,"YearOfWeekExpr"),Mg.key="yearOfWeek",Mg.argOrder=["this"],Mg._sqlNames=["YEAR_OF_WEEK","YEAROFWEEK"],Mg.register();var kP=Mg,kg=class kg extends E{constructor(e={}){super(e)}};n(kg,"YearOfWeekIsoExpr"),kg.key="yearOfWeekIso",kg.argOrder=["this"],kg._sqlNames=["YEAR_OF_WEEK_ISO","YEAROFWEEKISO"],kg.register();var DP=kg,nc=class nc extends E{constructor(e={}){super(e)}};n(nc,"MonthsBetweenExpr"),nc.key="monthsBetween",nc.requiredArgs=new Set(["this","expression"]),nc.availableArgs=new Set(["this","expression","roundoff"]),nc.argOrder=["this","expression","roundoff"],nc.register();var dv=nc,ac=class ac extends E{constructor(e={}){super(e)}};n(ac,"MakeIntervalExpr"),ac.key="makeInterval",ac.requiredArgs=new Set,ac.availableArgs=new Set(["year","month","week","day","hour","minute","second"]),ac.argOrder=["year","month","week","day","hour","minute","second"],ac.register();var qP=ac,bi=class bi extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(bi,"LastDayExpr"),bi.key="lastDay",bi._sqlNames=["LAST_DAY","LAST_DAY_OF_MONTH"],bi.argOrder=["this","unit"],bi.requiredArgs=new Set(["this"]),bi.availableArgs=new Set(["this","unit"]),bi.register();var _a=bi,oc=class oc extends E{constructor(e={}){super(e)}};n(oc,"PreviousDayExpr"),oc.key="previousDay",oc.requiredArgs=new Set(["this","expression"]),oc.availableArgs=new Set(["this","expression"]),oc.argOrder=["this","expression"],oc.register();var xv=oc,lN=class lN extends E{constructor(e={}){super(e)}};n(lN,"LaxBoolExpr"),lN.key="laxBool",lN.argOrder=["this"],lN.register();var fv=lN,uN=class uN extends E{constructor(e={}){super(e)}};n(uN,"LaxFloat64Expr"),uN.key="laxFloat64",uN.argOrder=["this"],uN.register();var Tv=uN,hN=class hN extends E{constructor(e={}){super(e)}};n(hN,"LaxInt64Expr"),hN.key="laxInt64",hN.argOrder=["this"],hN.register();var Sv=hN,gN=class gN extends E{constructor(e={}){super(e)}};n(gN,"LaxStringExpr"),gN.key="laxString",gN.argOrder=["this"],gN.register();var Rv=gN,cc=class cc extends E{constructor(e={}){super(e)}};n(cc,"ExtractExpr"),cc.key="extract",cc.requiredArgs=new Set(["this","expression"]),cc.availableArgs=new Set(["this","expression"]),cc.argOrder=["this","expression"],cc.register();var lr=cc,pc=class pc extends V(E,Us){constructor(e={}){super(e)}};n(pc,"ExistsExpr"),pc.key="exists",pc.argOrder=["this","expression"],pc.requiredArgs=new Set(["this"]),pc.availableArgs=new Set(["this","expression"]),pc.register();var Ys=pc,Pi=class Pi extends E{constructor(e={}){super(e)}};n(Pi,"EltExpr"),Pi.key="elt",Pi.isVarLenArgs=!0,Pi.requiredArgs=new Set(["this","expressions"]),Pi.availableArgs=new Set(["this","expressions"]),Pi.argOrder=["this","expressions"],Pi.register();var Ov=Pi,lc=class lc extends E{constructor(e={}){super(e)}};n(lc,"TimestampExpr"),lc.key="timestamp",lc.requiredArgs=new Set,lc.availableArgs=new Set(["this","zone","withTz"]),lc.argOrder=["this","zone","withTz"],lc.register();var Lh=lc,uc=class uc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(uc,"TimestampAddExpr"),uc.key="timestampAdd",uc.argOrder=["this","expression","unit"],uc.requiredArgs=new Set(["this","expression"]),uc.availableArgs=new Set(["this","expression","unit"]),uc.register();var Fh=uc,hc=class hc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(hc,"TimestampSubExpr"),hc.key="timestampSub",hc.argOrder=["this","expression","unit"],hc.requiredArgs=new Set(["this","expression"]),hc.availableArgs=new Set(["this","expression","unit"]),hc.register();var UP=hc,gc=class gc extends V(E,te){static sqlNames(){return["TIMESTAMPDIFF","TIMESTAMP_DIFF"]}constructor(e={}){super(te.initTimeArgs(e))}};n(gc,"TimestampDiffExpr"),gc.key="timestampDiff",gc.argOrder=["this","expression","unit"],gc.requiredArgs=new Set(["this","expression"]),gc.availableArgs=new Set(["this","expression","unit"]),gc.register();var Dh=gc,Ec=class Ec extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(Ec,"TimestampTruncExpr"),Ec.key="timestampTrunc",Ec.argOrder=["this","unit","zone","inputTypePreserved"],Ec.requiredArgs=new Set(["this","unit"]),Ec.availableArgs=new Set(["this","unit","zone","inputTypePreserved"]),Ec.register();var Sn=Ec,Ac=class Ac extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(Ac,"TimeSliceExpr"),Ac.key="timeSlice",Ac.argOrder=["this","expression","unit","kind"],Ac.requiredArgs=new Set(["this","expression","unit"]),Ac.availableArgs=new Set(["this","expression","unit","kind"]),Ac.register();var mv=Ac,dc=class dc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(dc,"TimeAddExpr"),dc.key="timeAdd",dc.argOrder=["this","expression","unit"],dc.requiredArgs=new Set(["this","expression"]),dc.availableArgs=new Set(["this","expression","unit"]),dc.register();var Bh=dc,xc=class xc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(xc,"TimeSubExpr"),xc.key="timeSub",xc.argOrder=["this","expression","unit"],xc.requiredArgs=new Set(["this","expression"]),xc.availableArgs=new Set(["this","expression","unit"]),xc.register();var vP=xc,fc=class fc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(fc,"TimeDiffExpr"),fc.key="timeDiff",fc.argOrder=["this","expression","unit"],fc.requiredArgs=new Set(["this","expression"]),fc.availableArgs=new Set(["this","expression","unit"]),fc.register();var FP=fc,Tc=class Tc extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(Tc,"TimeTruncExpr"),Tc.key="timeTrunc",Tc.argOrder=["this","unit","zone"],Tc.requiredArgs=new Set(["this","unit"]),Tc.availableArgs=new Set(["this","unit","zone"]),Tc.register();var Nv=Tc,Li=class Li extends E{constructor(e={}){super(e)}};n(Li,"DateFromPartsExpr"),Li.key="dateFromParts",Li._sqlNames=["DATE_FROM_PARTS","DATEFROMPARTS"],Li.requiredArgs=new Set(["year"]),Li.availableArgs=new Set(["year","month","day","allowOverflow"]),Li.argOrder=["year","month","day","allowOverflow"],Li.register();var BP=Li,Sc=class Sc extends E{static sqlNames(){return["TIME_FROM_PARTS","TIMEFROMPARTS"]}constructor(e={}){super(e)}};n(Sc,"TimeFromPartsExpr"),Sc.key="timeFromParts",Sc.requiredArgs=new Set(["hour","min","sec"]),Sc.availableArgs=new Set(["hour","min","sec","nano","fractions","precision","overflow"]),Sc.argOrder=["hour","min","sec","nano","fractions","precision","overflow"],Sc.register();var Iv=Sc,EN=class EN extends E{constructor(e={}){super(e)}};n(EN,"DateStrToDateExpr"),EN.key="dateStrToDate",EN.argOrder=["this"],EN.register();var $P=EN,AN=class AN extends E{constructor(e={}){super(e)}};n(AN,"DateToDateStrExpr"),AN.key="dateToDateStr",AN.argOrder=["this"],AN.register();var GP=AN,dN=class dN extends E{constructor(e={}){super(e)}};n(dN,"DateToDiExpr"),dN.key="dateToDi",dN.argOrder=["this"],dN.register();var YP=dN,wi=class wi extends E{constructor(e={}){super(e)}};n(wi,"DateExpr"),wi.key="date",wi.requiredArgs=new Set,wi.isVarLenArgs=!0,wi.availableArgs=new Set(["this","zone","expressions"]),wi.argOrder=["this","zone","expressions"],wi.register();var pi=wi,xN=class xN extends E{constructor(e={}){super(e)}};n(xN,"DayExpr"),xN.key="day",xN.argOrder=["this"],xN.register();var Nr=xN,Rc=class Rc extends E{constructor(e={}){super(e)}};n(Rc,"DecodeExpr"),Rc.key="decode",Rc.requiredArgs=new Set(["this","charset"]),Rc.availableArgs=new Set(["this","charset","replace"]),Rc.argOrder=["this","charset","replace"],Rc.register();var ob=Rc,Mi=class Mi extends E{constructor(e={}){super(e)}};n(Mi,"DecodeCaseExpr"),Mi.key="decodeCase",Mi.isVarLenArgs=!0,Mi.requiredArgs=new Set(["expressions"]),Mi.availableArgs=new Set(["expressions"]),Mi.argOrder=["expressions"],Mi.register();var cb=Mi,Oc=class Oc extends E{constructor(e={}){super(e)}};n(Oc,"DecryptExpr"),Oc.key="decrypt",Oc.requiredArgs=new Set(["this","passphrase"]),Oc.availableArgs=new Set(["this","passphrase","aad","encryptionMethod","safe"]),Oc.argOrder=["this","passphrase","aad","encryptionMethod","safe"],Oc.register();var yv=Oc,mc=class mc extends E{constructor(e={}){super(e)}};n(mc,"DecryptRawExpr"),mc.key="decryptRaw",mc.requiredArgs=new Set(["this","key","iv"]),mc.availableArgs=new Set(["this","key","iv","aad","encryptionMethod","aead","safe"]),mc.argOrder=["this","key","iv","aad","encryptionMethod","aead","safe"],mc.register();var Cv=mc,fN=class fN extends E{constructor(e={}){super(e)}};n(fN,"DiToDateExpr"),fN.key="diToDate",fN.argOrder=["this"],fN.register();var VP=fN,Nc=class Nc extends E{constructor(e={}){super(e)}};n(Nc,"EncodeExpr"),Nc.key="encode",Nc.requiredArgs=new Set(["this","charset"]),Nc.availableArgs=new Set(["this","charset"]),Nc.argOrder=["this","charset"],Nc.register();var bv=Nc,Ic=class Ic extends E{constructor(e={}){super(e)}};n(Ic,"EncryptExpr"),Ic.key="encrypt",Ic.requiredArgs=new Set(["this","passphrase"]),Ic.availableArgs=new Set(["this","passphrase","aad","encryptionMethod"]),Ic.argOrder=["this","passphrase","aad","encryptionMethod"],Ic.register();var Pv=Ic,yc=class yc extends E{constructor(e={}){super(e)}};n(yc,"EncryptRawExpr"),yc.key="encryptRaw",yc.requiredArgs=new Set(["this","key","iv"]),yc.availableArgs=new Set(["this","key","iv","aad","encryptionMethod"]),yc.argOrder=["this","key","iv","aad","encryptionMethod"],yc.register();var Lv=yc,Cc=class Cc extends E{constructor(e={}){super(e)}};n(Cc,"EqualNullExpr"),Cc.key="equalNull",Cc.requiredArgs=new Set(["this","expression"]),Cc.availableArgs=new Set(["this","expression"]),Cc.argOrder=["this","expression"],Cc.register();var wv=Cc,TN=class TN extends E{constructor(e={}){super(e)}};n(TN,"ExpExpr"),TN.key="exp",TN.argOrder=["this"],TN.register();var HP=TN,SN=class SN extends E{constructor(e={}){super(e)}};n(SN,"FactorialExpr"),SN.key="factorial",SN.argOrder=["this"],SN.register();var Mv=SN,ki=class ki extends V(E,Ct){constructor(e={}){super(e)}};n(ki,"ExplodeExpr"),ki.key="explode",ki.argOrder=["this","expressions"],ki.isVarLenArgs=!0,ki.requiredArgs=new Set(["this"]),ki.availableArgs=new Set(["this","expressions"]),ki.register();var Jt=ki,RN=class RN extends E{constructor(e={}){super(e)}};n(RN,"InlineExpr"),RN.key="inline",RN.argOrder=["this"],RN.register();var Ib=RN,bc=class bc extends V(E,Ct){constructor(e={}){super(e)}get selects(){let e=super.selects,t=this.args.offset;if(t){let s=t===!0?Z("offset"):t;return[...e,s]}return e}};n(bc,"UnnestExpr"),bc.key="unnest",bc.argOrder=["expressions","alias","offset","explodeArray"],bc.requiredArgs=new Set(["expressions"]),bc.availableArgs=new Set(["expressions","alias","offset","explodeArray"]),bc.register();var Ee=bc,Dg=class Dg extends E{constructor(e={}){super(e)}};n(Dg,"FloorExpr"),Dg.key="floor",Dg.availableArgs=new Set(["this","decimals","to"]),Dg.argOrder=["this","decimals","to"],Dg.register();var fh=Dg,ON=class ON extends E{constructor(e={}){super(e)}};n(ON,"FromBase32Expr"),ON.key="fromBase32",ON.argOrder=["this"],ON.register();var _P=ON,mN=class mN extends E{constructor(e={}){super(e)}};n(mN,"FromBase64Expr"),mN.key="fromBase64",mN.argOrder=["this"],mN.register();var WP=mN,NN=class NN extends E{constructor(e={}){super(e)}};n(NN,"ToBase32Expr"),NN.key="toBase32",NN.argOrder=["this"],NN.register();var jP=NN,IN=class IN extends E{constructor(e={}){super(e)}};n(IN,"ToBase64Expr"),IN.key="toBase64",IN.argOrder=["this"],IN.register();var XP=IN,qg=class qg extends E{constructor(e={}){super(e)}};n(qg,"ToBinaryExpr"),qg.key="toBinary",qg.availableArgs=new Set(["this","format","safe"]),qg.argOrder=["this","format","safe"],qg.register();var kv=qg,Ug=class Ug extends E{constructor(e={}){super(e)}};n(Ug,"Base64DecodeBinaryExpr"),Ug.key="base64DecodeBinary",Ug.availableArgs=new Set(["this","alphabet"]),Ug.argOrder=["this","alphabet"],Ug.register();var Dv=Ug,vg=class vg extends E{constructor(e={}){super(e)}};n(vg,"Base64DecodeStringExpr"),vg.key="base64DecodeString",vg.availableArgs=new Set(["this","alphabet"]),vg.argOrder=["this","alphabet"],vg.register();var qv=vg,Fg=class Fg extends E{constructor(e={}){super(e)}};n(Fg,"Base64EncodeExpr"),Fg.key="base64Encode",Fg.availableArgs=new Set(["this","maxLineLength","alphabet"]),Fg.argOrder=["this","maxLineLength","alphabet"],Fg.register();var Uv=Fg,Bg=class Bg extends E{constructor(e={}){super(e)}};n(Bg,"TryBase64DecodeBinaryExpr"),Bg.key="tryBase64DecodeBinary",Bg.availableArgs=new Set(["this","alphabet"]),Bg.argOrder=["this","alphabet"],Bg.register();var vv=Bg,$g=class $g extends E{constructor(e={}){super(e)}};n($g,"TryBase64DecodeStringExpr"),$g.key="tryBase64DecodeString",$g.availableArgs=new Set(["this","alphabet"]),$g.argOrder=["this","alphabet"],$g.register();var Fv=$g,yN=class yN extends E{constructor(e={}){super(e)}};n(yN,"TryHexDecodeBinaryExpr"),yN.key="tryHexDecodeBinary",yN.argOrder=["this"],yN.register();var Bv=yN,CN=class CN extends E{constructor(e={}){super(e)}};n(CN,"TryHexDecodeStringExpr"),CN.key="tryHexDecodeString",CN.argOrder=["this"],CN.register();var $v=CN,Gg=class Gg extends E{constructor(e={}){super(e)}};n(Gg,"FromIso8601TimestampExpr"),Gg.key="fromIso8601Timestamp",Gg.argOrder=["this"],Gg._sqlNames=["FROM_ISO8601_TIMESTAMP"],Gg.register();var Gv=Gg,Pc=class Pc extends E{constructor(e={}){super(e)}};n(Pc,"GapFillExpr"),Pc.key="gapFill",Pc.requiredArgs=new Set(["this","tsColumn","bucketWidth"]),Pc.availableArgs=new Set(["this","tsColumn","bucketWidth","partitioningColumns","valueColumns","origin","ignoreNulls"]),Pc.argOrder=["this","tsColumn","bucketWidth","partitioningColumns","valueColumns","origin","ignoreNulls"],Pc.register();var pb=Pc,Lc=class Lc extends E{constructor(e={}){super(e)}};n(Lc,"GenerateDateArrayExpr"),Lc.key="generateDateArray",Lc.requiredArgs=new Set(["start","end"]),Lc.availableArgs=new Set(["start","end","step"]),Lc.argOrder=["start","end","step"],Lc.register();var ii=Lc,wc=class wc extends E{constructor(e={}){super(e)}};n(wc,"GenerateTimestampArrayExpr"),wc.key="generateTimestampArray",wc.requiredArgs=new Set(["start","end","step"]),wc.availableArgs=new Set(["start","end","step"]),wc.argOrder=["start","end","step"],wc.register();var JP=wc,Mc=class Mc extends E{constructor(e={}){super(e)}};n(Mc,"GetExtractExpr"),Mc.key="getExtract",Mc.requiredArgs=new Set(["this","expression"]),Mc.availableArgs=new Set(["this","expression"]),Mc.argOrder=["this","expression"],Mc.register();var Yv=Mc,kc=class kc extends E{static sqlNames(){return["GETBIT","GET_BIT"]}constructor(e={}){super(e)}};n(kc,"GetbitExpr"),kc.key="getbit",kc.requiredArgs=new Set(["this","expression"]),kc.availableArgs=new Set(["this","expression","zeroIsMsb"]),kc.argOrder=["this","expression","zeroIsMsb"],kc.register();var zP=kc,Di=class Di extends E{constructor(e={}){super(e)}};n(Di,"GreatestExpr"),Di.key="greatest",Di.isVarLenArgs=!0,Di.requiredArgs=new Set(["this","ignoreNulls"]),Di.availableArgs=new Set(["this","expressions","ignoreNulls"]),Di.argOrder=["this","expressions","ignoreNulls"],Di.register();var ni=Di,bN=class bN extends E{constructor(e={}){super(e)}};n(bN,"HexExpr"),bN.key="hex",bN.argOrder=["this"],bN.register();var $a=bN,PN=class PN extends E{constructor(e={}){super(e)}};n(PN,"HexDecodeStringExpr"),PN.key="hexDecodeString",PN.argOrder=["this"],PN.register();var Vv=PN,Yg=class Yg extends E{constructor(e={}){super(e)}};n(Yg,"HexEncodeExpr"),Yg.key="hexEncode",Yg.availableArgs=new Set(["this","case"]),Yg.argOrder=["this","case"],Yg.register();var Hv=Yg,LN=class LN extends E{constructor(e={}){super(e)}};n(LN,"HourExpr"),LN.key="hour",LN.argOrder=["this"],LN.register();var QP=LN,wN=class wN extends E{constructor(e={}){super(e)}};n(wN,"MinuteExpr"),wN.key="minute",wN.argOrder=["this"],wN.register();var _v=wN,MN=class MN extends E{constructor(e={}){super(e)}};n(MN,"SecondExpr"),MN.key="second",MN.argOrder=["this"],MN.register();var Wv=MN,Vg=class Vg extends E{constructor(e={}){super(e)}};n(Vg,"CompressExpr"),Vg.key="compress",Vg.availableArgs=new Set(["this","method"]),Vg.argOrder=["this","method"],Vg.register();var jv=Vg,Dc=class Dc extends E{constructor(e={}){super(e)}};n(Dc,"DecompressBinaryExpr"),Dc.key="decompressBinary",Dc.requiredArgs=new Set(["this","method"]),Dc.availableArgs=new Set(["this","method"]),Dc.argOrder=["this","method"],Dc.register();var Xv=Dc,qc=class qc extends E{constructor(e={}){super(e)}};n(qc,"DecompressStringExpr"),qc.key="decompressString",qc.requiredArgs=new Set(["this","method"]),qc.availableArgs=new Set(["this","method"]),qc.argOrder=["this","method"],qc.register();var Jv=qc,qi=class qi extends E{constructor(e={}){super(e)}};n(qi,"IfExpr"),qi.key="if",qi._sqlNames=["IF","IIF"],qi.requiredArgs=new Set(["this","true"]),qi.availableArgs=new Set(["this","true","false"]),qi.argOrder=["this","true","false"],qi.register();var xe=qi,Uc=class Uc extends E{constructor(e={}){super(e)}};n(Uc,"NullifExpr"),Uc.key="nullif",Uc.requiredArgs=new Set(["this","expression"]),Uc.availableArgs=new Set(["this","expression"]),Uc.argOrder=["this","expression"],Uc.register();var qh=Uc,Hg=class Hg extends E{constructor(e={}){super(e)}};n(Hg,"InitcapExpr"),Hg.key="initcap",Hg.availableArgs=new Set(["this","expression"]),Hg.argOrder=["this","expression"],Hg.register();var Th=Hg,kN=class kN extends E{constructor(e={}){super(e)}};n(kN,"IsAsciiExpr"),kN.key="isAscii",kN.argOrder=["this"],kN.register();var zv=kN,_g=class _g extends E{constructor(e={}){super(e)}};n(_g,"IsNanExpr"),_g.key="isNan",_g.argOrder=["this"],_g._sqlNames=["IS_NAN","ISNAN"],_g.register();var ZP=_g,DN=class DN extends E{constructor(e={}){super(e)}};n(DN,"Int64Expr"),DN.key="int64",DN.argOrder=["this"],DN.register();var Uh=DN,Wg=class Wg extends E{constructor(e={}){super(e)}};n(Wg,"IsInfExpr"),Wg.key="isInf",Wg.argOrder=["this"],Wg._sqlNames=["IS_INF","ISINF"],Wg.register();var KP=Wg,qN=class qN extends E{constructor(e={}){super(e)}};n(qN,"IsNullValueExpr"),qN.key="isNullValue",qN.argOrder=["this"],qN.register();var Qv=qN,UN=class UN extends E{constructor(e={}){super(e)}};n(UN,"IsArrayExpr"),UN.key="isArray",UN.argOrder=["this"],UN.register();var Zv=UN,vc=class vc extends E{constructor(e={}){super(e)}};n(vc,"FormatExpr"),vc.key="format",vc.isVarLenArgs=!0,vc.availableArgs=new Set(["this","expressions"]),vc.argOrder=["this","expressions"],vc.register();var Kv=vc,Fc=class Fc extends E{constructor(e={}){super(e)}};n(Fc,"JsonKeysExpr"),Fc.key="jsonKeys",Fc.isVarLenArgs=!0,Fc.availableArgs=new Set(["this","expression","expressions"]),Fc.argOrder=["this","expression","expressions"],Fc.register();var lb=Fc,jg=class jg extends E{constructor(e={}){super(e)}};n(jg,"JsonKeysAtDepthExpr"),jg.key="jsonKeysAtDepth",jg.availableArgs=new Set(["this","expression","mode"]),jg.argOrder=["this","expression","mode"],jg.register();var eF=jg,Xg=class Xg extends E{constructor(e={}){super(e)}};n(Xg,"JsonObjectExpr"),Xg.key="jsonObject",Xg.availableArgs=new Set(["expressions","nullHandling","uniqueKeys","returnType","encoding"]),Xg.argOrder=["nullHandling","uniqueKeys","returnType","encoding"],Xg.register();var Sh=Xg,Jg=class Jg extends E{constructor(e={}){super(e)}static fromArgList(e){return new this({expressions:e})}};n(Jg,"JsonArrayExpr"),Jg.key="jsonArray",Jg.availableArgs=new Set(["expressions","nullHandling","returnType","strict"]),Jg.argOrder=["nullHandling","returnType","strict"],Jg.register();var tF=Jg,Bc=class Bc extends E{constructor(e={}){super(e)}};n(Bc,"JsonExistsExpr"),Bc.key="jsonExists",Bc.requiredArgs=new Set(["this","path"]),Bc.availableArgs=new Set(["this","path","passing","onCondition","fromDcolonqmark"]),Bc.argOrder=["path","passing","onCondition","fromDcolonqmark"],Bc.register();var sF=Bc,Pr=class Pr extends E{constructor(e={}){super(e)}};n(Pr,"JsonSetExpr"),Pr.key="jsonSet",Pr.isVarLenArgs=!0,Pr._sqlNames=["JSON_SET"],Pr.requiredArgs=new Set(["this","expressions"]),Pr.availableArgs=new Set(["this","expressions"]),Pr.argOrder=["this","expressions"],Pr.register();var rF=Pr,$c=class $c extends E{constructor(e={}){super(e)}};n($c,"JsonStripNullsExpr"),$c.key="jsonStripNulls",$c._sqlNames=["JSON_STRIP_NULLS"],$c.availableArgs=new Set(["this","expression","includeArrays","removeEmpty"]),$c.argOrder=["this","expression","includeArrays","removeEmpty"],$c.register();var iF=$c,zg=class zg extends E{constructor(e={}){super(e)}};n(zg,"JsonValueArrayExpr"),zg.key="jsonValueArray",zg.availableArgs=new Set(["this","expression"]),zg.argOrder=["this","expression"],zg.register();var nF=zg,Lr=class Lr extends E{constructor(e={}){super(e)}};n(Lr,"JsonRemoveExpr"),Lr.key="jsonRemove",Lr.isVarLenArgs=!0,Lr._sqlNames=["JSON_REMOVE"],Lr.requiredArgs=new Set(["this","expressions"]),Lr.availableArgs=new Set(["this","expressions"]),Lr.argOrder=["this","expressions"],Lr.register();var aF=Lr,Gc=class Gc extends E{constructor(e={}){super(e)}};n(Gc,"JsonTableExpr"),Gc.key="jsonTable",Gc.requiredArgs=new Set(["this","schema"]),Gc.availableArgs=new Set(["this","schema","path","errorHandling","emptyHandling"]),Gc.argOrder=["this","schema","path","errorHandling","emptyHandling"],Gc.register();var ub=Gc,Yc=class Yc extends E{constructor(e={}){super(e)}};n(Yc,"JsonTypeExpr"),Yc.key="jsontype",Yc._sqlNames=["JSON_TYPE"],Yc.availableArgs=new Set(["this","expression"]),Yc.argOrder=["this","expression"],Yc.register();var oF=Yc,Vc=class Vc extends E{constructor(e={}){super(e)}};n(Vc,"ObjectInsertExpr"),Vc.key="objectInsert",Vc.requiredArgs=new Set(["this","key","value"]),Vc.availableArgs=new Set(["this","key","value","updateFlag"]),Vc.argOrder=["this","key","value","updateFlag"],Vc.register();var cF=Vc,Qg=class Qg extends E{constructor(e={}){super(e)}};n(Qg,"ObjectIdExpr"),Qg.key="objectId",Qg.availableArgs=new Set(["this","expression"]),Qg.argOrder=["this","expression"],Qg.register();var pF=Qg,Zg=class Zg extends E{constructor(e={}){super(e)}};n(Zg,"OpenJsonExpr"),Zg.key="openJson",Zg.availableArgs=new Set(["this","path","expressions"]),Zg.argOrder=["this","path","expressions"],Zg.register();var hb=Zg,Hc=class Hc extends V(v,E){constructor(e={}){super(e)}};n(Hc,"JsonbContainsExpr"),Hc.key="jsonbContains",Hc._sqlNames=["JSONB_CONTAINS"],Hc.requiredArgs=new Set(["this","expression"]),Hc.availableArgs=new Set(["this","expression"]),Hc.register();var gb=Hc,vN=class vN extends V(v,E){constructor(e={}){super(e)}};n(vN,"JsonbContainsAnyTopKeysExpr"),vN.key="jsonbContainsAnyTopKeys",vN.requiredArgs=new Set(["this","expression"]),vN.availableArgs=new Set(["this","expression"]);var Rh=vN,FN=class FN extends V(v,E){constructor(e={}){super(e)}};n(FN,"JsonbContainsAllTopKeysExpr"),FN.key="jsonbContainsAllTopKeys",FN.requiredArgs=new Set(["this","expression"]),FN.availableArgs=new Set(["this","expression"]);var Oh=FN,Ui=class Ui extends E{constructor(e={}){super(e)}};n(Ui,"JsonbExistsExpr"),Ui.key="jsonbExists",Ui._sqlNames=["JSONB_EXISTS"],Ui.requiredArgs=new Set(["this","path"]),Ui.availableArgs=new Set(["this","path"]),Ui.argOrder=["this","path"],Ui.register();var lF=Ui,BN=class BN extends V(v,E){constructor(e={}){super(e)}};n(BN,"JsonbDeleteAtPathExpr"),BN.key="jsonbDeleteAtPath",BN.requiredArgs=new Set(["this","expression"]),BN.availableArgs=new Set(["this","expression"]);var mh=BN,vi=class vi extends V(v,E){constructor(e={}){super(e)}get outputName(){return this.args.expressions?"":this.args.expression?.outputName??""}};n(vi,"JsonExtractExpr"),vi.key="jsonExtract",vi.isVarLenArgs=!0,vi._sqlNames=["JSON_EXTRACT"],vi.requiredArgs=new Set(["this","expression"]),vi.availableArgs=new Set(["this","expression","onlyJsonTypes","expressions","variantExtract","jsonQuery","option","quote","onCondition","requiresJson"]),vi.register();var Ns=vi,_c=class _c extends E{constructor(e={}){super(e)}};n(_c,"JsonExtractArrayExpr"),_c.key="jsonExtractArray",_c._sqlNames=["JSON_EXTRACT_ARRAY"],_c.availableArgs=new Set(["this","expression"]),_c.argOrder=["this","expression"],_c.register();var uF=_c,Fi=class Fi extends V(v,E){constructor(e={}){super(e)}get outputName(){return this.args.expression?.outputName??""}};n(Fi,"JsonExtractScalarExpr"),Fi.key="jsonExtractScalar",Fi.isVarLenArgs=!0,Fi._sqlNames=["JSON_EXTRACT_SCALAR"],Fi.requiredArgs=new Set(["this","expression"]),Fi.availableArgs=new Set(["this","expression","onlyJsonTypes","expressions","jsonType","scalarOnly"]),Fi.register();var bn=Fi,Wc=class Wc extends V(v,E){constructor(e={}){super(e)}};n(Wc,"JsonbExtractExpr"),Wc.key="jsonbExtract",Wc._sqlNames=["JSONB_EXTRACT"],Wc.requiredArgs=new Set(["this","expression"]),Wc.availableArgs=new Set(["this","expression"]),Wc.register();var Nh=Wc,jc=class jc extends V(v,E){constructor(e={}){super(e)}};n(jc,"JsonbExtractScalarExpr"),jc.key="jsonbExtractScalar",jc._sqlNames=["JSONB_EXTRACT_SCALAR"],jc.requiredArgs=new Set(["this","expression"]),jc.availableArgs=new Set(["this","expression","jsonType"]),jc.register();var Eb=jc,Xc=class Xc extends E{constructor(e={}){super(e)}};n(Xc,"JsonFormatExpr"),Xc.key="jsonFormat",Xc._sqlNames=["JSON_FORMAT"],Xc.availableArgs=new Set(["this","options","isJson","toJson"]),Xc.argOrder=["this","options","isJson","toJson"],Xc.register();var hF=Xc,wr=class wr extends E{constructor(e={}){super(e)}};n(wr,"JsonArrayAppendExpr"),wr.key="jsonArrayAppend",wr.isVarLenArgs=!0,wr._sqlNames=["JSON_ARRAY_APPEND"],wr.requiredArgs=new Set(["this","expressions"]),wr.availableArgs=new Set(["this","expressions"]),wr.argOrder=["this","expressions"],wr.register();var gF=wr,Jc=class Jc extends V(v,ke,E){constructor(e={}){super(e)}};n(Jc,"JsonArrayContainsExpr"),Jc.key="jsonArrayContains",Jc._sqlNames=["JSON_ARRAY_CONTAINS"],Jc.requiredArgs=new Set(["this","expression"]),Jc.availableArgs=new Set(["this","expression","jsonType"]),Jc.register();var EF=Jc,Mr=class Mr extends E{constructor(e={}){super(e)}};n(Mr,"JsonArrayInsertExpr"),Mr.key="jsonArrayInsert",Mr.isVarLenArgs=!0,Mr._sqlNames=["JSON_ARRAY_INSERT"],Mr.requiredArgs=new Set(["this","expressions"]),Mr.availableArgs=new Set(["this","expressions"]),Mr.argOrder=["this","expressions"],Mr.register();var AF=Mr,$N=class $N extends E{constructor(e={}){super(e)}};n($N,"ParseBignumericExpr"),$N.key="parseBignumeric",$N.argOrder=["this"],$N.register();var dF=$N,GN=class GN extends E{constructor(e={}){super(e)}};n(GN,"ParseNumericExpr"),GN.key="parseNumeric",GN.argOrder=["this"],GN.register();var xF=GN,zc=class zc extends E{constructor(e={}){super(e)}};n(zc,"ParseJsonExpr"),zc.key="parseJson",zc._sqlNames=["PARSE_JSON","JSON_PARSE"],zc.availableArgs=new Set(["this","expression","safe"]),zc.argOrder=["this","expression","safe"],zc.register();var ai=zc,Kg=class Kg extends E{constructor(e={}){super(e)}};n(Kg,"ParseUrlExpr"),Kg.key="parseUrl",Kg.availableArgs=new Set(["this","partToExtract","key","permissive"]),Kg.argOrder=["this","partToExtract","key","permissive"],Kg.register();var fF=Kg,Qc=class Qc extends E{constructor(e={}){super(e)}};n(Qc,"ParseIpExpr"),Qc.key="parseIp",Qc.requiredArgs=new Set(["this","type"]),Qc.availableArgs=new Set(["this","type","permissive"]),Qc.argOrder=["this","type","permissive"],Qc.register();var TF=Qc,Zc=class Zc extends E{constructor(e={}){super(e)}};n(Zc,"ParseTimeExpr"),Zc.key="parseTime",Zc.requiredArgs=new Set(["this","format"]),Zc.availableArgs=new Set(["this","format"]),Zc.argOrder=["this","format"],Zc.register();var SF=Zc,eE=class eE extends E{constructor(e={}){super(e)}};n(eE,"ParseDatetimeExpr"),eE.key="parseDatetime",eE.availableArgs=new Set(["this","format","zone"]),eE.argOrder=["this","format","zone"],eE.register();var RF=eE,Bi=class Bi extends E{constructor(e={}){super(e)}};n(Bi,"LeastExpr"),Bi.key="least",Bi.isVarLenArgs=!0,Bi.requiredArgs=new Set(["this","ignoreNulls"]),Bi.availableArgs=new Set(["this","expressions","ignoreNulls"]),Bi.argOrder=["this","expressions","ignoreNulls"],Bi.register();var Ih=Bi,Kc=class Kc extends E{constructor(e={}){super(e)}};n(Kc,"LeftExpr"),Kc.key="left",Kc.requiredArgs=new Set(["this","expression"]),Kc.availableArgs=new Set(["this","expression"]),Kc.argOrder=["this","expression"],Kc.register();var OF=Kc,ep=class ep extends E{constructor(e={}){super(e)}};n(ep,"RightExpr"),ep.key="right",ep.requiredArgs=new Set(["this","expression"]),ep.availableArgs=new Set(["this","expression"]),ep.argOrder=["this","expression"],ep.register();var mF=ep,YN=class YN extends E{constructor(e={}){super(e)}};n(YN,"ReverseExpr"),YN.key="reverse",YN.argOrder=["this"],YN.register();var NF=YN,tp=class tp extends E{constructor(e={}){super(e)}};n(tp,"LengthExpr"),tp.key="length",tp._sqlNames=["LENGTH","LEN","CHAR_LENGTH","CHARACTER_LENGTH"],tp.availableArgs=new Set(["this","binary","encoding"]),tp.argOrder=["this","binary","encoding"],tp.register();var $h=tp,VN=class VN extends E{constructor(e={}){super(e)}};n(VN,"RtrimmedLengthExpr"),VN.key="rtrimmedLength",VN.argOrder=["this"],VN.register();var IF=VN,HN=class HN extends E{constructor(e={}){super(e)}};n(HN,"BitLengthExpr"),HN.key="bitLength",HN.argOrder=["this"],HN.register();var eL=HN,tE=class tE extends E{constructor(e={}){super(e)}};n(tE,"LevenshteinExpr"),tE.key="levenshtein",tE.availableArgs=new Set(["this","expression","insCost","delCost","subCost","maxDist"]),tE.argOrder=["this","expression","insCost","delCost","subCost","maxDist"],tE.register();var tL=tE,_N=class _N extends E{constructor(e={}){super(e)}};n(_N,"LnExpr"),_N.key="ln",_N.argOrder=["this"],_N.register();var yh=_N,sE=class sE extends E{constructor(e={}){super(e)}};n(sE,"LogExpr"),sE.key="log",sE.availableArgs=new Set(["this","expression"]),sE.argOrder=["this","expression"],sE.register();var ur=sE,rE=class rE extends E{constructor(e={}){super(e)}};n(rE,"LowerExpr"),rE.key="lower",rE.argOrder=["this"],rE._sqlNames=["LOWER","LCASE"],rE.register();var Ar=rE,sp=class sp extends E{constructor(e={}){super(e)}get keys(){return this.args.keys?.args?.expressions||[]}get values(){return this.args.values?.args?.expressions||[]}};n(sp,"MapExpr"),sp.key="map",sp.requiredArgs=new Set,sp.availableArgs=new Set(["keys","values"]),sp.argOrder=["keys","values"],sp.register();var mn=sp,WN=class WN extends E{constructor(e={}){super(e)}};n(WN,"ToMapExpr"),WN.key="toMap",WN.argOrder=["this"],WN.register();var vh=WN,jN=class jN extends E{constructor(e={}){super(e)}};n(jN,"MapFromEntriesExpr"),jN.key="mapFromEntries",jN.argOrder=["this"],jN.register();var yF=jN,rp=class rp extends E{constructor(e={}){super(e)}};n(rp,"MapCatExpr"),rp.key="mapCat",rp.requiredArgs=new Set(["this","expression"]),rp.availableArgs=new Set(["this","expression"]),rp.argOrder=["this","expression"],rp.register();var CF=rp,ip=class ip extends E{constructor(e={}){super(e)}};n(ip,"MapContainsKeyExpr"),ip.key="mapContainsKey",ip.requiredArgs=new Set(["this","key"]),ip.availableArgs=new Set(["this","key"]),ip.argOrder=["this","key"],ip.register();var bF=ip,$i=class $i extends E{constructor(e={}){super(e)}};n($i,"MapDeleteExpr"),$i.key="mapDelete",$i.isVarLenArgs=!0,$i.requiredArgs=new Set(["this","expressions"]),$i.availableArgs=new Set(["this","expressions"]),$i.argOrder=["this","expressions"],$i.register();var PF=$i,np=class np extends E{constructor(e={}){super(e)}};n(np,"MapInsertExpr"),np.key="mapInsert",np.requiredArgs=new Set(["this","value"]),np.availableArgs=new Set(["this","key","value","updateFlag"]),np.argOrder=["this","key","value","updateFlag"],np.register();var LF=np,XN=class XN extends E{constructor(e={}){super(e)}};n(XN,"MapKeysExpr"),XN.key="mapkeys",XN.argOrder=["this"],XN.register();var wF=XN,Gi=class Gi extends E{constructor(e={}){super(e)}};n(Gi,"MapPickExpr"),Gi.key="mapPick",Gi.isVarLenArgs=!0,Gi.requiredArgs=new Set(["this","expressions"]),Gi.availableArgs=new Set(["this","expressions"]),Gi.argOrder=["this","expressions"],Gi.register();var MF=Gi,JN=class JN extends E{constructor(e={}){super(e)}};n(JN,"MapSizeExpr"),JN.key="mapSize",JN.argOrder=["this"],JN.register();var kF=JN,zN=class zN extends E{constructor(e={}){super(e)}};n(zN,"StarMapExpr"),zN.key="starMap",zN.argOrder=["this"],zN.register();var Ab=zN,Yi=class Yi extends E{constructor(e={}){super(e)}get keys(){return this.args.keys?.args.expressions??[]}get values(){return this.args.values?.args.expressions??[]}};n(Yi,"VarMapExpr"),Yi.key="varMap",Yi.isVarLenArgs=!0,Yi.requiredArgs=new Set(["keys","values"]),Yi.availableArgs=new Set(["keys","values"]),Yi.argOrder=["keys","values"],Yi.register();var Rs=Yi,ap=class ap extends E{constructor(e={}){super(e)}};n(ap,"MatchAgainstExpr"),ap.key="matchAgainst",ap.requiredArgs=new Set(["this","expressions"]),ap.availableArgs=new Set(["this","expressions","modifier"]),ap.argOrder=["this","expressions","modifier"],ap.register();var db=ap,iE=class iE extends E{constructor(e={}){super(e)}};n(iE,"Md5Expr"),iE.key="md5",iE._sqlNames=["MD5"],iE.argOrder=["this"],iE.register();var sL=iE,Vi=class Vi extends E{constructor(e={}){super(e)}};n(Vi,"Md5DigestExpr"),Vi.key="md5Digest",Vi.isVarLenArgs=!0,Vi._sqlNames=["MD5_DIGEST"],Vi.availableArgs=new Set(["this","expressions"]),Vi.argOrder=["this","expressions"],Vi.register();var DF=Vi,QN=class QN extends E{constructor(e={}){super(e)}};n(QN,"Md5NumberLower64Expr"),QN.key="md5NumberLower64",QN.argOrder=["this"],QN.register();var qF=QN,ZN=class ZN extends E{constructor(e={}){super(e)}};n(ZN,"Md5NumberUpper64Expr"),ZN.key="md5NumberUpper64",ZN.argOrder=["this"],ZN.register();var UF=ZN,KN=class KN extends E{constructor(e={}){super(e)}};n(KN,"MonthExpr"),KN.key="month",KN.argOrder=["this"],KN.register();var rL=KN,nE=class nE extends E{constructor(e={}){super(e)}};n(nE,"MonthnameExpr"),nE.key="monthname",nE.availableArgs=new Set(["this","abbreviated"]),nE.argOrder=["this","abbreviated"],nE.register();var iL=nE,op=class op extends E{constructor(e={}){super(e)}};n(op,"AddMonthsExpr"),op.key="addMonths",op.requiredArgs=new Set(["this","expression"]),op.availableArgs=new Set(["this","expression","preserveEndOfMonth"]),op.argOrder=["this","expression","preserveEndOfMonth"],op.register();var vF=op,cp=class cp extends E{constructor(e={}){super(e)}};n(cp,"Nvl2Expr"),cp.key="nvl2",cp.requiredArgs=new Set(["this","true"]),cp.availableArgs=new Set(["this","true","false"]),cp.argOrder=["this","true","false"],cp.register();var FF=cp,aE=class aE extends E{constructor(e={}){super(e)}};n(aE,"NormalizeExpr"),aE.key="normalize",aE.availableArgs=new Set(["this","form","isCasefold"]),aE.argOrder=["this","form","isCasefold"],aE.register();var xb=aE,pp=class pp extends E{constructor(e={}){super(e)}};n(pp,"NormalExpr"),pp.key="normal",pp.requiredArgs=new Set(["this","stddev","gen"]),pp.availableArgs=new Set(["this","stddev","gen"]),pp.argOrder=["this","stddev","gen"],pp.register();var BF=pp,eI=class eI extends E{constructor(e={}){super(e)}};n(eI,"NetFuncExpr"),eI.key="netFunc",eI.argOrder=["this"],eI.register();var Yb=eI,tI=class tI extends E{constructor(e={}){super(e)}};n(tI,"HostExpr"),tI.key="host",tI.argOrder=["this"],tI.register();var $F=tI,sI=class sI extends E{constructor(e={}){super(e)}};n(sI,"RegDomainExpr"),sI.key="regDomain",sI.argOrder=["this"],sI.register();var GF=sI,lp=class lp extends E{constructor(e={}){super(e)}};n(lp,"OverlayExpr"),lp.key="overlay",lp.requiredArgs=new Set(["this","expression","from"]),lp.availableArgs=new Set(["this","expression","from","for"]),lp.argOrder=["this","expression","from","for"],lp.register();var fb=lp,up=class up extends E{constructor(e={}){super(e)}};n(up,"PredictExpr"),up.key="predict",up.requiredArgs=new Set(["this","expression"]),up.availableArgs=new Set(["this","expression","paramsStruct"]),up.argOrder=["this","expression","paramsStruct"],up.register();var YF=up,hp=class hp extends E{constructor(e={}){super(e)}};n(hp,"MlTranslateExpr"),hp.key="mlTranslate",hp.requiredArgs=new Set(["this","expression","paramsStruct"]),hp.availableArgs=new Set(["this","expression","paramsStruct"]),hp.argOrder=["this","expression","paramsStruct"],hp.register();var VF=hp,oE=class oE extends E{constructor(e={}){super(e)}};n(oE,"FeaturesAtTimeExpr"),oE.key="featuresAtTime",oE.availableArgs=new Set(["this","time","numRows","ignoreFeatureNulls"]),oE.argOrder=["this","time","numRows","ignoreFeatureNulls"],oE.register();var HF=oE,gp=class gp extends E{constructor(e={}){super(e)}};n(gp,"GenerateEmbeddingExpr"),gp.key="generateEmbedding",gp.requiredArgs=new Set(["this","expression"]),gp.availableArgs=new Set(["this","expression","paramsStruct","isText"]),gp.argOrder=["this","expression","paramsStruct","isText"],gp.register();var _F=gp,cE=class cE extends E{constructor(e={}){super(e)}};n(cE,"MlForecastExpr"),cE.key="mlForecast",cE.availableArgs=new Set(["this","expression","paramsStruct"]),cE.argOrder=["this","expression","paramsStruct"],cE.register();var WF=cE,Ep=class Ep extends E{constructor(e={}){super(e)}};n(Ep,"VectorSearchExpr"),Ep.key="vectorSearch",Ep.requiredArgs=new Set(["this","columnToSearch","queryTable"]),Ep.availableArgs=new Set(["this","columnToSearch","queryTable","queryColumnToSearch","topK","distanceType","options"]),Ep.argOrder=["columnToSearch","queryTable","queryColumnToSearch","topK","distanceType","options"],Ep.register();var jF=Ep,Ap=class Ap extends E{constructor(e={}){super(e)}};n(Ap,"PiExpr"),Ap.key="pi",Ap.requiredArgs=new Set,Ap.availableArgs=new Set,Ap.argOrder=["this"],Ap.register();var nL=Ap,Hi=class Hi extends V(v,E){constructor(e={}){super(e)}};n(Hi,"PowExpr"),Hi.key="pow",Hi._sqlNames=["POWER","POW"],Hi.argOrder=["this","expression"],Hi.requiredArgs=new Set(["this","expression"]),Hi.availableArgs=new Set(["this","expression"]),Hi.register();var Gh=Hi,dp=class dp extends E{constructor(e={}){super(e)}};n(dp,"ApproxPercentileEstimateExpr"),dp.key="approxPercentileEstimate",dp.requiredArgs=new Set(["this","percentile"]),dp.availableArgs=new Set(["this","percentile"]),dp.argOrder=["this","percentile"],dp.register();var XF=dp,rI=class rI extends E{constructor(e={}){super(e)}};n(rI,"QuarterExpr"),rI.key="quarter",rI.argOrder=["this"],rI.register();var aL=rI,xp=class xp extends E{constructor(e={}){super(e)}};n(xp,"RandExpr"),xp.key="rand",xp._sqlNames=["RAND","RANDOM"],xp.availableArgs=new Set(["this","lower","upper"]),xp.argOrder=["this","lower","upper"],xp.register();var vr=xp,pE=class pE extends E{constructor(e={}){super(e)}};n(pE,"RandnExpr"),pE.key="randn",pE.requiredArgs=new Set,pE.argOrder=["this"],pE.register();var JI=pE,lE=class lE extends E{constructor(e={}){super(e)}};n(lE,"RandstrExpr"),lE.key="randstr",lE.availableArgs=new Set(["this","generator"]),lE.argOrder=["this","generator"],lE.register();var JF=lE,fp=class fp extends E{constructor(e={}){super(e)}};n(fp,"RangeNExpr"),fp.key="rangeN",fp.requiredArgs=new Set(["this","expressions"]),fp.availableArgs=new Set(["this","expressions","each"]),fp.argOrder=["this","expressions","each"],fp.register();var zF=fp,Tp=class Tp extends E{constructor(e={}){super(e)}};n(Tp,"RangeBucketExpr"),Tp.key="rangeBucket",Tp.requiredArgs=new Set(["this","expression"]),Tp.availableArgs=new Set(["this","expression"]),Tp.argOrder=["this","expression"],Tp.register();var QF=Tp,_i=class _i extends E{constructor(e={}){super(e)}};n(_i,"ReadCsvExpr"),_i.key="readCsv",_i.isVarLenArgs=!0,_i._sqlNames=["READ_CSV"],_i.availableArgs=new Set(["this","expressions"]),_i.argOrder=["this","expressions"],_i.register();var ZF=_i,Wi=class Wi extends E{constructor(e={}){super(e)}};n(Wi,"ReadParquetExpr"),Wi.key="readParquet",Wi.isVarLenArgs=!0,Wi.requiredArgs=new Set(["expressions"]),Wi.availableArgs=new Set(["expressions"]),Wi.argOrder=["expressions"],Wi.register();var KF=Wi,Sp=class Sp extends E{constructor(e={}){super(e)}};n(Sp,"ReduceExpr"),Sp.key="reduce",Sp.requiredArgs=new Set(["this","initial","merge"]),Sp.availableArgs=new Set(["this","initial","merge","finish"]),Sp.argOrder=["this","initial","merge","finish"],Sp.register();var eB=Sp,Rp=class Rp extends E{constructor(e={}){super(e)}};n(Rp,"RegexpExtractExpr"),Rp.key="regexpExtract",Rp.requiredArgs=new Set(["this","expression"]),Rp.availableArgs=new Set(["this","expression","position","occurrence","parameters","group","nullIfPosOverflow"]),Rp.argOrder=["this","expression","position","occurrence","parameters","group","nullIfPosOverflow"],Rp.register();var ZL=Rp,Op=class Op extends E{constructor(e={}){super(e)}};n(Op,"RegexpExtractAllExpr"),Op.key="regexpExtractAll",Op.requiredArgs=new Set(["this","expression"]),Op.availableArgs=new Set(["this","expression","group","parameters","position","occurrence"]),Op.argOrder=["this","expression","group","parameters","position","occurrence"],Op.register();var tB=Op,mp=class mp extends E{constructor(e={}){super(e)}};n(mp,"RegexpReplaceExpr"),mp.key="regexpReplace",mp.requiredArgs=new Set(["this","expression"]),mp.availableArgs=new Set(["this","expression","replacement","position","occurrence","modifiers","singleReplace"]),mp.argOrder=["this","expression","replacement","position","occurrence","modifiers","singleReplace"],mp.register();var sB=mp,Np=class Np extends V(v,E){constructor(e={}){super(e)}};n(Np,"RegexpLikeExpr"),Np.key="regexpLike",Np.argOrder=["this","expression","flag"],Np.requiredArgs=new Set(["this","expression"]),Np.availableArgs=new Set(["this","expression","flag","fullMatch"]),Np.register();var Ga=Np,Ip=class Ip extends V(v,E){constructor(e={}){super(e)}};n(Ip,"RegexpILikeExpr"),Ip.key="regexpIlike",Ip.argOrder=["this","expression"],Ip.requiredArgs=new Set(["this","expression"]),Ip.availableArgs=new Set(["this","expression","flag"]),Ip.register();var Tb=Ip,yp=class yp extends V(v,E){constructor(e={}){super(e)}};n(yp,"RegexpFullMatchExpr"),yp.key="regexpFullMatch",yp.argOrder=["this","expression","options"],yp.requiredArgs=new Set(["this","expression"]),yp.availableArgs=new Set(["this","expression","options"]),yp.register();var rB=yp,Cp=class Cp extends E{constructor(e={}){super(e)}};n(Cp,"RegexpInstrExpr"),Cp.key="regexpInstr",Cp.requiredArgs=new Set(["this","expression"]),Cp.availableArgs=new Set(["this","expression","position","occurrence","option","parameters","group"]),Cp.argOrder=["this","expression","position","occurrence","option","parameters","group"],Cp.register();var iB=Cp,bp=class bp extends E{constructor(e={}){super(e)}};n(bp,"RegexpSplitExpr"),bp.key="regexpSplit",bp.requiredArgs=new Set(["this","expression"]),bp.availableArgs=new Set(["this","expression","limit"]),bp.argOrder=["this","expression","limit"],bp.register();var nB=bp,Pp=class Pp extends E{constructor(e={}){super(e)}};n(Pp,"RegexpCountExpr"),Pp.key="regexpCount",Pp.requiredArgs=new Set(["this","expression"]),Pp.availableArgs=new Set(["this","expression","position","parameters"]),Pp.argOrder=["this","expression","position","parameters"],Pp.register();var aB=Pp,Lp=class Lp extends E{constructor(e={}){super(e)}};n(Lp,"RepeatExpr"),Lp.key="repeat",Lp.requiredArgs=new Set(["this","times"]),Lp.availableArgs=new Set(["this","times"]),Lp.argOrder=["this","times"],Lp.register();var oB=Lp,wp=class wp extends E{constructor(e={}){super(e)}};n(wp,"ReplaceExpr"),wp.key="replace",wp.requiredArgs=new Set(["this","expression"]),wp.availableArgs=new Set(["this","expression","replacement"]),wp.argOrder=["this","expression","replacement"],wp.register();var KL=wp,iI=class iI extends E{constructor(e={}){super(e)}};n(iI,"RadiansExpr"),iI.key="radians",iI.argOrder=["this"],iI.register();var oL=iI,uE=class uE extends E{constructor(e={}){super(e)}};n(uE,"RoundExpr"),uE.key="round",uE.availableArgs=new Set(["this","decimals","truncate","castsNonIntegerDecimals"]),uE.argOrder=["this","decimals","truncate","castsNonIntegerDecimals"],uE.register();var cL=uE,Mp=class Mp extends E{constructor(e={}){super(e)}};n(Mp,"TruncExpr"),Mp.key="trunc",Mp._sqlNames=["TRUNC","TRUNCATE"],Mp.availableArgs=new Set(["this","decimals"]),Mp.argOrder=["this","decimals"],Mp.register();var ew=Mp,kp=class kp extends E{constructor(e={}){super(e)}};n(kp,"RowNumberExpr"),kp.key="rowNumber",kp.argOrder=["this"],kp.requiredArgs=new Set,kp.availableArgs=new Set(["this"]),kp.register();var yb=kp,Dp=class Dp extends E{constructor(e={}){super(e)}};n(Dp,"Seq1Expr"),Dp.key="seq1",Dp.argOrder=["this"],Dp.requiredArgs=new Set,Dp.availableArgs=new Set(["this"]),Dp.register();var cB=Dp,qp=class qp extends E{constructor(e={}){super(e)}};n(qp,"Seq2Expr"),qp.key="seq2",qp.argOrder=["this"],qp.requiredArgs=new Set,qp.availableArgs=new Set(["this"]),qp.register();var pB=qp,Up=class Up extends E{constructor(e={}){super(e)}};n(Up,"Seq4Expr"),Up.key="seq4",Up.argOrder=["this"],Up.requiredArgs=new Set,Up.availableArgs=new Set(["this"]),Up.register();var lB=Up,vp=class vp extends E{constructor(e={}){super(e)}};n(vp,"Seq8Expr"),vp.key="seq8",vp.argOrder=["this"],vp.requiredArgs=new Set,vp.availableArgs=new Set(["this"]),vp.register();var uB=vp,Fp=class Fp extends E{constructor(e={}){super(e)}};n(Fp,"SafeAddExpr"),Fp.key="safeAdd",Fp.requiredArgs=new Set(["this","expression"]),Fp.availableArgs=new Set(["this","expression"]),Fp.argOrder=["this","expression"],Fp.register();var hB=Fp,Bp=class Bp extends E{constructor(e={}){super(e)}};n(Bp,"SafeDivideExpr"),Bp.key="safeDivide",Bp.requiredArgs=new Set(["this","expression"]),Bp.availableArgs=new Set(["this","expression"]),Bp.argOrder=["this","expression"],Bp.register();var pL=Bp,$p=class $p extends E{constructor(e={}){super(e)}};n($p,"SafeMultiplyExpr"),$p.key="safeMultiply",$p.requiredArgs=new Set(["this","expression"]),$p.availableArgs=new Set(["this","expression"]),$p.argOrder=["this","expression"],$p.register();var gB=$p,nI=class nI extends E{constructor(e={}){super(e)}};n(nI,"SafeNegateExpr"),nI.key="safeNegate",nI.argOrder=["this"],nI.register();var EB=nI,Gp=class Gp extends E{constructor(e={}){super(e)}};n(Gp,"SafeSubtractExpr"),Gp.key="safeSubtract",Gp.requiredArgs=new Set(["this","expression"]),Gp.availableArgs=new Set(["this","expression"]),Gp.argOrder=["this","expression"],Gp.register();var AB=Gp,aI=class aI extends E{constructor(e={}){super(e)}};n(aI,"SafeConvertBytesToStringExpr"),aI.key="safeConvertBytesToString",aI.argOrder=["this"],aI.register();var dB=aI,hE=class hE extends E{constructor(e={}){super(e)}};n(hE,"ShaExpr"),hE.key="sha",hE.argOrder=["this"],hE._sqlNames=["SHA","Sha1"],hE.register();var lL=hE,Yp=class Yp extends E{constructor(e={}){super(e)}};n(Yp,"Sha2Expr"),Yp.key="sha2",Yp._sqlNames=["Sha2"],Yp.availableArgs=new Set(["this","length"]),Yp.argOrder=["this","length"],Yp.register();var uL=Yp,oI=class oI extends E{constructor(e={}){super(e)}};n(oI,"Sha1DigestExpr"),oI.key="sha1Digest",oI.argOrder=["this"],oI.register();var xB=oI,gE=class gE extends E{constructor(e={}){super(e)}};n(gE,"Sha2DigestExpr"),gE.key="sha2Digest",gE.availableArgs=new Set(["this","length"]),gE.argOrder=["this","length"],gE.register();var fB=gE,EE=class EE extends E{constructor(e={}){super(e)}};n(EE,"SignExpr"),EE.key="sign",EE.argOrder=["this"],EE._sqlNames=["SIGN","SIGNUM"],EE.register();var hL=EE,AE=class AE extends E{constructor(e={}){super(e)}};n(AE,"SortArrayExpr"),AE.key="sortArray",AE.availableArgs=new Set(["this","asc","nullsFirst"]),AE.argOrder=["this","asc","nullsFirst"],AE.register();var gL=AE,cI=class cI extends E{constructor(e={}){super(e)}};n(cI,"SoundexExpr"),cI.key="soundex",cI.argOrder=["this"],cI.register();var TB=cI,pI=class pI extends E{constructor(e={}){super(e)}};n(pI,"SoundexP123Expr"),pI.key="soundexP123",pI.argOrder=["this"],pI.register();var SB=pI,Vp=class Vp extends E{constructor(e={}){super(e)}};n(Vp,"SplitExpr"),Vp.key="split",Vp.requiredArgs=new Set(["this","expression"]),Vp.availableArgs=new Set(["this","expression","limit","nullReturnsNull","emptyDelimiterReturnsWhole"]),Vp.argOrder=["this","expression","limit"],Vp.register();var RB=Vp,dE=class dE extends E{constructor(e={}){super(e)}};n(dE,"SplitPartExpr"),dE.key="splitPart",dE.availableArgs=new Set(["this","delimiter","partIndex","partIndexZeroAsOne","emptyDelimiterReturnsWhole"]),dE.argOrder=["this","delimiter","partIndex"],dE.register();var OB=dE,lI=class lI extends E{constructor(e={}){super(e)}};n(lI,"StrtokExpr"),lI.key="strtok",lI.requiredArgs=new Set(["this"]),lI.availableArgs=new Set(["this","delimiter","partIndex"]);var mB=lI,Hp=class Hp extends E{constructor(e={}){super(e)}};n(Hp,"SubstringExpr"),Hp.key="substring",Hp._sqlNames=["SUBSTRING","SUBSTR"],Hp.availableArgs=new Set(["this","start","length"]),Hp.argOrder=["this","start","length"],Hp.register();var Is=Hp,_p=class _p extends E{constructor(e={}){super(e)}};n(_p,"SubstringIndexExpr"),_p.key="substringIndex",_p.requiredArgs=new Set(["this","delimiter","count"]),_p.availableArgs=new Set(["this","delimiter","count"]),_p.argOrder=["this","delimiter","count"],_p.register();var NB=_p,xE=class xE extends E{constructor(e={}){super(e)}};n(xE,"StandardHashExpr"),xE.key="standardHash",xE.availableArgs=new Set(["this","expression"]),xE.argOrder=["this","expression"],xE.register();var IB=xE,ji=class ji extends E{constructor(e={}){super(e)}};n(ji,"StartsWithExpr"),ji.key="startsWith",ji._sqlNames=["STARTS_WITH","STARTSWITH"],ji.requiredArgs=new Set(["this","expression"]),ji.availableArgs=new Set(["this","expression"]),ji.argOrder=["this","expression"],ji.register();var Vl=ji,Xi=class Xi extends E{constructor(e={}){super(e)}};n(Xi,"EndsWithExpr"),Xi.key="endsWith",Xi._sqlNames=["ENDS_WITH","ENDSWITH"],Xi.requiredArgs=new Set(["this","expression"]),Xi.availableArgs=new Set(["this","expression"]),Xi.argOrder=["this","expression"],Xi.register();var EL=Xi,Wp=class Wp extends E{constructor(e={}){super(e)}};n(Wp,"StrPositionExpr"),Wp.key="strPosition",Wp.requiredArgs=new Set(["this","substr"]),Wp.availableArgs=new Set(["this","substr","position","occurrence","clampPosition"]),Wp.argOrder=["this","substr","position","occurrence"],Wp.register();var Bs=Wp,jp=class jp extends E{constructor(e={}){super(e)}};n(jp,"SearchExpr"),jp.key="search",jp.requiredArgs=new Set(["this","expression"]),jp.availableArgs=new Set(["this","expression","jsonScope","analyzer","analyzerOptions","searchMode"]),jp.argOrder=["this","expression","jsonScope","analyzer","analyzerOptions","searchMode"],jp.register();var yB=jp,Xp=class Xp extends E{constructor(e={}){super(e)}};n(Xp,"SearchIpExpr"),Xp.key="searchIp",Xp.requiredArgs=new Set(["this","expression"]),Xp.availableArgs=new Set(["this","expression"]),Xp.argOrder=["this","expression"],Xp.register();var CB=Xp,fE=class fE extends E{constructor(e={}){super(e)}};n(fE,"StrToDateExpr"),fE.key="strToDate",fE.availableArgs=new Set(["this","format","safe"]),fE.argOrder=["this","format","safe"],fE.register();var oi=fE,Jp=class Jp extends E{constructor(e={}){super(e)}};n(Jp,"StrToTimeExpr"),Jp.key="strToTime",Jp.requiredArgs=new Set(["this","format"]),Jp.availableArgs=new Set(["this","format","zone","safe","targetType"]),Jp.argOrder=["this","format","zone","safe","targetType"],Jp.register();var ys=Jp,zp=class zp extends E{constructor(e={}){super(e)}};n(zp,"StrToUnixExpr"),zp.key="strToUnix",zp.requiredArgs=new Set,zp.availableArgs=new Set(["this","format"]),zp.argOrder=["this","format"],zp.register();var bB=zp,TE=class TE extends E{constructor(e={}){super(e)}};n(TE,"StrToMapExpr"),TE.key="strToMap",TE.availableArgs=new Set(["this","pairDelim","keyValueDelim","duplicateResolutionCallback"]),TE.argOrder=["this","pairDelim","keyValueDelim","duplicateResolutionCallback"],TE.register();var PB=TE,Qp=class Qp extends E{constructor(e={}){super(e)}};n(Qp,"NumberToStrExpr"),Qp.key="numberToStr",Qp.requiredArgs=new Set(["this","format"]),Qp.availableArgs=new Set(["this","format","culture"]),Qp.argOrder=["this","format","culture"],Qp.register();var LB=Qp,Zp=class Zp extends E{constructor(e={}){super(e)}};n(Zp,"FromBaseExpr"),Zp.key="fromBase",Zp.requiredArgs=new Set(["this","expression"]),Zp.availableArgs=new Set(["this","expression"]),Zp.argOrder=["this","expression"],Zp.register();var wB=Zp,uI=class uI extends E{constructor(e={}){super(e)}};n(uI,"SpaceExpr"),uI.key="space",uI.argOrder=["this"],uI.register();var AL=uI,Ji=class Ji extends E{constructor(e={}){super(e)}};n(Ji,"StructExpr"),Ji.key="struct",Ji.isVarLenArgs=!0,Ji.requiredArgs=new Set([]),Ji.availableArgs=new Set(["expressions"]),Ji.argOrder=["expressions"],Ji.register();var Es=Ji,Kp=class Kp extends E{constructor(e={}){super(e)}};n(Kp,"StructExtractExpr"),Kp.key="structExtract",Kp.requiredArgs=new Set(["this","expression"]),Kp.availableArgs=new Set(["this","expression"]),Kp.argOrder=["this","expression"],Kp.register();var MB=Kp,zi=class zi extends E{constructor(e={}){super(e)}};n(zi,"StuffExpr"),zi.key="stuff",zi._sqlNames=["STUFF","INSERT"],zi.requiredArgs=new Set(["this","start","length","expression"]),zi.availableArgs=new Set(["this","start","length","expression"]),zi.argOrder=["this","start","length","expression"],zi.register();var kB=zi,hI=class hI extends E{constructor(e={}){super(e)}};n(hI,"SqrtExpr"),hI.key="sqrt",hI.argOrder=["this"],hI.register();var Ch=hI,el=class el extends E{constructor(e={}){super(e)}};n(el,"TimeExpr"),el.key="time",el.requiredArgs=new Set,el.availableArgs=new Set(["this","zone"]),el.argOrder=["this","zone"],el.register();var dL=el,tl=class tl extends E{constructor(e={}){super(e)}};n(tl,"TimeToStrExpr"),tl.key="timeToStr",tl.requiredArgs=new Set(["this","format"]),tl.availableArgs=new Set(["this","format","culture","zone"]),tl.argOrder=["this","format","culture","zone"],tl.register();var Or=tl,gI=class gI extends E{constructor(e={}){super(e)}};n(gI,"TimeToTimeStrExpr"),gI.key="timeToTimeStr",gI.argOrder=["this"],gI.register();var xL=gI,EI=class EI extends E{constructor(e={}){super(e)}};n(EI,"TimeToUnixExpr"),EI.key="timeToUnix",EI.argOrder=["this"],EI.register();var DB=EI,AI=class AI extends E{constructor(e={}){super(e)}};n(AI,"TimeStrToDateExpr"),AI.key="timeStrToDate",AI.argOrder=["this"],AI.register();var fL=AI,SE=class SE extends E{constructor(e={}){super(e)}};n(SE,"TimeStrToTimeExpr"),SE.key="timeStrToTime",SE.availableArgs=new Set(["this","zone"]),SE.argOrder=["this","zone"],SE.register();var Yh=SE,dI=class dI extends E{constructor(e={}){super(e)}};n(dI,"TimeStrToUnixExpr"),dI.key="timeStrToUnix",dI.argOrder=["this"],dI.register();var qB=dI,RE=class RE extends E{constructor(e={}){super(e)}};n(RE,"TrimExpr"),RE.key="trim",RE.availableArgs=new Set(["this","expression","position","collation"]),RE.argOrder=["this","expression","position","collation"],RE.register();var Ya=RE,sl=class sl extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}get returnType(){let e=this.args.returnType;return e instanceof N?e:N.build("date")}};n(sl,"TsOrDsAddExpr"),sl.key="tsOrDsAdd",sl.argOrder=["this","expression","unit","returnType"],sl.requiredArgs=new Set(["this","expression"]),sl.availableArgs=new Set(["this","expression","unit","returnType"]),sl.register();var Vh=sl,rl=class rl extends V(E,te){constructor(e={}){super(te.initTimeArgs(e))}};n(rl,"TsOrDsDiffExpr"),rl.key="tsOrDsDiff",rl.argOrder=["this","expression","unit"],rl.requiredArgs=new Set(["this","expression"]),rl.availableArgs=new Set(["this","expression","unit"]),rl.register();var UB=rl,xI=class xI extends E{constructor(e={}){super(e)}};n(xI,"TsOrDsToDateStrExpr"),xI.key="tsOrDsToDateStr",xI.argOrder=["this"],xI.register();var TL=xI,OE=class OE extends E{constructor(e={}){super(e)}};n(OE,"TsOrDsToDateExpr"),OE.key="tsOrDsToDate",OE.availableArgs=new Set(["this","format","safe"]),OE.argOrder=["this","format","safe"],OE.register();var os=OE,fI=class fI extends E{constructor(e={}){super(e)}};n(fI,"TsOrDsToDatetimeExpr"),fI.key="tsOrDsToDatetime",fI.argOrder=["this"],fI.register();var Vb=fI,mE=class mE extends E{constructor(e={}){super(e)}};n(mE,"TsOrDsToTimeExpr"),mE.key="tsOrDsToTime",mE.availableArgs=new Set(["this","format","safe"]),mE.argOrder=["format","safe","this"],mE.register();var Hb=mE,TI=class TI extends E{constructor(e={}){super(e)}};n(TI,"TsOrDsToTimestampExpr"),TI.key="tsOrDsToTimestamp",TI.argOrder=["this"],TI.register();var _b=TI,SI=class SI extends E{constructor(e={}){super(e)}};n(SI,"TsOrDiToDiExpr"),SI.key="tsOrDiToDi",SI.argOrder=["this"],SI.register();var SL=SI,NE=class NE extends E{constructor(e={}){super(e)}};n(NE,"UnhexExpr"),NE.key="unhex",NE.availableArgs=new Set(["this","expression"]),NE.argOrder=["this","expression"],NE.register();var vB=NE,RI=class RI extends E{constructor(e={}){super(e)}};n(RI,"UnicodeExpr"),RI.key="unicode",RI.argOrder=["this"],RI.register();var RL=RI,il=class il extends E{constructor(e={}){super(e)}};n(il,"UniformExpr"),il.key="uniform",il.requiredArgs=new Set(["this","expression"]),il.availableArgs=new Set(["this","expression","gen","seed"]),il.argOrder=["this","expression","gen","seed"],il.register();var FB=il,OI=class OI extends E{constructor(e={}){super(e)}};n(OI,"UnixDateExpr"),OI.key="unixDate",OI.argOrder=["this"],OI.register();var OL=OI,IE=class IE extends E{constructor(e={}){super(e)}};n(IE,"UnixToStrExpr"),IE.key="unixToStr",IE.availableArgs=new Set(["this","format"]),IE.argOrder=["this","format"],IE.register();var mL=IE,vt=class vt extends E{constructor(e={}){super(e)}};n(vt,"UnixToTimeExpr"),vt.key="unixToTime",vt.availableArgs=new Set(["this","scale","zone","hours","minutes","format","targetType"]),vt.argOrder=["this","scale","zone","hours","minutes","format","targetType"],vt.SECONDS=I.number(0),vt.DECIS=I.number(1),vt.CENTIS=I.number(2),vt.MILLIS=I.number(3),vt.DECIMILLIS=I.number(4),vt.CENTIMILLIS=I.number(5),vt.MICROS=I.number(6),vt.DECIMICROS=I.number(7),vt.CENTIMICROS=I.number(8),vt.NANOS=I.number(9),vt.register();var NL=vt,mI=class mI extends E{constructor(e={}){super(e)}};n(mI,"UnixToTimeStrExpr"),mI.key="unixToTimeStr",mI.argOrder=["this"],mI.register();var IL=mI,NI=class NI extends E{constructor(e={}){super(e)}};n(NI,"UnixSecondsExpr"),NI.key="unixSeconds",NI.argOrder=["this"],NI.register();var yL=NI,II=class II extends E{constructor(e={}){super(e)}};n(II,"UnixMicrosExpr"),II.key="unixMicros",II.argOrder=["this"],II.register();var CL=II,yI=class yI extends E{constructor(e={}){super(e)}};n(yI,"UnixMillisExpr"),yI.key="unixMillis",yI.argOrder=["this"],yI.register();var bL=yI,nl=class nl extends E{constructor(e={}){super(e)}};n(nl,"UuidExpr"),nl.key="uuid",nl._sqlNames=["UUID","GEN_RANDOM_UUID","GENERATE_UUID","UUID_STRING"],nl.availableArgs=new Set(["this","name","isString"]),nl.argOrder=["this","name","isString"],nl.register();var DA=nl,yj={year:!1,month:!1,day:!1,hour:!1,min:!1,sec:!1,nano:!1},Qi=class Qi extends E{constructor(e={}){super(e)}};n(Qi,"TimestampFromPartsExpr"),Qi.key="timestampFromParts",Qi._sqlNames=["TIMESTAMP_FROM_PARTS","TIMESTAMPFROMPARTS"],Qi.requiredArgs=new Set,Qi.availableArgs=new Set(["year","month","day","hour","min","sec","nano","zone","milli","this","expression"]),Qi.argOrder=["year","month","day","hour","min","sec","nano","zone","milli","this","expression"],Qi.register();var vM=Qi,al=class al extends E{constructor(e={}){super(e)}};n(al,"TimestampLtzFromPartsExpr"),al.key="timestampLtzFromParts",al.argOrder=["year","month","day","hour","min","sec","nano"],al._sqlNames=["TIMESTAMP_LTZ_FROM_PARTS","TIMESTAMPLTZFROMPARTS"],al.availableArgs=new Set(["year","month","day","hour","min","sec","nano"]),al.register();var PL=al,ol=class ol extends E{constructor(e={}){super(e)}};n(ol,"TimestampTzFromPartsExpr"),ol.key="timestampTzFromParts",ol._sqlNames=["TIMESTAMP_TZ_FROM_PARTS","TIMESTAMPTZFROMPARTS"],ol.argOrder=["year","month","day","hour","min","sec","nano","zone"],ol.availableArgs=new Set(["year","month","day","hour","min","sec","nano","zone"]),ol.register();var LL=ol,yE=class yE extends E{constructor(e={}){super(e)}};n(yE,"UpperExpr"),yE.key="upper",yE.argOrder=["this"],yE._sqlNames=["UPPER","UCASE"],yE.register();var dr=yE,cl=class cl extends V(v,D){constructor(e={}){super(e)}};n(cl,"CorrExpr"),cl.key="corr",cl.requiredArgs=new Set(["this","expression"]),cl.availableArgs=new Set(["this","expression","nullOnZeroVariance"]),cl.argOrder=["this","expression","nullOnZeroVariance"],cl.register();var BB=cl,CE=class CE extends E{constructor(e={}){super(e)}};n(CE,"WidthBucketExpr"),CE.key="widthBucket",CE.availableArgs=new Set(["this","minValue","maxValue","numBuckets","threshold"]),CE.argOrder=["this","minValue","maxValue","numBuckets","threshold"],CE.register();var $B=CE,pl=class pl extends E{constructor(e={}){super(e)}};n(pl,"WeekExpr"),pl.key="week",pl.requiredArgs=new Set,pl.availableArgs=new Set(["this","mode"]),pl.argOrder=["this","mode"],pl.register();var Ad=pl,ll=class ll extends E{constructor(e={}){super(e)}};n(ll,"NextDayExpr"),ll.key="nextDay",ll.requiredArgs=new Set(["this","expression"]),ll.availableArgs=new Set(["this","expression"]),ll.argOrder=["this","expression"],ll.register();var GB=ll,ul=class ul extends E{constructor(e={}){super(e)}};n(ul,"XmlElementExpr"),ul.key="xmlElement",ul._sqlNames=["XmlELEMENT"],ul.availableArgs=new Set(["this","expressions","evalname"]),ul.argOrder=["evalname","this","expressions"],ul.register();var Sb=ul,Zi=class Zi extends E{constructor(e={}){super(e)}};n(Zi,"XmlGetExpr"),Zi.key="xmlGet",Zi._sqlNames=["XmlGET"],Zi.requiredArgs=new Set(["this","expression"]),Zi.availableArgs=new Set(["this","expression","instance"]),Zi.argOrder=["this","expression","instance"],Zi.register();var YB=Zi,bE=class bE extends E{constructor(e={}){super(e)}};n(bE,"XmlTableExpr"),bE.key="xmlTable",bE.availableArgs=new Set(["this","namespaces","passing","columns","byRef"]),bE.argOrder=["this","namespaces","passing","columns","byRef"],bE.register();var Rb=bE,CI=class CI extends E{constructor(e={}){super(e)}};n(CI,"YearExpr"),CI.key="year",CI.argOrder=["this"],CI.register();var wL=CI,hl=class hl extends E{constructor(e={}){super(e)}};n(hl,"ZipfExpr"),hl.key="zipf",hl.requiredArgs=new Set(["this","elementcount","gen"]),hl.availableArgs=new Set(["this","elementcount","gen"]),hl.argOrder=["this","elementcount","gen"],hl.register();var VB=hl,PE=class PE extends E{constructor(e={}){super(e)}};n(PE,"NextValueForExpr"),PE.key="nextValueFor",PE.availableArgs=new Set(["this","order"]),PE.argOrder=["order","this"],PE.register();var Ob=PE,Gk=class Gk extends Us{constructor(e={}){super(e)}};n(Gk,"AllExpr"),Gk.key="all";var cs=Gk,Yk=class Yk extends Us{constructor(e={}){super(e)}};n(Yk,"AnyExpr"),Yk.key="any";var Tt=Yk,Mw=class Mw extends D{constructor(e={}){super(e)}};n(Mw,"BitwiseAndAggExpr"),Mw.key="bitwiseAndAgg",Mw.register();var HB=Mw,kw=class kw extends D{constructor(e={}){super(e)}};n(kw,"BitwiseOrAggExpr"),kw.key="bitwiseOrAgg",kw.register();var _B=kw,Dw=class Dw extends D{constructor(e={}){super(e)}};n(Dw,"BitwiseXorAggExpr"),Dw.key="bitwiseXorAgg",Dw.register();var WB=Dw,qw=class qw extends D{constructor(e={}){super(e)}};n(qw,"BoolxorAggExpr"),qw.key="boolxorAgg",qw.register();var jB=qw,Uw=class Uw extends D{constructor(e={}){super(e)}};n(Uw,"BitmapConstructAggExpr"),Uw.key="bitmapConstructAgg",Uw.register();var XB=Uw,vw=class vw extends D{constructor(e={}){super(e)}};n(vw,"BitmapOrAggExpr"),vw.key="bitmapOrAgg",vw.register();var JB=vw,gl=class gl extends D{constructor(e={}){super(e)}};n(gl,"ParameterizedAggExpr"),gl.key="parameterizedAgg",gl.argOrder=["this","expressions","params"],gl.requiredArgs=new Set(["this","expressions","params"]),gl.availableArgs=new Set(["this","expressions","params"]),gl.register();var $M=gl,Ki=class Ki extends D{constructor(e={}){super(e)}};n(Ki,"ArgMaxExpr"),Ki.key="argMax",Ki.argOrder=["this","expression","count"],Ki._sqlNames=["ARG_MAX","ARGMAX","MAX_BY"],Ki.requiredArgs=new Set(["this","expression"]),Ki.availableArgs=new Set(["this","expression","count"]),Ki.register();var qA=Ki,en=class en extends D{constructor(e={}){super(e)}};n(en,"ArgMinExpr"),en.key="argMin",en.argOrder=["this","expression","count"],en._sqlNames=["ARG_MIN","ARGMIN","MIN_BY"],en.requiredArgs=new Set(["this","expression"]),en.availableArgs=new Set(["this","expression","count"]),en.register();var UA=en,LE=class LE extends D{constructor(e={}){super(e)}};n(LE,"ApproxTopKExpr"),LE.key="approxTopK",LE.argOrder=["this","expression","counters"],LE.availableArgs=new Set(["this","expression","counters"]),LE.register();var zB=LE,wE=class wE extends D{constructor(e={}){super(e)}};n(wE,"ApproxTopKAccumulateExpr"),wE.key="approxTopKAccumulate",wE.argOrder=["this","expression"],wE.availableArgs=new Set(["this","expression"]),wE.register();var QB=wE,ME=class ME extends D{constructor(e={}){super(e)}};n(ME,"ApproxTopKCombineExpr"),ME.key="approxTopKCombine",ME.argOrder=["this","expression"],ME.availableArgs=new Set(["this","expression"]),ME.register();var ZB=ME,El=class El extends D{constructor(e={}){super(e)}};n(El,"ApproxTopSumExpr"),El.key="approxTopSum",El.argOrder=["this","expression","count"],El.requiredArgs=new Set(["this","expression","count"]),El.availableArgs=new Set(["this","expression","count"]),El.register();var KB=El,kE=class kE extends D{constructor(e={}){super(e)}};n(kE,"ApproxQuantilesExpr"),kE.key="approxQuantiles",kE.argOrder=["this","expression"],kE.availableArgs=new Set(["this","expression"]),kE.register();var e$=kE,Fw=class Fw extends D{constructor(e={}){super(e)}};n(Fw,"ApproxPercentileCombineExpr"),Fw.key="approxPercentileCombine",Fw.register();var t$=Fw,tn=class tn extends D{constructor(e={}){super(e)}};n(tn,"MinhashExpr"),tn.key="minhash",tn.argOrder=["this","expressions"],tn.isVarLenArgs=!0,tn.requiredArgs=new Set(["this","expressions"]),tn.availableArgs=new Set(["this","expressions"]),tn.register();var s$=tn,Bw=class Bw extends D{constructor(e={}){super(e)}};n(Bw,"MinhashCombineExpr"),Bw.key="minhashCombine",Bw.register();var r$=Bw,bI=class bI extends D{constructor(e={}){super(e)}};n(bI,"ApproximateSimilarityExpr"),bI.key="approximateSimilarity",bI._sqlNames=["APPROXIMATE_SIMILARITY","APPROXIMATE_JACCARD_INDEX"],bI.register();var i$=bI,sn=class sn extends D{constructor(e={}){super(e)}};n(sn,"GroupingExpr"),sn.key="grouping",sn.isVarLenArgs=!0,sn.argOrder=["expressions"],sn.requiredArgs=new Set(["expressions"]),sn.availableArgs=new Set(["expressions"]),sn.register();var n$=sn,rn=class rn extends D{constructor(e={}){super(e)}};n(rn,"GroupingIdExpr"),rn.key="groupingId",rn.requiredArgs=new Set,rn.isVarLenArgs=!0,rn.argOrder=["expressions"],rn.availableArgs=new Set(["expressions"]),rn.register();var a$=rn,Al=class Al extends D{constructor(e={}){super(e)}};n(Al,"AnonymousAggFuncExpr"),Al.key="anonymousAggFunc",Al.argOrder=["this","expressions"],Al.isVarLenArgs=!0,Al.availableArgs=new Set(["this","expressions"]),Al.register();var GM=Al,dl=class dl extends D{constructor(e={}){super(e)}};n(dl,"HashAggExpr"),dl.key="hashAgg",dl.argOrder=["this","expressions"],dl.isVarLenArgs=!0,dl.availableArgs=new Set(["this","expressions"]),dl.register();var o$=dl,xl=class xl extends D{constructor(e={}){super(e)}};n(xl,"HllExpr"),xl.key="hll",xl.argOrder=["this","expressions"],xl.isVarLenArgs=!0,xl.availableArgs=new Set(["this","expressions"]),xl.register();var c$=xl,fl=class fl extends D{constructor(e={}){super(e)}};n(fl,"ApproxDistinctExpr"),fl.key="approxDistinct",fl.argOrder=["this","accuracy"],fl._sqlNames=["APPROX_DISTINCT","APPROX_COUNT_DISTINCT"],fl.availableArgs=new Set(["this","accuracy"]),fl.register();var ML=fl,$w=class $w extends As{};n($w,"ExplodingGenerateSeriesExpr"),$w.key="explodingGenerateSeries",$w.register();var p$=$w,DE=class DE extends D{constructor(e={}){super(e)}};n(DE,"ArrayAggExpr"),DE.key="arrayAgg",DE.argOrder=["this","nullsExcluded"],DE.availableArgs=new Set(["this","nullsExcluded"]),DE.register();var Bn=DE,Gw=class Gw extends D{constructor(e={}){super(e)}};n(Gw,"ArrayUniqueAggExpr"),Gw.key="arrayUniqueAgg",Gw.register();var l$=Gw,nn=class nn extends D{constructor(e={}){super(e)}};n(nn,"AiAggExpr"),nn.key="aiAgg",nn.argOrder=["this","expression"],nn._sqlNames=["AI_AGG"],nn.requiredArgs=new Set(["this","expression"]),nn.availableArgs=new Set(["this","expression"]),nn.register();var u$=nn,PI=class PI extends D{constructor(e={}){super(e)}};n(PI,"AiSummarizeAggExpr"),PI.key="aiSummarizeAgg",PI._sqlNames=["AI_SUMMARIZE_AGG"],PI.register();var h$=PI,Yw=class Yw extends D{constructor(e={}){super(e)}};n(Yw,"ArrayConcatAggExpr"),Yw.key="arrayConcatAgg",Yw.register();var kL=Yw,Vw=class Vw extends D{constructor(e={}){super(e)}};n(Vw,"ArrayUnionAggExpr"),Vw.key="arrayUnionAgg",Vw.register();var g$=Vw,Hw=class Hw extends D{constructor(e={}){super(e)}};n(Hw,"AvgExpr"),Hw.key="avg",Hw.register();var DL=Hw,_w=class _w extends D{constructor(e={}){super(e)}};n(_w,"AnyValueExpr"),_w.key="anyValue",_w.register();var qL=_w,qE=class qE extends D{constructor(e={}){super(e)}};n(qE,"LagExpr"),qE.key="lag",qE.argOrder=["this","offset","default"],qE.availableArgs=new Set(["this","offset","default"]),qE.register();var E$=qE,UE=class UE extends D{constructor(e={}){super(e)}};n(UE,"LeadExpr"),UE.key="lead",UE.argOrder=["this","offset","default"],UE.availableArgs=new Set(["this","offset","default"]),UE.register();var A$=UE,vE=class vE extends D{constructor(e={}){super(e)}};n(vE,"FirstExpr"),vE.key="first",vE.argOrder=["this","expression"],vE.availableArgs=new Set(["this","expression"]),vE.register();var d$=vE,FE=class FE extends D{constructor(e={}){super(e)}};n(FE,"LastExpr"),FE.key="last",FE.argOrder=["this","expression"],FE.availableArgs=new Set(["this","expression"]),FE.register();var x$=FE,Ww=class Ww extends D{constructor(e={}){super(e)}};n(Ww,"FirstValueExpr"),Ww.key="firstValue",Ww.register();var f$=Ww,jw=class jw extends D{constructor(e={}){super(e)}};n(jw,"LastValueExpr"),jw.key="lastValue",jw.register();var UL=jw,Tl=class Tl extends D{constructor(e={}){super(e)}};n(Tl,"NthValueExpr"),Tl.key="nthValue",Tl.argOrder=["this","offset","fromFirst"],Tl.requiredArgs=new Set(["this","offset"]),Tl.availableArgs=new Set(["this","offset","fromFirst"]),Tl.register();var T$=Tl,Sl=class Sl extends D{constructor(e={}){super(e)}};n(Sl,"ObjectAggExpr"),Sl.key="objectAgg",Sl.argOrder=["this","expression"],Sl.requiredArgs=new Set(["this","expression"]),Sl.availableArgs=new Set(["this","expression"]),Sl.register();var S$=Sl,BE=class BE extends z{constructor(e={}){super(e)}};n(BE,"TryCastExpr"),BE.key="tryCast",BE.requiredArgs=new Set,BE.availableArgs=new Set(["this","to","format","safe","action","default","requiresString"]),BE.register();var Gt=BE,Vk=class Vk extends z{constructor(e={}){super(e)}};n(Vk,"JsonCastExpr"),Vk.key="jsonCast";var mb=Vk,Xw=class Xw extends $t{constructor(e={}){super(e)}};n(Xw,"ConcatWsExpr"),Xw.key="concatWs",Xw._sqlNames=["CONCAT_WS"];var Wt=Xw,an=class an extends D{constructor(e={}){super(e)}};n(an,"CountExpr"),an.key="count",an.argOrder=["this","expressions","bigInt"],an.requiredArgs=new Set,an.isVarLenArgs=!0,an.availableArgs=new Set(["this","expressions","bigInt"]),an.register();var bh=an,LI=class LI extends D{constructor(e={}){super(e)}};n(LI,"CountIfExpr"),LI.key="countIf",LI._sqlNames=["COUNT_IF","COUNTIF"],LI.register();var vL=LI,on=class on extends D{constructor(e={}){super(e)}};n(on,"DenseRankExpr"),on.key="denseRank",on.argOrder=[],on.requiredArgs=new Set,on.isVarLenArgs=!0,on.availableArgs=new Set(["expressions"]),on.register();var R$=on,Jw=class Jw extends Jt{constructor(e={}){super(e)}};n(Jw,"ExplodeOuterExpr"),Jw.key="explodeOuter",Jw.register();var WA=Jw,zw=class zw extends Jt{constructor(e={}){super(e)}};n(zw,"PosexplodeExpr"),zw.key="posexplode",zw.register();var li=zw,$E=class $E extends D{constructor(e={}){super(e)}};n($E,"GroupConcatExpr"),$E.key="groupConcat",$E.argOrder=["this","separator","onOverflow"],$E.availableArgs=new Set(["this","separator","onOverflow"]),$E.register();var sr=$E,Hk=class Hk extends $a{constructor(e={}){super(e)}};n(Hk,"LowerHexExpr"),Hk.key="lowerHex";var Ph=Hk,GE=class GE extends V(Ae,E){constructor(e={}){super(e)}};n(GE,"AndExpr"),GE.key="and",GE.requiredArgs=new Set(["this","expression"]),GE.availableArgs=new Set(["this","expression"]),GE.register();var Te=GE,YE=class YE extends V(Ae,E){constructor(e={}){super(e)}};n(YE,"OrExpr"),YE.key="or",YE.requiredArgs=new Set(["this","expression"]),YE.availableArgs=new Set(["this","expression"]),YE.register();var pt=YE,Rl=class Rl extends V(Ae,E){constructor(e={}){super(e)}};n(Rl,"XorExpr"),Rl.key="xor",Rl.requiredArgs=new Set,Rl.isVarLenArgs=!0,Rl.availableArgs=new Set(["this","expression","expressions","roundInput"]),Rl.register();var hA=Rl,VE=class VE extends D{constructor(e={}){super(e)}};n(VE,"JsonObjectAggExpr"),VE.key="jsonObjectAgg",VE.argOrder=["expressions","nullHandling","uniqueKeys","returnType","encoding"],VE.availableArgs=new Set(["expressions","nullHandling","uniqueKeys","returnType","encoding"]),VE.register();var Nb=VE,Ol=class Ol extends D{constructor(e={}){super(e)}};n(Ol,"JsonbObjectAggExpr"),Ol.key="jsonbObjectAgg",Ol.argOrder=["this","expression"],Ol.requiredArgs=new Set(["this","expression"]),Ol.availableArgs=new Set(["this","expression"]),Ol.register();var O$=Ol,HE=class HE extends D{constructor(e={}){super(e)}};n(HE,"JsonArrayAggExpr"),HE.key="jsonArrayAgg",HE.argOrder=["this","order","nullHandling","returnType","strict"],HE.availableArgs=new Set(["this","order","nullHandling","returnType","strict"]),HE.register();var m$=HE,wI=class wI extends D{constructor(e={}){super(e)}};n(wI,"LogicalOrExpr"),wI.key="logicalOr",wI._sqlNames=["LOGICAL_OR","BOOL_OR","BOOLOR_AGG"],wI.register();var FL=wI,MI=class MI extends D{constructor(e={}){super(e)}};n(MI,"LogicalAndExpr"),MI.key="logicalAnd",MI._sqlNames=["LOGICAL_AND","BOOL_AND","BOOLAND_AGG"],MI.register();var BL=MI,ml=class ml extends D{constructor(e={}){super(e)}};n(ml,"MaxExpr"),ml.key="max",ml.argOrder=["this","expressions"],ml.isVarLenArgs=!0,ml.availableArgs=new Set(["this","expressions"]),ml.register();var $L=ml,Qw=class Qw extends D{constructor(e={}){super(e)}};n(Qw,"MedianExpr"),Qw.key="median",Qw.register();var N$=Qw,Nl=class Nl extends D{constructor(e={}){super(e)}};n(Nl,"ModeExpr"),Nl.key="mode",Nl.argOrder=["this","deterministic"],Nl.requiredArgs=new Set,Nl.availableArgs=new Set(["this","deterministic"]),Nl.register();var I$=Nl,Il=class Il extends D{constructor(e={}){super(e)}};n(Il,"MinExpr"),Il.key="min",Il.argOrder=["this","expressions"],Il.isVarLenArgs=!0,Il.availableArgs=new Set(["this","expressions"]),Il.register();var GL=Il,kI=class kI extends D{constructor(e={}){super(e)}};n(kI,"NtileExpr"),kI.key="ntile",kI.requiredArgs=new Set,kI.register();var y$=kI,_E=class _E extends D{constructor(e={}){super(e)}};n(_E,"PercentileContExpr"),_E.key="percentileCont",_E.argOrder=["this","expression"],_E.availableArgs=new Set(["this","expression"]),_E.register();var Ed=_E,WE=class WE extends D{constructor(e={}){super(e)}};n(WE,"PercentileDiscExpr"),WE.key="percentileDisc",WE.argOrder=["this","expression"],WE.availableArgs=new Set(["this","expression"]),WE.register();var YM=WE,cn=class cn extends D{constructor(e={}){super(e)}};n(cn,"PercentRankExpr"),cn.key="percentRank",cn.argOrder=[],cn.requiredArgs=new Set,cn.isVarLenArgs=!0,cn.availableArgs=new Set(["expressions"]),cn.register();var C$=cn,yl=class yl extends D{constructor(e={}){super(e)}};n(yl,"QuantileExpr"),yl.key="quantile",yl.argOrder=["this","quantile"],yl.requiredArgs=new Set(["this","quantile"]),yl.availableArgs=new Set(["this","quantile"]),yl.register();var dd=yl,Zw=class Zw extends D{constructor(e={}){super(e)}};n(Zw,"ApproxPercentileAccumulateExpr"),Zw.key="approxPercentileAccumulate",Zw.register();var b$=Zw,pn=class pn extends D{constructor(e={}){super(e)}};n(pn,"RankExpr"),pn.key="rank",pn.argOrder=[],pn.requiredArgs=new Set,pn.isVarLenArgs=!0,pn.availableArgs=new Set(["expressions"]),pn.register();var P$=pn,Cl=class Cl extends D{constructor(e={}){super(e)}};n(Cl,"RegrValxExpr"),Cl.key="regrValx",Cl.argOrder=["this","expression"],Cl.requiredArgs=new Set(["this","expression"]),Cl.availableArgs=new Set(["this","expression"]),Cl.register();var L$=Cl,bl=class bl extends D{constructor(e={}){super(e)}};n(bl,"RegrValyExpr"),bl.key="regrValy",bl.argOrder=["this","expression"],bl.requiredArgs=new Set(["this","expression"]),bl.availableArgs=new Set(["this","expression"]),bl.register();var w$=bl,Pl=class Pl extends D{constructor(e={}){super(e)}};n(Pl,"RegrAvgyExpr"),Pl.key="regrAvgy",Pl.argOrder=["this","expression"],Pl.requiredArgs=new Set(["this","expression"]),Pl.availableArgs=new Set(["this","expression"]),Pl.register();var M$=Pl,Ll=class Ll extends D{constructor(e={}){super(e)}};n(Ll,"RegrAvgxExpr"),Ll.key="regrAvgx",Ll.argOrder=["this","expression"],Ll.requiredArgs=new Set(["this","expression"]),Ll.availableArgs=new Set(["this","expression"]),Ll.register();var k$=Ll,wl=class wl extends D{constructor(e={}){super(e)}};n(wl,"RegrCountExpr"),wl.key="regrCount",wl.argOrder=["this","expression"],wl.requiredArgs=new Set(["this","expression"]),wl.availableArgs=new Set(["this","expression"]),wl.register();var D$=wl,Ml=class Ml extends D{constructor(e={}){super(e)}};n(Ml,"RegrInterceptExpr"),Ml.key="regrIntercept",Ml.argOrder=["this","expression"],Ml.requiredArgs=new Set(["this","expression"]),Ml.availableArgs=new Set(["this","expression"]),Ml.register();var q$=Ml,kl=class kl extends D{constructor(e={}){super(e)}};n(kl,"RegrR2Expr"),kl.key="regrR2",kl.argOrder=["this","expression"],kl.requiredArgs=new Set(["this","expression"]),kl.availableArgs=new Set(["this","expression"]),kl.register();var U$=kl,Dl=class Dl extends D{constructor(e={}){super(e)}};n(Dl,"RegrSxxExpr"),Dl.key="regrSxx",Dl.argOrder=["this","expression"],Dl.requiredArgs=new Set(["this","expression"]),Dl.availableArgs=new Set(["this","expression"]),Dl.register();var v$=Dl,ql=class ql extends D{constructor(e={}){super(e)}};n(ql,"RegrSxyExpr"),ql.key="regrSxy",ql.argOrder=["this","expression"],ql.requiredArgs=new Set(["this","expression"]),ql.availableArgs=new Set(["this","expression"]),ql.register();var F$=ql,Ul=class Ul extends D{constructor(e={}){super(e)}};n(Ul,"RegrSyyExpr"),Ul.key="regrSyy",Ul.argOrder=["this","expression"],Ul.requiredArgs=new Set(["this","expression"]),Ul.availableArgs=new Set(["this","expression"]),Ul.register();var B$=Ul,vl=class vl extends D{constructor(e={}){super(e)}};n(vl,"RegrSlopeExpr"),vl.key="regrSlope",vl.argOrder=["this","expression"],vl.requiredArgs=new Set(["this","expression"]),vl.availableArgs=new Set(["this","expression"]),vl.register();var $$=vl,Kw=class Kw extends D{constructor(e={}){super(e)}};n(Kw,"SumExpr"),Kw.key="sum",Kw.register();var YL=Kw,DI=class DI extends D{constructor(e={}){super(e)}};n(DI,"StddevExpr"),DI.key="stddev",DI._sqlNames=["STDDEV","STDEV"],DI.register();var VL=DI,eM=class eM extends D{constructor(e={}){super(e)}};n(eM,"StddevPopExpr"),eM.key="stddevPop",eM.register();var HL=eM,tM=class tM extends D{constructor(e={}){super(e)}};n(tM,"StddevSampExpr"),tM.key="stddevSamp",tM.register();var _L=tM,ln=class ln extends D{constructor(e={}){super(e)}};n(ln,"CumeDistExpr"),ln.key="cumeDist",ln.argOrder=[],ln.requiredArgs=new Set,ln.isVarLenArgs=!0,ln.availableArgs=new Set(["expressions"]),ln.register();var G$=ln,qI=class qI extends D{constructor(e={}){super(e)}};n(qI,"VarianceExpr"),qI.key="variance",qI._sqlNames=["VARIANCE","VARIANCE_SAMP","VAR_SAMP"],qI.register();var WL=qI,UI=class UI extends D{constructor(e={}){super(e)}};n(UI,"VariancePopExpr"),UI.key="variancePop",UI._sqlNames=["VARIANCE_POP","VAR_POP"],UI.register();var jL=UI,sM=class sM extends D{constructor(e={}){super(e)}};n(sM,"KurtosisExpr"),sM.key="kurtosis",sM.register();var XL=sM,rM=class rM extends D{constructor(e={}){super(e)}};n(rM,"SkewnessExpr"),rM.key="skewness",rM.register();var JL=rM,Fl=class Fl extends D{constructor(e={}){super(e)}};n(Fl,"CovarSampExpr"),Fl.key="covarSamp",Fl.argOrder=["this","expression"],Fl.requiredArgs=new Set(["this","expression"]),Fl.availableArgs=new Set(["this","expression"]),Fl.register();var Y$=Fl,Bl=class Bl extends D{constructor(e={}){super(e)}};n(Bl,"CovarPopExpr"),Bl.key="covarPop",Bl.argOrder=["this","expression"],Bl.requiredArgs=new Set(["this","expression"]),Bl.availableArgs=new Set(["this","expression"]),Bl.register();var V$=Bl,iM=class iM extends GM{constructor(e={}){super(e)}};n(iM,"CombinedAggFuncExpr"),iM.key="combinedAggFunc",iM.register();var H$=iM,nM=class nM extends $M{constructor(e={}){super(e)}};n(nM,"CombinedParameterizedAggExpr"),nM.key="combinedParameterizedAgg",nM.register();var _$=nM,jE=class jE extends V(li,WA){constructor(e={}){super(e)}};n(jE,"PosexplodeOuterExpr"),jE.key="posexplodeOuter",jE.requiredArgs=new Set(["this"]),jE.availableArgs=new Set(["this","expressions"]),jE.register();var W$=jE,XE=class XE extends dd{constructor(e={}){super(e)}};n(XE,"ApproxQuantileExpr"),XE.key="approxQuantile",XE.argOrder=["this","quantile","accuracy","weight","errorTolerance"],XE.availableArgs=new Set(["this","quantile","accuracy","weight","errorTolerance"]),XE.register();var wh=XE;function $n(a,e={}){let{col:t,table:s,db:r,catalog:i}=a,{fields:o,quoted:c,copy:p=!0}=e,u;t instanceof Ne?u=t:u=Z(t,{quoted:c,copy:p});let h=new $({this:u,table:s!==void 0?Z(s,{quoted:c,copy:p}):void 0,db:r!==void 0?Z(r,{quoted:c,copy:p}):void 0,catalog:i!==void 0?Z(i,{quoted:c,copy:p}):void 0});if(o&&0<o.length){let g=o.map(x=>Z(x,{quoted:c,copy:p})).filter(x=>x!==void 0);return ge.build([h,...g])}return h}n($n,"column");function Cj(a,e={}){let{db:t,catalog:s,quoted:r,alias:i}=e;return new W({this:a?Z(a,{quoted:r}):void 0,db:t?Z(t,{quoted:r}):void 0,catalog:s?Z(s,{quoted:r}):void 0,alias:i?new pe({this:Z(i)}):void 0})}n(Cj,"table_");function F_(a,e,t){let s={this:new F({this:a})};return e&&(s.db=new F({this:e})),t&&(s.catalog=new F({this:t})),new W(s)}n(F_,"table");function ve(a,e={}){let{dialect:t,copy:s=!0,wrap:r=!0,...i}=e;return HA(a,Te,{dialect:t,copy:s,wrap:r,...i})}n(ve,"and");function Ht(a,e={}){let{dialect:t,copy:s=!0,wrap:r=!0,...i}=e;return HA(a,pt,{dialect:t,copy:s,wrap:r,...i})}n(Ht,"or");function ED(a,e={}){let{dialect:t,copy:s=!0,wrap:r=!0,...i}=e;return HA(a,hA,{dialect:t,copy:s,wrap:r,...i})}n(ED,"xor");function ks(a,e={}){let t=G_(a,e);return new Le({this:mr(t,Ae)||t})}n(ks,"not");function zs(a,e={}){let{copy:t=!0,...s}=e;return new Re({this:j(a,{copy:t,...s})})}n(zs,"paren");var tw=/^[_a-zA-Z][\w]*$/;function Z(a,e={}){let{quoted:t,copy:s=!0}=e;if(a!==void 0)return a instanceof F?$e(a,s):new F({this:a,quoted:t!==void 0?t:!tw.test(a.toString())})}n(Z,"toIdentifier");function sy(a,e={}){let{dialect:t,...s}=e;try{return j(a,{dialect:t,into:F,...s})}catch{return Z(a)}}n(sy,"parseIdentifier");var ID=/\s*(-?[0-9]+(?:\.[0-9]+)?)\s*([a-zA-Z]+)\s*/,yD=/\s*-?\s*\d+(?:\.\d+)?\s+(?:-?(?:\d+:)?\d+:\d+(?:\.\d+)?|-?(?:\d+:){1,2}|:)\s*/;function bj(a){let e;if(a instanceof I){if(!a.args.isString)throw new Error("Invalid interval string.");e=a.args.this}else e=a;let t=j(`INTERVAL ${e}`);if(!(t instanceof qe))throw new Error("Failed to parse interval expression");return t}n(bj,"toInterval");function Be(a,e,t={}){let{table:s,quoted:r,dialect:i,copy:o=!0,...c}=t,p=j(a,{dialect:i,copy:o,...c}),u=e!==void 0?Z(e instanceof F?e:e.toString(),{quoted:r}):void 0;if(s){let h=new pe({this:u});if(p.setArgKey("alias",h),Array.isArray(s))for(let g of s){let x=Z(g,{quoted:r});x&&h.append("columns",x)}return p}return p._constructor.availableArgs.has("alias")&&!(p instanceof Ue)?(u&&p.setArgKey("alias",u),p):new Oe({this:p,alias:u})}n(Be,"alias");function DD(a,e,t={}){let{dialect:s,...r}=t,i=j(a,{dialect:s,...r});if(!(i instanceof ee))throw new Error("The input sql is not a QueryExpr");let o=i.subquery(e,r);return new se({}).from(o,{dialect:s,...r})}n(DD,"subquery");function Ye(a,e={}){return new se().select(a,e)}n(Ye,"select");function Pj(a,e={}){return new se({}).from(a,e)}n(Pj,"from");function qD(a,e={}){let t;return a!==void 0&&(t=j(a,e)),new ut({this:t,ifs:[]})}n(qD,"case_");function X(a,e,t={}){let{copy:s=!0,dialect:r,...i}=t,o=j(a,{copy:s,dialect:r,...i}),c=N.build(e,{copy:s,dialect:r,...i});if(o instanceof z){let h=ae.getOrRaise(r)._constructor.generatorClass.TYPE_MAPPING,g=o.args.to?.args.this,x=c?.args.this,f=(h.get(g?.toString()??"")||g?.toString())?.toUpperCase(),T=(h.get(x?.toString()??"")||x?.toString())?.toUpperCase(),y=g!=null&&f===T;if(c!==void 0&&o.isType([c])||y)return o}let p=new z({this:o,to:c});return p.type=c,p}n(X,"cast");function Lj(a,e={}){let{alias:t,columns:s}=e;if(s&&!t)throw new Error("Alias is required when providing columns");let r=a.map(o=>new Ze({expressions:o.map(c=>ht(c))})),i;return s?i=new pe({this:t!==void 0?Z(t):void 0,columns:s.map(o=>Z(o)).filter(o=>o!==void 0)}):t&&(i=new pe({this:Z(t)})),new tr({expressions:r,alias:i})}n(Lj,"values");function _A(a,...e){let t=e.map(r=>typeof r=="string"?j(r):ht(r)),s=jl.get(a.toUpperCase());return s?s.fromArgList(t):new Qe({this:a,expressions:t})}n(_A,"func");function J$(a,e,t={}){let{distinct:s=!0,dialect:r,copy:i=!0,...o}=t;return a?.map(p=>j(p,{dialect:r,copy:i,...o}))?.reduce((p,u)=>new e({this:p,expression:u,distinct:s,...o}))}n(J$,"applySetOperation");function jA(a,e={}){let t=Array.from(J(a)).filter(s=>s!==void 0);if(t.length<2)throw new Error("At least two expressions are required by `union`.");return J$(t,or,e)}n(jA,"union");function B_(a,e={}){let t=Array.from(J(a)).filter(s=>s!==void 0);if(t.length<2)throw new Error("At least two expressions are required by `intersect`.");return J$(t,ei,e)}n(B_,"intersect");function $_(a,e={}){let t=Array.from(J(a)).filter(s=>s!==void 0);if(t.length<2)throw new Error("At least two expressions are required by `except`.");return J$(t,cr,e)}n($_,"except");function wj(a,e,t={}){let{columns:s,overwrite:r,returning:i,dialect:o,copy:c=!0,...p}=t,u=j(a,{dialect:o,copy:c,...p}),h=j(e,{into:W,dialect:o,copy:c,...p});s&&(h=new Rt({this:h,expressions:s.map(x=>typeof x=="string"?Z(x):x)}));let g=new es({this:h,expression:u,overwrite:r});return i&&(g=g.returning(i,{dialect:o,copy:!1,...p})),g}n(wj,"insert");function Mj(a,e={}){let{where:t,returning:s,dialect:r,...i}=e,o=new Gr({}).delete(a,{dialect:r,copy:!1,...i});return t&&(o=o.where(t,{dialect:r,copy:!1,...i})),s&&(o=o.returning(s,{dialect:r,copy:!1,...i})),o}n(Mj,"delete_");function kj(a,e,t={}){let{where:s,from:r,with:i,dialect:o,...c}=t,p=new us({this:j(a,{into:W,dialect:o})});if(e&&p.setArgKey("expressions",Object.entries(e).map(([u,h])=>new Me({this:j(u,{dialect:o,...c}),expression:ht(h)}))),r&&p.setArgKey("from",j(r,{into:rt,dialect:o,prefix:"FROM",...c})),s){let u=s;s instanceof be&&(u=new St({this:s})),p.setArgKey("where",j(u,{into:St,dialect:o,prefix:"WHERE",...c}))}if(i){let u=Object.entries(i).map(([h,g])=>Be(new Bt({this:j(g,{dialect:o,...c})}),h,{table:!0}));p.setArgKey("with",new dt({expressions:u}))}return p}n(kj,"update");function Dj(a,e={}){let{into:t,using:s,on:r,returning:i,dialect:o,copy:c=!0,...p}=e,u=a!==void 0?Array.from(J(a)):[],h=[];for(let f of u){let T=j(f,{dialect:o,copy:c,into:Au,...p});T instanceof _n?h.push(T):h.push(...T.args.expressions)}let g=new YA({this:j(t,{dialect:o,copy:c,...p}),using:j(s,{dialect:o,copy:c,...p}),on:j(r,{dialect:o,copy:c,...p}),whens:new Au({expressions:h})});i&&(g=g.returning(i,{dialect:o,copy:!1,...p}));let x=g.args.using;if(x instanceof Oe){let f=x.args.alias,T=typeof f=="string"||Y(f,F)?f:void 0;x.replace(Be(x.args.this,T,{table:!0}))}return g}n(Dj,"merge");function G_(a,e={}){return j(a,{into:be,...e})}n(G_,"condition");function j(a,e){if(a instanceof d)return e?.copy?a.copy():a;if(a===void 0)throw new Ke("SQL cannot be null or undefined");let t=String(a);e?.prefix&&(t=`${e.prefix} ${t}`);let{dialect:s,...r}=e||{};return mD(t,{...r,read:s||r.read})}n(j,"maybeParse");function vI(a,e={}){let{dialect:t,copy:s=!0,...r}=e;if(a instanceof W)return $e(a,s);try{let i=j(a,{into:W,dialect:t,...r});for(let[o,c]of Object.entries(r))i.setArgKey(o,c);return i}catch{let[i,o,c]=BY(a,".",3);if(!c)throw new Error(`Invalid table path: ${a}`);let p=F_(c,o,i);for(let[u,h]of Object.entries(r))p.setArgKey(u,h);return p}}n(vI,"toTable");function j$(a,e={}){let{quoted:t,dialect:s,copy:r=!0,...i}=e;if(a instanceof $)return $e(a,r);try{let o=j(a,{into:$,dialect:s,...i});for(let[c,p]of Object.entries(i))o.setArgKey(c,p);if(t)for(let c of o.findAll(F))c.setArgKey("quoted",!0);return o}catch{let o=a.split(".").reverse(),[c,p]=o,u={this:Z(c,{quoted:t})};p&&(u.table=Z(p,{quoted:t}));let h=new $(u);for(let[g,x]of Object.entries(i))h.setArgKey(g,x);return h}}n(j$,"toColumn");function qj(a){let e=new Set;for(let t of sA(a))for(let s of t.tables)s.name&&!t.cteSources.has(s.name)&&e.add(s);return e}n(qj,"findTables");function $e(a,e=!0){return e&&a?a.copy():a}n($e,"maybeCopy");function Y_(a,e){return a instanceof d&&!(a instanceof e)}n(Y_,"isWrongExpression");function JE(a,e){let{instance:t,arg:s,copy:r=!0,prefix:i,into:o,dialect:c,intoArg:p="this",...u}=e;o&&Y_(a,o)&&(a=new o({[p]:a}));let h=$e(t,r),g=j(a,{prefix:i,into:o,dialect:c,...u});return s!==void 0&&h.setArgKey(s,g),h}n(JE,"applyBuilder");function xd(a,e={}){let{instance:t,arg:s,append:r=!0,copy:i=!0,prefix:o,into:c,dialect:p,properties:u,...h}=e,g=$e(t,i),x=[],f=u||{},T=J(a);for(let C of T){if(C===void 0)continue;let q=C;c&&Y_(q,c)&&(q=new c({expressions:[q]}));let U=j(q,{into:c,dialect:p,prefix:o,...h});for(let[_,ne]of Object.entries(U.args))_==="expressions"?x.push(...ne):f[_]=ne}let y=g.getArgKey(s),b=x;r&&y&&y.args.expressions&&(b=[...y.args.expressions,...x]);let m=c?new c({expressions:b}):new d({expressions:b});for(let[C,q]of Object.entries(f))m.setArgKey(C,q);return s!==void 0&&g.setArgKey(s,m),g}n(xd,"applyChildListBuilder");function Hh(a,e){let{instance:t,arg:s,append:r=!0,copy:i=!0,prefix:o,into:c,dialect:p,...u}=e,h=$e(t,i),x=J(a).filter(T=>T!==void 0).map(T=>j(T,{into:c,prefix:o,dialect:p,...u})),f=h?.getArgKey(s);return s!==void 0&&(r&&f?h?.setArgKey(s,[...f,...x]):h?.setArgKey(s,x)),h}n(Hh,"applyListBuilder");function FI(a,e={}){let{instance:t,arg:s,into:r,append:i=!0,copy:o=!0,dialect:c,...p}=e,h=Array.from(J(a)).filter(m=>m!==void 0&&m!=="");if(h.length===0)return t;let g=$e(t,o),x=g.getArgKey(s),f=[...h];i&&x instanceof d&&(f=[r&&"this"in x.args?x.args.this:x,...h]);let T=n(m=>m instanceof Ae?new Re({this:m}):m,"wrapConnector"),y;if(0<f.length){let m=f.map(_=>j(_,{dialect:c,copy:o,...p})),[C,...q]=m,U=C;0<q.length&&(U=T(C)),y=q.reduce((_,ne)=>new Te({this:_,expression:T(ne)}),U)}let b=r&&y?new r({this:y}):y;return b&&s!==void 0&&g.setArgKey(s,b),g}n(FI,"applyConjunctionBuilder");function z$(a){let{instance:e,alias:t,as:s,recursive:r,materialized:i,append:o=!0,dialect:c,copy:p=!0,scalar:u,...h}=a,g=j(t,{dialect:c,into:pe,...h}),x=j(s,{dialect:c,copy:p,...h});u&&!(x instanceof he)&&(x=new he({this:x}));let f=new Bt({this:x,alias:g,materialized:i,scalar:u});return xd([f],{instance:e,arg:"with",append:o,copy:p,into:dt,properties:r?{recursive:r}:{}})}n(z$,"applyCteBuilder");function HA(a,e,t={}){let{dialect:s,copy:r=!0,wrap:i=!0,...o}=t,p=Array.from(J(a)).filter(x=>x!==void 0&&x!=="").map(x=>j(x,{dialect:s,copy:r,...o})),[u,...h]=p,g=u;0<h.length&&i&&(g=mr(g,Ae)||g);for(let x of h)g=new e({this:g,expression:i&&mr(x,Ae)||x});return g}n(HA,"combine");function mr(a,e){return a instanceof e?new Re({this:a}):a}n(mr,"wrap");function Hl(a){return typeof a=="string"?I.string(a):typeof a=="number"?I.number(a):I.string(String(a))}n(Hl,"literal");function le(){return new Lt({})}n(le,"null_");function We(){return new at({this:!0})}n(We,"true_");function it(){return new at({this:!1})}n(it,"false_");function ht(a,e={}){let{copy:t=!1}=e;if(a instanceof d){let s=$e(a,t);if(s)return s}if(typeof a=="string")return I.string(a);if(typeof a=="boolean")return new at({this:a});if(a===void 0||typeof a=="number"&&isNaN(a))return le();if(typeof a=="number")return I.number(a);if(D_.isDateTime(a)){let s=a.toFormat("yyyy-MM-dd HH:mm:ss");if(0<a.millisecond){let o=(a.millisecond*1e3).toString().padStart(6,"0");s+=`.${o}`}let r=I.string(s),i;return a.zone.isUniversal&&(i=I.string(a.zoneName)),new Yh({this:r,zone:i})}if(a instanceof Date){let r=D_.fromJSDate(a).toFormat("yyyy-MM-dd HH:mm:ss"),i=I.string(r);return new Yh({this:i,zone:void 0})}if(Array.isArray(a))return new ue({expressions:a.map(s=>ht(s,{copy:t}))});if(a!==null&&typeof a=="object"){let s=Object.entries(a);return new mn({keys:new ue({expressions:s.map(([r])=>I.string(r))}),values:new ue({expressions:s.map(([,r])=>ht(r,{copy:t}))})})}throw new Error(`Cannot convert ${a}`)}n(ht,"convert");function Q(a){if(!a)throw new Error("Cannot convert empty name into var.");return a instanceof d&&(a=a.name),new Ve({this:a})}n(Q,"var_");function vA(a,e={}){let{copy:t=!0,dialect:s,...r}=e,i=Array.from(J(a));return new ue({expressions:i.map(o=>j(o,{copy:t,dialect:s,...r}))})}n(vA,"array");function Uj(a,e={}){let{copy:t=!0,dialect:s,...r}=e,i=Array.from(J(a));return new Ze({expressions:i.map(o=>j(o,{copy:t,dialect:s,...r}))})}n(Uj,"tuple");function vj(a,e,t={}){let{dialect:s}=t,r=vI(a,{dialect:s}),i=vI(e,{dialect:s});return new lu({this:r,kind:"table",actions:[new Yn({this:i})]})}n(vj,"renameTable");function Fj(a,e,t,s={}){let{exists:r,dialect:i}=s,o=vI(a,{dialect:i}),c=j$(e,{dialect:i}),p=j$(t,{dialect:i});return new lu({this:o,kind:"table",actions:[new FA({this:c,to:p,exists:r})]})}n(Fj,"renameColumn");function wM(a,e={}){let{exclude:t=""}=e,s=new Set;for(let r of a.findAll($)){let i=r.table;i&&i!==t&&s.add(i)}return s}n(wM,"columnTableNames");function Bj(a,e={}){let{dialect:t,identify:s=!1}=e,r=j(a,{into:W,dialect:t});if(!r)throw new Error(`Cannot parse ${a}`);return r.parts.map(i=>s||!tw.test(i.name)?i.sql({dialect:t,identify:!0,copy:!1,comments:!1}):i.name).join(".")}n(Bj,"tableName");function SM(a,e,...t){for(let[s,r]of Object.entries(a.args)){let i=Array.isArray(r),o=i?r:[r],c=[];for(let p of o)if(p instanceof d){let u=e(p,...t),h=Array.isArray(u)?u:[u];c.push(...h)}else c.push(p);i?a.setArgKey(s,c):a.setArgKey(s,c[0])}}n(SM,"replaceChildren");function $j(a,e,t){let s=Array.from(a.dfs({prune:t})),r=a;for(;0<s.length;){let i=s.pop();r=e(i),r!==i&&(i.replace(r),r instanceof d&&s.push(r))}return r}n($j,"replaceTree");function aM(a,e={}){let{dialect:t,copy:s=!0}=e;return ty(vI(a,{dialect:t,copy:s}),{dialect:t}).parts.map(r=>r.name).join(".")}n(aM,"normalizeTableName");function Gj(a,e,t={}){let{dialect:s,copy:r=!0}=t,i={};for(let[c,p]of Object.entries(e))i[aM(c,{dialect:s})]=p;function o(c){if(c instanceof W&&c.meta.replace!==!1){let p=aM(c,{dialect:s}),u=i[p];if(u){let h=vI(u,{dialect:s});for(let[g,x]of Object.entries(c.args))["this","db","catalog"].includes(g)||h.setArgKey(g,x);return h.addComments([p]),h}}return c}return n(o,"replaceTablesTransform"),a.transform(o,{copy:r})}n(Gj,"replaceTables");function Yj(a,e=[],t={}){let s=0;function r(i){if(i instanceof ar){if(typeof i.args.this=="string"){let o=t[i.args.this];if(o!==void 0)return ht(o)}else if(s<e.length)return ht(e[s++])}return i}return n(r,"replacePlaceholder"),a.transform(r)}n(Yj,"replacePlaceholders");function Vj(a,e,t={}){let{dialect:s,copy:r=!0}=t,i={};for(let[c,p]of Object.entries(e))i[aM(c,{dialect:s})]=p;function o(c){if(c instanceof W){let p=aM(c,{dialect:s}),u=i[p];if(u){let h=typeof u=="function"?u():u,g=c.alias||p,x=h.subquery(g);return x.comments=[`source: ${p}`],x.transform(o,{copy:!1})}}return c}return n(o,"expandTransform"),a.transform(o,{copy:r})}n(Vj,"expand");var Ls=[se,Ge],MM=[Ed,YM],AD=[I,at],dD=[I,at,Lt],Hj=new Set([Vs,kt,fr,Qt,Hs,Tr,ts,Sr,qt]);function Rn(a,e){if(!Y(a,"string",d)||a===void 0)return!1;if(a instanceof d)return a.isType(e);let t=typeof e!="string"&&GI(e)?e:[e];for(let r of t)if(r.toLowerCase()===a.toLowerCase())return!0;let s=st(At,a.toString());if(s===void 0)return!1;for(let r of t)if(r===s)return!0;return!1}n(Rn,"isType");function QE(a,e,t=[]){let s=[],r=e??gA(a)-1;for(let[i,o]of Object.entries(a))r===1||typeof o!="object"||o===void 0?s.push([...t,i]):2<=r&&s.push(...QE(o,r-1,[...t,i]));return s}n(QE,"flattenSchema");function cM(a,e,t={}){let{raiseOnMissing:s=!0}=t,r=a;for(let[i,o]of e){if(typeof r!="object"||r===void 0){if(s)throw new is(`Unknown ${i==="this"?"table":i}: ${o}`);return}let c=r[o];if(c===void 0||c===void 0){if(s)throw new is(`Unknown ${i==="this"?"table":i}: ${o}`);return}r=c}return r}n(cM,"nestedGet");function Q$(a,e,t){if(!e.length)return a;if(e.length===1)return a[e[0]]=t,a;let s=a;for(let r=0;r<e.length-1;r++)(!(e[r]in s)||typeof s[e[r]]!="object"||s[e[r]]===void 0)&&(s[e[r]]={}),s=s[e[r]];return s[e[e.length-1]]=t,a}n(Q$,"nestedSet");function _j(a){if(a==null)return{};if(typeof a=="object"&&!Array.isArray(a))return a;if(typeof a=="string")return Object.fromEntries(a.split(",").map(e=>{let[t,s]=e.split(":").map(r=>r.trim());return[t,s]}));if(Array.isArray(a))return Object.fromEntries(a.map(e=>[e.trim(),void 0]));throw new Error(`Invalid mapping provided: ${typeof a}`)}n(_j,"ensureColumnMapping");function oM(a,e={}){let{dialect:t,isTable:s=!1,normalize:r=!0}=e,i=typeof a=="string"?sy(a,{dialect:t}):a.copy();return r?(i.meta.isTable=s,ae.getOrRaise(t).normalizeIdentifier(i)):i}n(oM,"normalizeName");var K$=class K${get dialect(){}get empty(){return!0}hasColumn(e,t,s){let r=typeof t=="string"?t:t.name;return this.columnNames(e,s).includes(r)}getUdfType(e,t){return N.build("unknown")}};n(K$,"Schema");var pM=K$,eG=class eG extends pM{constructor(e,t){super(),this.mapping=e||{},this.udfMapping=t||{},this.mappingTrie=Yt(QE(this.mapping,this.depth()).map(s=>[...s].reverse())),this.udfTrie=Yt(QE(this.udfMapping,this.udfDepth()).map(s=>[...s].reverse()))}get empty(){return Object.keys(this.mapping).length===0}depth(){return gA(this.mapping)}udfDepth(){return gA(this.udfMapping)}get supportedTableArgs(){if(!this._supportedTableArgs&&!this.empty){let e=this.depth();if(!e)this._supportedTableArgs=[];else if(1<=e&&e<=3)this._supportedTableArgs=X$.slice(0,e);else throw new is(`Invalid mapping shape. Depth: ${e}`)}return this._supportedTableArgs||[]}tableParts(e){return[...e.parts].reverse().map(t=>t.name)}udfParts(e){let t=e.parent;return[...t instanceof ge?[...t.flatten()].map(r=>r.name):[e.name]].reverse().slice(0,this.udfDepth())}findInTrie(e,t,s){let{raiseOnMissing:r}=s,[i,o]=Nn(t,e);if(i!==0){if(i===1){let c=QE(o);if(c.length===1)e.push(...c[0]);else{if(r){let p=e.join("."),u=c.map(h=>h.join(".")).join(", ");throw new is(`Ambiguous mapping for ${p}: ${u}.`)}return}}return e}}find(e,t={}){let{raiseOnMissing:s=!0}=t,r=this.tableParts(e).slice(0,this.supportedTableArgs.length),i=this.findInTrie(r,this.mappingTrie,{raiseOnMissing:s});if(i)return this.nestedGet(i,void 0,{raiseOnMissing:s})}findUdf(e,t={}){let{raiseOnMissing:s=!1}=t,r=this.udfParts(e),i=this.findInTrie(r,this.udfTrie,{raiseOnMissing:s});if(!i)return;let o=[...i].reverse();return cM(this.udfMapping,i.map((c,p)=>[c,o[p]]),{raiseOnMissing:s})}nestedGet(e,t,s={}){let{raiseOnMissing:r=!0}=s,i=[...e].reverse();return cM(t||this.mapping,this.supportedTableArgs.map((o,c)=>[o,i[c]]),{raiseOnMissing:r})}};n(eG,"AbstractMappingSchema");var Z$=eG,zE=class zE extends V(Z$,pM){constructor(t,s={}){let r,i,o,c,p;if(t&&("schema"in t||"udfMapping"in t||"visible"in t||"dialect"in t||"normalize"in t)){let g=t;r=g.schema||{},i=g.visible,o=g.dialect,c=g.normalize??!0,p=g.udfMapping}else r=t||{},{visible:i,dialect:o,normalize:c=!0,udfMapping:p}=s;let u=o?ae.getOrRaise(o):new ae,h=p||{};super(c?zE.normalizeSchemaStatic(r,u,{normalize:c}):r,c?zE.normalizeUdfsStatic(h,u,{normalize:c}):h);this._typeCache={};this._depth=0;this.visible=i||{},this.normalize=c,this._dialect=u}static fromMappingSchema(t){return new zE(t.mapping,{visible:t.visible,dialect:t.dialect,normalize:t.normalize,udfMapping:t.udfMapping})}get dialect(){return this._dialect}depth(){return!this.empty&&!this._depth&&(this._depth=super.depth()-1),this._depth}copy(t={}){return new zE(t.schema??{...this.mapping},{visible:t.visible??{...this.visible},dialect:t.dialect??this.dialect,normalize:t.normalize??this.normalize,udfMapping:t.udfMapping??{...this.udfMapping}})}find(t,s={}){let{ensureDataTypes:r=!1}=s,i=super.find(t,s);return!r||typeof i!="object"||i===null?i:Object.fromEntries(Object.entries(i).map(([o,c])=>[o,typeof c=="string"?this.toDataType(c):c]))}addTable(t,s,r={}){let{dialect:i,normalize:o,matchDepth:c=!0}=r,p=this.normalizeTable(t,i,o);if(c&&!this.empty&&p.parts.length!==this.depth())throw new is(`Table ${p.sql()} must match the schema's nesting level: ${this.depth()}.`);let u=Object.fromEntries(Object.entries(_j(s)).map(([x,f])=>[this.normalizeName(x,i,{isTable:!1,normalize:o}),f]));if(this.find(p,{raiseOnMissing:!1})&&!Object.keys(u).length)return;let g=this.tableParts(p);Q$(this.mapping,[...g].reverse(),u),Yt([g],this.mappingTrie)}columnNames(t,s={}){let{onlyVisible:r=!1,dialect:i,normalize:o}=s,c=this.normalizeTable(t,i,o),p=this.find(c);if(!p||typeof p!="object")return[];let u=Object.keys(p);if(!r||!Object.keys(this.visible).length)return u;let h=this.nestedGet(this.tableParts(c),this.visible,{raiseOnMissing:!1}),g=h instanceof Set?h:h||[];return u.filter(x=>g instanceof Set?g.has(x):g.includes(x))}getColumnType(t,s,r={}){let{dialect:i,normalize:o}=r,c=this.normalizeTable(t,i,o),p=this.normalizeName(typeof s=="string"?s:s.args.this,i,{isTable:!1,normalize:o}),u=this.find(c,{raiseOnMissing:!1});if(u&&typeof u=="object"){let h=u[p];if(h instanceof N)return h;if(typeof h=="string")return this.toDataType(h,i)}return N.build("unknown")}hasColumn(t,s,r){let{dialect:i,normalize:o}=r||{},c=this.normalizeTable(t,i,o),p=this.normalizeName(typeof s=="string"?s:s.args.this,i,{isTable:!1,normalize:o}),u=this.find(c,{raiseOnMissing:!1});return u?p in u:!1}getUdfType(t,s={}){let{dialect:r,normalize:i}=s,o=this.normalizeUdf(t,r,i),c=this.findInTrie(o,this.udfTrie,{raiseOnMissing:!1});if(!c)return N.build("unknown");let p=[...c].reverse(),u=cM(this.udfMapping,c.map((h,g)=>[h,p[g]]),{raiseOnMissing:!1});return u instanceof N?u:typeof u=="string"?this.toDataType(u,r):N.build("unknown")}normalizeUdf(t,s,r){let i=s?ae.getOrRaise(s):this._dialect,o=r??this.normalize,c;if(typeof t=="string"){let u=j(t,{dialect:i});if(u instanceof Qe)c=u;else if(u instanceof ge){let h=[...u.flatten()],g=h[h.length-1];if(!(g instanceof Qe))throw new is(`Unable to parse UDF from: ${JSON.stringify(t)}`);c=g}else throw new is(`Unable to parse UDF from: ${JSON.stringify(t)}`)}else c=t;let p=this.udfParts(c);return o?p.map(u=>this.normalizeName(u,s,{isTable:!0,normalize:r})):p}toDataType(t,s){if(!this._typeCache[t]){let r=s?ae.getOrRaise(s):this._dialect,i=N.build(t,{dialect:r,udt:r._constructor.SUPPORTS_USER_DEFINED_TYPES});i?.transform(o=>r.normalizeIdentifier(o),{copy:!1}),this._typeCache[t]=i}return this._typeCache[t]}normalizeTable(t,s,r){let i=s?ae.getOrRaise(s):this._dialect,o=r??this.normalize,c=j(t,{into:W,dialect:i,copy:o});if(o)for(let p of c.parts)p instanceof F&&p.replace(oM(p,{dialect:i,isTable:!0,normalize:o}));return c}normalizeName(t,s,r={}){let{isTable:i=!1,normalize:o}=r,c=s?ae.getOrRaise(s):this._dialect;return oM(t,{dialect:c,isTable:i,normalize:o??this.normalize}).name}static normalizeSchemaStatic(t,s,r){let{normalize:i}=r;if(!i||!Object.keys(t).length)return t;let o={},c=QE(t);if(!c.length)return t;for(let p of c){let u=cM(t,p.map(f=>[f,f]),{raiseOnMissing:!1});if(typeof u!="object"||u===void 0)throw new is(`Table ${p.slice(0,-1).join(".")} must match the schema's nesting level: ${c[0].length}.`);let h=Object.entries(u);if(!h.length)throw new is(`Table ${p.slice(0,-1).join(".")} must have at least one column`);let g=h[0][1];if(g!=null&&typeof g=="object"&&!(g instanceof d)){let f=QE(u);throw new is(`Table ${[...p,...f[0]||[]].join(".")} must match the schema's nesting level: ${c[0].length}.`)}let x=p.map(f=>oM(f,{dialect:s,isTable:!0,normalize:i}).name);for(let[f,T]of h)Q$(o,[...x,oM(f,{dialect:s,normalize:i}).name],T)}return o}static normalizeUdfsStatic(t,s,r){let{normalize:i}=r;if(!i||!Object.keys(t).length)return t;let o={};for(let c of QE(t,gA(t))){let p=cM(t,c.map(h=>[h,h]),{raiseOnMissing:!1}),u=c.map(h=>oM(h,{dialect:s,isTable:!0,normalize:i}).name);Q$(o,u,p)}return o}};n(zE,"MappingSchema");var KI=zE;function NM(a,e={}){return a instanceof pM?a:new KI(a,e)}n(NM,"ensureSchema");export{n as a,Ft as b,It as c,yt as d,R as e,hM as f,un as g,kr as h,Ke as i,ZE as j,$l as k,nG as l,aG as m,KE as n,Y as o,re as p,ct as q,Et as r,O as s,sW as t,pX as u,lX as v,uX as w,hX as x,gX as y,EX as z,AX as A,dX as B,xX as C,fX as D,TX as E,xW as F,SX as G,RX as H,OX as I,mX as J,NX as K,IX as L,YI as M,dG as N,eA as O,xG as P,fG as Q,TG as R,SG as S,RG as T,OG as U,mG as V,NG as W,AM as X,IG as Y,yG as Z,Vt as _,CG as $,bG as aa,PG as ba,At as ca,VI as da,LG as ea,wG as fa,MG as ga,kG as ha,DG as ia,qG as ja,UG as ka,vG as la,FG as ma,BG as na,$G as oa,GG as pa,YG as qa,VG as ra,tD as sa,dM as ta,HG as ua,_G as va,WG as wa,jG as xa,sD as ya,QE as za,cM as Aa,Q$ as Ba,oM as Ca,pM as Da,KI as Ea,NM as Fa,js as Ga,sA as Ha,GX as Ia,rA as Ja,Dr as Ka,LW as La,Kt as Ma,Yl as Na,JX as Oa,fM as Pa,IM as Qa,wW as Ra,k as Sa,J as Ta,yM as Ua,En as Va,FY as Wa,CM as Xa,BY as Ya,gA as Za,AA as _a,qY as $a,bM as ab,Wl as bb,ty as cb,jl as db,ry as eb,Q0 as fb,mD as gb,QW as hb,zt as ib,RD as jb,rj as kb,oV as lb,ij as mb,pV as nb,iy as ob,GD as pb,YD as qb,q_ as rb,ND as sb,X$ as tb,U_ as ub,v_ as vb,d as wb,be as xb,ke as yb,An as zb,ee as Ab,Ct as Bb,ny as Cb,ay as Db,oy as Eb,dn as Fb,_D as Gb,bs as Hb,ss as Ib,Br as Jb,Gn as Kb,cy as Lb,py as Mb,ly as Nb,uy as Ob,hy as Pb,Ql as Qb,WD as Rb,jD as Sb,XD as Tb,gy as Ub,Ey as Vb,Ay as Wb,dy as Xb,xy as Yb,Zl as Zb,fA as _b,Xl as $b,JD as ac,zD as bc,fy as cc,TA as dc,Ty as ec,dt as fc,ns as gc,QD as hc,pe as ic,Sy as jc,Pe as kc,ms as lc,ZD as mc,KD as nc,SA as oc,RA as pc,Ry as qc,FA as rc,Yn as sc,eq as tc,Kl as uc,Oy as vc,my as wc,In as xc,Pn as yc,tq as zc,yn as Ac,ce as Bc,eu as Cc,sq as Dc,Ny as Ec,Gr as Fc,tu as Gc,rq as Hc,Xr as Ic,iq as Jc,Iy as Kc,yy as Lc,Cy as Mc,by as Nc,Py as Oc,su as Pc,nq as Qc,Ly as Rc,aq as Sc,ru as Tc,iu as Uc,rt as Vc,xs as Wc,Ps as Xc,gn as Yc,F as Zc,wy as _c,My as $c,ky as ad,Dy as bd,nu as cd,qy as dd,Uy as ed,BA as fd,vy as gd,Fy as hd,By as id,$y as jd,oq as kd,cq as ld,hr as md,Gy as nd,Yy as od,Yr as pd,Vy as qd,OA as rd,Hy as sd,ps as td,Dt as ud,_y as vd,fe as wd,Wy as xd,jy as yd,_I as zd,Cn as Ad,ye as Bd,Xy as Cd,Jy as Dd,hs as Ed,w as Fd,zy as Gd,Qy as Hd,Vn as Id,pq as Jd,lq as Kd,uq as Ld,au as Md,hq as Nd,gq as Od,Eq as Pd,Xs as Qd,Zy as Rd,ou as Sd,Ky as Td,Ze as Ud,Ij as Vd,Aq as Wd,cu as Xd,eC as Yd,tC as Zd,XA as _d,bb as $d,W as ae,Ve as be,sC as ce,Rt as de,$A as ee,rC as fe,dq as ge,Ln as he,iC as ie,pu as je,nC as ke,St as le,Ne as me,Jr as ne,N as oe,xq as pe,$r as qe,aC as re,oC as se,cC as te,lu as ue,mA as ve,NA as we,pC as xe,lC as ye,uC as ze,hC as Ae,gC as Be,uu as Ce,EC as De,hu as Ee,gu as Fe,IA as Ge,AC as He,fq as Ie,dC as Je,Tq as Ke,Oe as Le,wn as Me,Hn as Ne,xC as Oe,gs as Pe,Sq as Qe,Rq as Re,et as Se,Oq as Te,te as Ue,yA as Ve,CA as We,gr as Xe,mq as Ye,Pb as Ze,fC as _e,TC as $e,Er as af,Ut as bf,SC as cf,RC as df,OC as ef,mC as ff,NC as gf,IC as hf,Nq as if,bA as jf,On as kf,Eu as lf,Iq as mf,zL as nf,yC as of,yq as pf,CC as qf,_n as rf,Au as sf,bC as tf,Gl as uf,Lb as vf,Cq as wf,GA as xf,bq as yf,PC as zf,du as Af,BM as Bf,Pq as Cf,Bt as Df,LC as Ef,xu as Ff,wC as Gf,Mn as Hf,MC as If,$ as Jf,WI as Kf,kC as Lf,wb as Mf,DC as Nf,kn as Of,fu as Pf,qC as Qf,Mb as Rf,Tu as Sf,Su as Tf,Ru as Uf,PA as Vf,Ou as Wf,mu as Xf,Nu as Yf,Iu as Zf,yu as _f,Jl as $f,UC as ag,Lq as bg,Cu as cg,bu as dg,Pu as eg,wq as fg,LA as gg,Lu as hg,vC as ig,wu as jg,Mu as kg,ku as lg,Du as mg,kb as ng,Dn as og,FC as pg,BC as qg,es as rg,I as sg,rr as tg,$C as ug,zl as vg,Wn as wg,jn as xg,Xn as yg,Jn as zg,Mq as Ag,qu as Bg,zr as Cg,Uu as Dg,zn as Eg,Qn as Fg,vu as Gg,Fu as Hg,Zn as Ig,Kn as Jg,ea as Kg,ta as Lg,Bu as Mg,sa as Ng,kq as Og,ra as Pg,ia as Qg,na as Rg,aa as Sg,nr as Tg,oa as Ug,$u as Vg,ir as Wg,ld as Xg,Gu as Yg,ca as Zg,pa as _g,la as $g,ua as ah,ha as bh,Yu as ch,Vu as dh,Qr as eh,ga as fh,Ea as gh,Hu as hh,GC as ih,_u as jh,Aa as kh,Dq as lh,da as mh,Wu as nh,Zr as oh,ud as ph,ju as qh,xa as rh,fa as sh,qn as th,Ta as uh,Vr as vh,Hr as wh,Cs as xh,Xu as yh,Ju as zh,qq as Ah,Db as Bh,Uq as Ch,qb as Dh,vq as Eh,zu as Fh,Sa as Gh,Ra as Hh,Kr as Ih,Oa as Jh,ma as Kh,Qu as Lh,Zu as Mh,Na as Nh,Ia as Oh,Ku as Ph,_r as Qh,ya as Rh,JA as Sh,Ca as Th,ba as Uh,vs as Vh,Pa as Wh,Fs as Xh,eh as Yh,$s as Zh,La as _h,zA as $h,QA as ai,ZA as bi,KA as ci,ed as di,td as ei,sd as fi,rd as gi,id as hi,nd as ii,ad as ji,wa as ki,Ma as li,ka as mi,od as ni,Da as oi,qa as pi,th as qi,Ua as ri,va as si,sh as ti,Fa as ui,hd as vi,gd as wi,cd as xi,He as yi,Ge as zi,us as Ai,se as Bi,he as Ci,Ue as Di,YC as Ei,VC as Fi,ar as Gi,Lt as Hi,at as Ii,HC as Ji,_C as Ki,v as Li,qs as Mi,WC as Ni,wt as Oi,Zs as Pi,Wr as Qi,qe as Ri,E as Si,D as Ti,Vs as Ui,kt as Vi,fr as Wi,Qt as Xi,Hs as Yi,Tr as Zi,ci as _i,ts as $i,Sr as aj,qt as bj,YA as cj,bt as dj,_l as ej,or as fj,cr as gj,ei as hj,tr as ij,Us as jj,we as kj,Ae as lj,rh as mj,jC as nj,XC as oj,ih as pj,JC as qj,Mt as rj,zC as sj,nh as tj,ah as uj,ge as vj,jt as wj,Me as xj,Ks as yj,Ur as zj,ot as Aj,QC as Bj,Ba as Cj,wA as Dj,je as Ej,Je as Fj,Gs as Gj,Un as Hj,ze as Ij,oh as Jj,Zt as Kj,Fq as Lj,Fe as Mj,nt as Nj,jr as Oj,Ts as Pj,xt as Qj,Bq as Rj,ch as Sj,ZC as Tj,Ce as Uj,ph as Vj,lh as Wj,Le as Xj,Re as Yj,Pt as Zj,Ss as _j,lt as $j,Ub as ak,$q as bk,Wb as ck,jb as dk,Xb as ek,Jb as fk,zb as gk,Qb as hk,Gq as ik,Zb as jk,Yq as kk,Kb as lk,Vq as mk,Hq as nk,_q as ok,Wq as pk,eP as qk,tP as rk,sP as sk,rP as tk,iP as uk,nP as vk,jq as wk,Xq as xk,Jq as yk,zq as zk,Qq as Ak,Zq as Bk,Kq as Ck,eU as Dk,tU as Ek,sU as Fk,rU as Gk,iU as Hk,nU as Ik,aU as Jk,uh as Kk,aP as Lk,oU as Mk,cU as Nk,pU as Ok,lU as Pk,uU as Qk,hU as Rk,oP as Sk,Qe as Tk,gU as Uk,ue as Vk,cP as Wk,EU as Xk,AU as Yk,dU as Zk,KC as _k,eb as $k,QL as al,xU as bl,fU as cl,pP as dl,TU as el,SU as fl,RU as gl,OU as hl,tb as il,mU as jl,vb as kl,vn as ll,NU as ml,As as nl,IU as ol,yU as pl,CU as ql,bU as rl,sb as sl,rb as tl,hh as ul,PU as vl,LU as wl,wU as xl,MU as yl,kU as zl,DU as Al,qU as Bl,UU as Cl,lP as Dl,Fn as El,Va as Fl,uP as Gl,hP as Hl,vU as Il,gP as Jl,EP as Kl,AP as Ll,MA as Ml,FU as Nl,BU as Ol,dP as Pl,$U as Ql,Fb as Rl,Rr as Sl,GU as Tl,YU as Ul,VU as Vl,ut as Wl,z as Xl,xP as Yl,fP as Zl,TP as _l,HU as $l,ib as am,_U as bm,WU as cm,kA as dm,jU as em,ti as fm,tt as gm,gh as hm,$t as im,SP as jm,Eh as km,Ah as lm,XU as mm,JU as nm,zU as om,QU as pm,ZU as qm,KU as rm,ev as sm,tv as tm,sv as um,rv as vm,RP as wm,iv as xm,nv as ym,pr as zm,OP as Am,si as Bm,dh as Cm,nb as Dm,av as Em,ri as Fm,mP as Gm,ov as Hm,cv as Im,NP as Jm,xh as Km,Mh as Lm,pv as Mm,ab as Nm,lv as Om,uv as Pm,kh as Qm,Bb as Rm,$b as Sm,Gb as Tm,ft as Um,hv as Vm,Xt as Wm,_s as Xm,ls as Ym,IP as Zm,Ds as _m,Qs as $m,yP as an,gv as bn,Ev as cn,CP as dn,bP as en,PP as fn,LP as gn,wP as hn,Av as in,MP as jn,kP as kn,DP as ln,dv as mn,qP as nn,_a as on,xv as pn,fv as qn,Tv as rn,Sv as sn,Rv as tn,lr as un,Ys as vn,Ov as wn,Lh as xn,Fh as yn,UP as zn,Dh as An,Sn as Bn,mv as Cn,Bh as Dn,vP as En,FP as Fn,Nv as Gn,BP as Hn,Iv as In,$P as Jn,GP as Kn,YP as Ln,pi as Mn,Nr as Nn,ob as On,cb as Pn,yv as Qn,Cv as Rn,VP as Sn,bv as Tn,Pv as Un,Lv as Vn,wv as Wn,HP as Xn,Mv as Yn,Jt as Zn,Ib as _n,Ee as $n,fh as ao,_P as bo,WP as co,jP as do,XP as eo,kv as fo,Dv as go,qv as ho,Uv as io,vv as jo,Fv as ko,Bv as lo,$v as mo,Gv as no,pb as oo,ii as po,JP as qo,Yv as ro,zP as so,ni as to,$a as uo,Vv as vo,Hv as wo,QP as xo,_v as yo,Wv as zo,jv as Ao,Xv as Bo,Jv as Co,xe as Do,qh as Eo,Th as Fo,zv as Go,ZP as Ho,Uh as Io,KP as Jo,Qv as Ko,Zv as Lo,Kv as Mo,lb as No,eF as Oo,Sh as Po,tF as Qo,sF as Ro,rF as So,iF as To,nF as Uo,aF as Vo,ub as Wo,oF as Xo,cF as Yo,pF as Zo,hb as _o,gb as $o,Rh as ap,Oh as bp,lF as cp,mh as dp,Ns as ep,uF as fp,bn as gp,Nh as hp,Eb as ip,hF as jp,gF as kp,EF as lp,AF as mp,dF as np,xF as op,ai as pp,fF as qp,TF as rp,SF as sp,RF as tp,Ih as up,OF as vp,mF as wp,NF as xp,$h as yp,IF as zp,eL as Ap,tL as Bp,yh as Cp,ur as Dp,Ar as Ep,mn as Fp,vh as Gp,yF as Hp,CF as Ip,bF as Jp,PF as Kp,LF as Lp,wF as Mp,MF as Np,kF as Op,Ab as Pp,Rs as Qp,db as Rp,sL as Sp,DF as Tp,qF as Up,UF as Vp,rL as Wp,iL as Xp,vF as Yp,FF as Zp,xb as _p,BF as $p,Yb as aq,$F as bq,GF as cq,fb as dq,YF as eq,VF as fq,HF as gq,_F as hq,WF as iq,jF as jq,nL as kq,Gh as lq,XF as mq,aL as nq,vr as oq,JI as pq,JF as qq,zF as rq,QF as sq,ZF as tq,KF as uq,eB as vq,ZL as wq,tB as xq,sB as yq,Ga as zq,Tb as Aq,rB as Bq,iB as Cq,nB as Dq,aB as Eq,oB as Fq,KL as Gq,oL as Hq,cL as Iq,ew as Jq,yb as Kq,cB as Lq,pB as Mq,lB as Nq,uB as Oq,hB as Pq,pL as Qq,gB as Rq,EB as Sq,AB as Tq,dB as Uq,lL as Vq,uL as Wq,xB as Xq,fB as Yq,hL as Zq,gL as _q,TB as $q,SB as ar,RB as br,OB as cr,mB as dr,Is as er,NB as fr,IB as gr,Vl as hr,EL as ir,Bs as jr,yB as kr,CB as lr,oi as mr,ys as nr,bB as or,PB as pr,LB as qr,wB as rr,AL as sr,Es as tr,MB as ur,kB as vr,Ch as wr,dL as xr,Or as yr,xL as zr,DB as Ar,fL as Br,Yh as Cr,qB as Dr,Ya as Er,Vh as Fr,UB as Gr,TL as Hr,os as Ir,Vb as Jr,Hb as Kr,_b as Lr,SL as Mr,vB as Nr,RL as Or,FB as Pr,OL as Qr,mL as Rr,NL as Sr,IL as Tr,yL as Ur,CL as Vr,bL as Wr,DA as Xr,yj as Yr,vM as Zr,PL as _r,LL as $r,dr as as,BB as bs,$B as cs,Ad as ds,GB as es,Sb as fs,YB as gs,Rb as hs,wL as is,VB as js,Ob as ks,cs as ls,Tt as ms,HB as ns,_B as os,WB as ps,jB as qs,XB as rs,JB as ss,$M as ts,qA as us,UA as vs,zB as ws,QB as xs,ZB as ys,KB as zs,e$ as As,t$ as Bs,s$ as Cs,r$ as Ds,i$ as Es,n$ as Fs,a$ as Gs,GM as Hs,o$ as Is,c$ as Js,ML as Ks,p$ as Ls,Bn as Ms,l$ as Ns,u$ as Os,h$ as Ps,kL as Qs,g$ as Rs,DL as Ss,qL as Ts,E$ as Us,A$ as Vs,d$ as Ws,x$ as Xs,f$ as Ys,UL as Zs,T$ as _s,S$ as $s,Gt as at,mb as bt,Wt as ct,bh as dt,vL as et,R$ as ft,WA as gt,li as ht,sr as it,Ph as jt,Te as kt,pt as lt,hA as mt,Nb as nt,O$ as ot,m$ as pt,FL as qt,BL as rt,$L as st,N$ as tt,I$ as ut,GL as vt,y$ as wt,Ed as xt,YM as yt,C$ as zt,dd as At,b$ as Bt,P$ as Ct,L$ as Dt,w$ as Et,M$ as Ft,k$ as Gt,D$ as Ht,q$ as It,U$ as Jt,v$ as Kt,F$ as Lt,B$ as Mt,$$ as Nt,YL as Ot,VL as Pt,HL as Qt,_L as Rt,G$ as St,WL as Tt,jL as Ut,XL as Vt,JL as Wt,Y$ as Xt,V$ as Yt,H$ as Zt,_$ as _t,W$ as $t,wh as au,$n as bu,Cj as cu,F_ as du,ve as eu,Ht as fu,ED as gu,ks as hu,zs as iu,tw as ju,Z as ku,sy as lu,ID as mu,yD as nu,bj as ou,Be as pu,DD as qu,Ye as ru,Pj as su,qD as tu,X as uu,Lj as vu,_A as wu,jA as xu,B_ as yu,$_ as zu,wj as Au,Mj as Bu,kj as Cu,Dj as Du,G_ as Eu,j as Fu,vI as Gu,j$ as Hu,qj as Iu,$e as Ju,HA as Ku,mr as Lu,Hl as Mu,le as Nu,We as Ou,it as Pu,ht as Qu,Q as Ru,vA as Su,Uj as Tu,vj as Uu,Fj as Vu,wM as Wu,Bj as Xu,SM as Yu,$j as Zu,aM as _u,Gj as $u,Yj as av,Vj as bv,Ls as cv,MM as dv,AD as ev,dD as fv,Hj as gv,Rn as hv,VA as iv,SJ as jv,yJ as kv,qJ as lv,UJ as mv,vJ as nv,FJ as ov,BJ as pv,$J as qv,GJ as rv,YJ as sv,VJ as tv,HJ as uv,_J as vv,WJ as wv,jJ as xv,XJ as yv,JJ as zv,zJ as Av,QJ as Bv,ZJ as Cv,KJ as Dv,ez as Ev,tz as Fv,sz as Gv,rz as Hv,Cb as Iv,pd as Jv,xz as Kv,UM as Lv,ae as Mv,Fz as Nv,Bz as Ov,UD as Pv,$z as Qv,Gz as Rv,Yz as Sv,Rj as Tv,Vz as Uv,Hz as Vv,_z as Wv,Wz as Xv,jz as Yv,Xz as Zv,Jz as _v,zz as $v,Qz as aw,Zz as bw,Kz as cw,e1 as dw,t1 as ew,s1 as fw,r1 as gw,i1 as hw,n1 as iw,Oj as jw,a1 as kw,OD as lw,o1 as mw,c1 as nw,p1 as ow,l1 as pw,u1 as qw,h1 as rw,g1 as sw,E1 as tw,A1 as uw,d1 as vw,x1 as ww,f1 as xw,T1 as yw,S1 as zw,R1 as Aw,O1 as Bw,m1 as Cw,ZH as Dw,N1 as Ew,I1 as Fw,y1 as Gw,C1 as Hw,b1 as Iw,P1 as Jw,L1 as Kw,w1 as Lw,M1 as Mw,k1 as Nw,D1 as Ow,q1 as Pw,U1 as Qw,mj as Rw,v1 as Sw,F1 as Tw,DM as Uw,vD as Vw,KH as Ww,B1 as Xw,$1 as Yw,G1 as Zw,Y1 as _w,V1 as $w,H1 as ax,_1 as bx,W1 as cx,j1 as dx,X1 as ex,J1 as fx,z1 as gx,Q1 as hx,Z1 as ix,K1 as jx,eQ as kx,tQ as lx,sQ as mx,rQ as nx,iQ as ox,nQ as px,aQ as qx,oQ as rx,cQ as sx,PM as tx,ey as ux,Fr as vx};
|
|
19
|
+
//# sourceMappingURL=chunk-CNQXTBAR.js.map
|