@malloydata/malloy 0.0.38-dev230609163341 → 0.0.38-dev230609221655
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.
|
@@ -243,6 +243,7 @@ declare class QueryQuery extends QueryField {
|
|
|
243
243
|
/** returns a fields and primary key of a struct for this query */
|
|
244
244
|
getResultStructDef(resultStruct?: FieldInstanceResult, isRoot?: boolean): StructDef;
|
|
245
245
|
generateSQLJoinBlock(stageWriter: StageWriter, ji: JoinInstance): string;
|
|
246
|
+
generateSQLPassthroughKeys(qs: QueryStruct): string;
|
|
246
247
|
generateSQLJoins(stageWriter: StageWriter): string;
|
|
247
248
|
genereateSQLOrderBy(queryDef: QuerySegment, resultStruct: FieldInstanceResult): string;
|
|
248
249
|
generateSimpleSQL(stageWriter: StageWriter): string;
|
|
@@ -1679,7 +1679,8 @@ class QueryQuery extends QueryField {
|
|
|
1679
1679
|
let structSQL = qs.structSourceSQL(stageWriter);
|
|
1680
1680
|
if ((0, malloy_types_1.isJoinOn)(structRelationship)) {
|
|
1681
1681
|
if (ji.makeUniqueKey) {
|
|
1682
|
-
|
|
1682
|
+
const passKeys = this.generateSQLPassthroughKeys(qs);
|
|
1683
|
+
structSQL = `(SELECT ${qs.dialect.sqlGenerateUUID()} as __distinct_key, * ${passKeys} FROM ${structSQL} as x)`;
|
|
1683
1684
|
}
|
|
1684
1685
|
let onCondition = '';
|
|
1685
1686
|
if (qs.parent === undefined) {
|
|
@@ -1740,6 +1741,25 @@ class QueryQuery extends QueryField {
|
|
|
1740
1741
|
}
|
|
1741
1742
|
return s;
|
|
1742
1743
|
}
|
|
1744
|
+
// BigQuery has wildcard psudo columns that are treated differently
|
|
1745
|
+
// SELECT * FROM xxx doesn't include these psuedo columns but we need them so
|
|
1746
|
+
// filters can get pushed down properly when generating a UNIQUE key.
|
|
1747
|
+
// No other dialect really needs this so we are coding here but maybe someday
|
|
1748
|
+
// this makes its way into the dialect.
|
|
1749
|
+
generateSQLPassthroughKeys(qs) {
|
|
1750
|
+
let ret = '';
|
|
1751
|
+
if (qs.dialect.name === 'standardsql') {
|
|
1752
|
+
const psudoCols = [
|
|
1753
|
+
'_TABLE_SUFFIX',
|
|
1754
|
+
'_PARTITIONDATE',
|
|
1755
|
+
'_PARTITIONTIME',
|
|
1756
|
+
].filter(element => qs.getChildByName(element) !== undefined);
|
|
1757
|
+
if (psudoCols.length > 0) {
|
|
1758
|
+
ret = ', ' + psudoCols.join(', ');
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
return ret;
|
|
1762
|
+
}
|
|
1743
1763
|
generateSQLJoins(stageWriter) {
|
|
1744
1764
|
let s = '';
|
|
1745
1765
|
// get the first value from the map (weird, I know)
|
|
@@ -1756,7 +1776,8 @@ class QueryQuery extends QueryField {
|
|
|
1756
1776
|
const structRelationship = qs.fieldDef.structRelationship;
|
|
1757
1777
|
if (structRelationship.type === 'basetable') {
|
|
1758
1778
|
if (ji.makeUniqueKey) {
|
|
1759
|
-
|
|
1779
|
+
const passKeys = this.generateSQLPassthroughKeys(qs);
|
|
1780
|
+
structSQL = `(SELECT ${qs.dialect.sqlGenerateUUID()} as __distinct_key, * ${passKeys} FROM ${structSQL} as x)`;
|
|
1760
1781
|
}
|
|
1761
1782
|
s += `FROM ${structSQL} as ${this.parent.getIdentifier()}\n`;
|
|
1762
1783
|
}
|