Releases: azurechen97/sqlglot-maxcompute
Releases · azurechen97/sqlglot-maxcompute
v0.4.0
Changed (internal refactor)
maxcompute.pyrenamed todialect.py— the coordinator classMaxComputeis now insrc/sqlglot_maxcompute/dialect.pyMaxComputeParsernow inherits fromHiveParser(imported fromsqlglot.parsers.hive) instead ofHive.ParserMaxComputeGeneratornow inherits fromHiveGenerator(imported fromsqlglot.generators.hive) instead ofHive.Generatorsqlglotdependency floor raised to>=30.1.0(first release with splitparsers/andgenerators/modules)
Fixed (parser + generator correctness)
TRUNC(n, d)now maps toexp.Truncfor numeric truncation;TRUNC(dt, 'unit')still routes to date truncationBOOL_AND(col)/BOOL_OR(col)now emit correct MaxCompute names instead ofLOGICAL_AND/LOGICAL_ORLOCATE(sub, str, start)now passes the start position through toINSTR(str, sub, start)instead of silently dropping it
v0.3.1
Fixed (parser correctness)
NOW()now maps toexp.CurrentTimestampso cross-dialect output isCURRENT_TIMESTAMPinstead ofCURRENT_DATETIME()(BigQuery-specific); round-trip in MaxCompute producesGETDATE()(a synonym)DATE_SUB(date, n)now maps toexp.DateSubso output isDATEADD(date, -n, 'DAY')instead ofDATEADD(date, n * -1, 'DAY')
v0.3.0
Fixed (generator correctness)
TO_DATE(str, fmt)now models return type as DATETIME (exp.StrToTime);TO_DATE(str)remains DATE (exp.TsOrDsToDate) — cross-dialect consumers now see the correct type for each formSPACE(n)now emitsSPACE(n)instead ofREPEAT(' ', n)VAR_POP(x)now emitsVAR_POP(x)instead ofVARIANCE_POP(x)VAR_SAMP(x)/VARIANCE(x)now emitsVAR_SAMP(x)instead ofVARIANCE(x)INSTR(s, sub)now emitsINSTR(s, sub)instead ofLOCATE(sub, s)SUBSTR(s, pos, len)now emitsSUBSTRinstead ofSUBSTRING
Added (parser)
SUBSTRas explicit MaxCompute parser alias forexp.Substring
Changed (internal)
- Dialect split:
maxcompute.pynow delegates toparser.pyandgenerator.py(mirrors sqlglot's own mypyc-compile refactor)
Tests
- Regression coverage for ~20 functions previously relying on untested Hive inheritance:
INITCAP, REVERSE, REPEAT, LPAD/RPAD, LTRIM/RTRIM, REGEXP_REPLACE,
REGEXP_EXTRACT_ALL, INSTR, FIND_IN_SET, SUBSTR, SUBSTRING_INDEX,
CONCAT_WS, FORMAT_NUMBER, COLLECT_LIST/SET, VAR_SAMP, VAR_POP,
PERCENTILE, STDDEV, GREATEST/LEAST, CBRT, FACTORIAL, GET_JSON_OBJECT,
JSON_TUPLE
v0.2.0
Added
Generator (MaxCompute SQL output)
DATEADD/DATEADDwith negated delta forDateSub(e.g. BigQueryDATE_SUB→DATEADD(dt, -3, 'DAY'))DATEDIFFwith optional unit argumentDATETRUNC/TRUNC_TIMEwith full week-unit support ('week'→'week(monday)')DATEPARTvia namedextract_sqlmethodGETDATE()forCurrentTimestamp,NOW()forCurrentDatetimeTOLOWER/TOUPPERforLower/UpperFROM_JSONforParseJSON,GET_USER_ID()forCurrentUser,TO_MILLISforUnixMillisAPPROX_DISTINCT,ARG_MAX,ARG_MINWM_CONCAT(sep, col)via namedgroupconcat_sqlmethod (with default separator guard)TO_CHARvia namedtochar_sqlmethod- Type mapping:
VARCHAR/CHAR/TEXT→STRING;DATETIMEpreserved
Parser (read direction)
- Statistical aggregates:
STDDEV_SAMP,COVAR_POP,COVAR_SAMP,CORR,MEDIAN,PERCENTILE_APPROX,BITWISE_AND_AGG,BITWISE_OR_AGG,BITWISE_XOR_AGG MAX_BY/MIN_BYas aliases forARG_MAX/ARG_MIN
Fixed
TO_DATEformat string preserved as-is (Hive was converting Oracle-stylemm→%M)WEEKDAYround-trips asWEEKDAY(dt)in MaxCompute output (other dialects still get the(DAYOFWEEK + 5) % 7arithmetic)DATETRUNCweek-unit emits valid'week(monday)'string literal instead of bareWEEK(MONDAY)groupconcat_sqldefaults separator to','when absent (prevents invalidWM_CONCAT(col))- Python >=3.9 compatibility (removed
ipykernel, relaxedpytestfloor) - Added
sqlglot<31upper bound to prevent unexpected breakage on major releases
Infrastructure
- GitHub Actions CI across Python 3.9 / 3.10 / 3.11 / 3.12
- README with usage examples and function coverage table
v0.1.0
Initial release.
- MaxCompute dialect registered via Python entry points
- Parser: ~40 date/time, string, array, and map functions
- DDL:
LIFECYCLE,RANGE CLUSTERED BY,AUTO PARTITIONED BY