@dataform/core 2.3.2 → 2.4.0
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/bundle.d.ts +17 -4
- package/bundle.js +287 -195
- package/core.proto +10 -1
- package/package.json +1 -1
package/bundle.d.ts
CHANGED
|
@@ -1553,6 +1553,15 @@ namespace dataform {
|
|
|
1553
1553
|
}
|
|
1554
1554
|
}
|
|
1555
1555
|
|
|
1556
|
+
/** TableType enum. */
|
|
1557
|
+
enum TableType {
|
|
1558
|
+
UNKNOWN_TYPE = 0,
|
|
1559
|
+
TABLE = 1,
|
|
1560
|
+
INCREMENTAL = 2,
|
|
1561
|
+
VIEW = 3,
|
|
1562
|
+
INLINE = 4
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1556
1565
|
/** Properties of a Table. */
|
|
1557
1566
|
interface ITable {
|
|
1558
1567
|
|
|
@@ -1583,6 +1592,9 @@ namespace dataform {
|
|
|
1583
1592
|
/** Table materialized */
|
|
1584
1593
|
materialized?: (boolean|null);
|
|
1585
1594
|
|
|
1595
|
+
/** Table enumType */
|
|
1596
|
+
enumType?: (dataform.TableType|null);
|
|
1597
|
+
|
|
1586
1598
|
/** Table actionDescriptor */
|
|
1587
1599
|
actionDescriptor?: (dataform.IActionDescriptor|null);
|
|
1588
1600
|
|
|
@@ -1665,6 +1677,9 @@ namespace dataform {
|
|
|
1665
1677
|
/** Table materialized. */
|
|
1666
1678
|
public materialized: boolean;
|
|
1667
1679
|
|
|
1680
|
+
/** Table enumType. */
|
|
1681
|
+
public enumType: dataform.TableType;
|
|
1682
|
+
|
|
1668
1683
|
/** Table actionDescriptor. */
|
|
1669
1684
|
public actionDescriptor?: (dataform.IActionDescriptor|null);
|
|
1670
1685
|
|
|
@@ -6193,7 +6208,7 @@ interface IAdapter {
|
|
|
6193
6208
|
publishTasks(table: dataform.ITable, runConfig: dataform.IRunConfig, tableMetadata: dataform.ITableMetadata): Tasks;
|
|
6194
6209
|
assertTasks(assertion: dataform.IAssertion, projectConfig: dataform.IProjectConfig): Tasks;
|
|
6195
6210
|
dropIfExists(target: dataform.ITarget, type: dataform.TableMetadata.Type): string;
|
|
6196
|
-
baseTableType(
|
|
6211
|
+
baseTableType(enumType: dataform.TableType): dataform.TableMetadata.Type;
|
|
6197
6212
|
indexAssertion(dataset: string, indexCols: string[]): string;
|
|
6198
6213
|
rowConditionsAssertion(dataset: string, rowConditions: string[]): string;
|
|
6199
6214
|
}
|
|
@@ -6443,9 +6458,7 @@ interface ITableContext extends ICommonContext {
|
|
|
6443
6458
|
incremental: () => boolean;
|
|
6444
6459
|
}
|
|
6445
6460
|
declare class Table {
|
|
6446
|
-
static readonly
|
|
6447
|
-
[tableType: string]: Array<keyof dataform.ITable>;
|
|
6448
|
-
};
|
|
6461
|
+
static readonly INLINE_IGNORED_PROPS: Array<keyof dataform.ITable>;
|
|
6449
6462
|
proto: dataform.ITable;
|
|
6450
6463
|
session: Session;
|
|
6451
6464
|
contextableQuery: Contextable<ITableContext, string>;
|
package/bundle.js
CHANGED
|
@@ -4174,6 +4174,26 @@ const dataform = $root.dataform = (() => {
|
|
|
4174
4174
|
return ColumnDescriptor;
|
|
4175
4175
|
})();
|
|
4176
4176
|
|
|
4177
|
+
/**
|
|
4178
|
+
* TableType enum.
|
|
4179
|
+
* @name dataform.TableType
|
|
4180
|
+
* @enum {number}
|
|
4181
|
+
* @property {number} UNKNOWN_TYPE=0 UNKNOWN_TYPE value
|
|
4182
|
+
* @property {number} TABLE=1 TABLE value
|
|
4183
|
+
* @property {number} INCREMENTAL=2 INCREMENTAL value
|
|
4184
|
+
* @property {number} VIEW=3 VIEW value
|
|
4185
|
+
* @property {number} INLINE=4 INLINE value
|
|
4186
|
+
*/
|
|
4187
|
+
dataform.TableType = (function() {
|
|
4188
|
+
const valuesById = {}, values = Object.create(valuesById);
|
|
4189
|
+
values[valuesById[0] = "UNKNOWN_TYPE"] = 0;
|
|
4190
|
+
values[valuesById[1] = "TABLE"] = 1;
|
|
4191
|
+
values[valuesById[2] = "INCREMENTAL"] = 2;
|
|
4192
|
+
values[valuesById[3] = "VIEW"] = 3;
|
|
4193
|
+
values[valuesById[4] = "INLINE"] = 4;
|
|
4194
|
+
return values;
|
|
4195
|
+
})();
|
|
4196
|
+
|
|
4177
4197
|
dataform.Table = (function() {
|
|
4178
4198
|
|
|
4179
4199
|
/**
|
|
@@ -4189,6 +4209,7 @@ const dataform = $root.dataform = (() => {
|
|
|
4189
4209
|
* @property {string|null} [query] Table query
|
|
4190
4210
|
* @property {boolean|null} ["protected"] Table protected
|
|
4191
4211
|
* @property {boolean|null} [materialized] Table materialized
|
|
4212
|
+
* @property {dataform.TableType|null} [enumType] Table enumType
|
|
4192
4213
|
* @property {dataform.IActionDescriptor|null} [actionDescriptor] Table actionDescriptor
|
|
4193
4214
|
* @property {Array.<string>|null} [tags] Table tags
|
|
4194
4215
|
* @property {string|null} [where] Table where
|
|
@@ -4300,6 +4321,14 @@ const dataform = $root.dataform = (() => {
|
|
|
4300
4321
|
*/
|
|
4301
4322
|
Table.prototype.materialized = false;
|
|
4302
4323
|
|
|
4324
|
+
/**
|
|
4325
|
+
* Table enumType.
|
|
4326
|
+
* @member {dataform.TableType} enumType
|
|
4327
|
+
* @memberof dataform.Table
|
|
4328
|
+
* @instance
|
|
4329
|
+
*/
|
|
4330
|
+
Table.prototype.enumType = 0;
|
|
4331
|
+
|
|
4303
4332
|
/**
|
|
4304
4333
|
* Table actionDescriptor.
|
|
4305
4334
|
* @member {dataform.IActionDescriptor|null|undefined} actionDescriptor
|
|
@@ -4499,6 +4528,8 @@ const dataform = $root.dataform = (() => {
|
|
|
4499
4528
|
$root.dataform.PrestoOptions.encode(message.presto, writer.uint32(/* id 34, wireType 2 =*/274).fork()).ldelim();
|
|
4500
4529
|
if (message.materialized != null && Object.hasOwnProperty.call(message, "materialized"))
|
|
4501
4530
|
writer.uint32(/* id 35, wireType 0 =*/280).bool(message.materialized);
|
|
4531
|
+
if (message.enumType != null && Object.hasOwnProperty.call(message, "enumType"))
|
|
4532
|
+
writer.uint32(/* id 36, wireType 0 =*/288).int32(message.enumType);
|
|
4502
4533
|
return writer;
|
|
4503
4534
|
};
|
|
4504
4535
|
|
|
@@ -4571,6 +4602,10 @@ const dataform = $root.dataform = (() => {
|
|
|
4571
4602
|
message.materialized = reader.bool();
|
|
4572
4603
|
break;
|
|
4573
4604
|
}
|
|
4605
|
+
case 36: {
|
|
4606
|
+
message.enumType = reader.int32();
|
|
4607
|
+
break;
|
|
4608
|
+
}
|
|
4574
4609
|
case 24: {
|
|
4575
4610
|
message.actionDescriptor = $root.dataform.ActionDescriptor.decode(reader, reader.uint32());
|
|
4576
4611
|
break;
|
|
@@ -4721,6 +4756,17 @@ const dataform = $root.dataform = (() => {
|
|
|
4721
4756
|
if (message.materialized != null && message.hasOwnProperty("materialized"))
|
|
4722
4757
|
if (typeof message.materialized !== "boolean")
|
|
4723
4758
|
return "materialized: boolean expected";
|
|
4759
|
+
if (message.enumType != null && message.hasOwnProperty("enumType"))
|
|
4760
|
+
switch (message.enumType) {
|
|
4761
|
+
default:
|
|
4762
|
+
return "enumType: enum value expected";
|
|
4763
|
+
case 0:
|
|
4764
|
+
case 1:
|
|
4765
|
+
case 2:
|
|
4766
|
+
case 3:
|
|
4767
|
+
case 4:
|
|
4768
|
+
break;
|
|
4769
|
+
}
|
|
4724
4770
|
if (message.actionDescriptor != null && message.hasOwnProperty("actionDescriptor")) {
|
|
4725
4771
|
let error = $root.dataform.ActionDescriptor.verify(message.actionDescriptor);
|
|
4726
4772
|
if (error)
|
|
@@ -4861,6 +4907,28 @@ const dataform = $root.dataform = (() => {
|
|
|
4861
4907
|
message["protected"] = Boolean(object["protected"]);
|
|
4862
4908
|
if (object.materialized != null)
|
|
4863
4909
|
message.materialized = Boolean(object.materialized);
|
|
4910
|
+
switch (object.enumType) {
|
|
4911
|
+
case "UNKNOWN_TYPE":
|
|
4912
|
+
case 0:
|
|
4913
|
+
message.enumType = 0;
|
|
4914
|
+
break;
|
|
4915
|
+
case "TABLE":
|
|
4916
|
+
case 1:
|
|
4917
|
+
message.enumType = 1;
|
|
4918
|
+
break;
|
|
4919
|
+
case "INCREMENTAL":
|
|
4920
|
+
case 2:
|
|
4921
|
+
message.enumType = 2;
|
|
4922
|
+
break;
|
|
4923
|
+
case "VIEW":
|
|
4924
|
+
case 3:
|
|
4925
|
+
message.enumType = 3;
|
|
4926
|
+
break;
|
|
4927
|
+
case "INLINE":
|
|
4928
|
+
case 4:
|
|
4929
|
+
message.enumType = 4;
|
|
4930
|
+
break;
|
|
4931
|
+
}
|
|
4864
4932
|
if (object.actionDescriptor != null) {
|
|
4865
4933
|
if (typeof object.actionDescriptor !== "object")
|
|
4866
4934
|
throw TypeError(".dataform.Table.actionDescriptor: object expected");
|
|
@@ -4982,6 +5050,7 @@ const dataform = $root.dataform = (() => {
|
|
|
4982
5050
|
object.snowflake = null;
|
|
4983
5051
|
object.presto = null;
|
|
4984
5052
|
object.materialized = false;
|
|
5053
|
+
object.enumType = options.enums === String ? "UNKNOWN_TYPE" : 0;
|
|
4985
5054
|
}
|
|
4986
5055
|
if (message.type != null && message.hasOwnProperty("type"))
|
|
4987
5056
|
object.type = message.type;
|
|
@@ -5052,6 +5121,8 @@ const dataform = $root.dataform = (() => {
|
|
|
5052
5121
|
object.presto = $root.dataform.PrestoOptions.toObject(message.presto, options);
|
|
5053
5122
|
if (message.materialized != null && message.hasOwnProperty("materialized"))
|
|
5054
5123
|
object.materialized = message.materialized;
|
|
5124
|
+
if (message.enumType != null && message.hasOwnProperty("enumType"))
|
|
5125
|
+
object.enumType = options.enums === String ? $root.dataform.TableType[message.enumType] : message.enumType;
|
|
5055
5126
|
return object;
|
|
5056
5127
|
};
|
|
5057
5128
|
|
|
@@ -16426,6 +16497,166 @@ class Task {
|
|
|
16426
16497
|
}
|
|
16427
16498
|
}
|
|
16428
16499
|
|
|
16500
|
+
const pathSeperator = (() => {
|
|
16501
|
+
if (typeof process !== "undefined") {
|
|
16502
|
+
return process.platform === "win32" ? "\\" : "/";
|
|
16503
|
+
}
|
|
16504
|
+
return "/";
|
|
16505
|
+
})();
|
|
16506
|
+
function relativePath(fullPath, base) {
|
|
16507
|
+
if (base.length === 0) {
|
|
16508
|
+
return fullPath;
|
|
16509
|
+
}
|
|
16510
|
+
const stripped = fullPath.substr(base.length);
|
|
16511
|
+
if (stripped.startsWith(pathSeperator)) {
|
|
16512
|
+
return stripped.substr(1);
|
|
16513
|
+
}
|
|
16514
|
+
else {
|
|
16515
|
+
return stripped;
|
|
16516
|
+
}
|
|
16517
|
+
}
|
|
16518
|
+
function baseFilename(fullPath) {
|
|
16519
|
+
return fullPath
|
|
16520
|
+
.split(pathSeperator)
|
|
16521
|
+
.slice(-1)[0]
|
|
16522
|
+
.split(".")[0];
|
|
16523
|
+
}
|
|
16524
|
+
function getCallerFile(rootDir) {
|
|
16525
|
+
let lastfile;
|
|
16526
|
+
const stack = getCurrentStack();
|
|
16527
|
+
while (stack.length) {
|
|
16528
|
+
const nextLastfile = stack.shift().getFileName();
|
|
16529
|
+
if (!nextLastfile) {
|
|
16530
|
+
continue;
|
|
16531
|
+
}
|
|
16532
|
+
if (!nextLastfile.includes(rootDir)) {
|
|
16533
|
+
continue;
|
|
16534
|
+
}
|
|
16535
|
+
if (nextLastfile.includes("node_modules")) {
|
|
16536
|
+
continue;
|
|
16537
|
+
}
|
|
16538
|
+
lastfile = nextLastfile;
|
|
16539
|
+
if (!(nextLastfile.includes(`definitions${pathSeperator}`) ||
|
|
16540
|
+
nextLastfile.includes(`models${pathSeperator}`))) {
|
|
16541
|
+
continue;
|
|
16542
|
+
}
|
|
16543
|
+
break;
|
|
16544
|
+
}
|
|
16545
|
+
if (!lastfile) {
|
|
16546
|
+
throw new Error("Unable to find valid caller file; please report this issue.");
|
|
16547
|
+
}
|
|
16548
|
+
return relativePath(lastfile, rootDir);
|
|
16549
|
+
}
|
|
16550
|
+
function getCurrentStack() {
|
|
16551
|
+
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
16552
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
16553
|
+
try {
|
|
16554
|
+
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
16555
|
+
Error.prepareStackTrace = (err, stack) => {
|
|
16556
|
+
return stack;
|
|
16557
|
+
};
|
|
16558
|
+
return new Error().stack;
|
|
16559
|
+
}
|
|
16560
|
+
finally {
|
|
16561
|
+
Error.stackTraceLimit = originalStackTraceLimit;
|
|
16562
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
16563
|
+
}
|
|
16564
|
+
}
|
|
16565
|
+
const invalidRefInputMessage = "Invalid input. Accepted inputs include: a single object containing " +
|
|
16566
|
+
"an (optional) 'database', (optional) 'schema', and 'name', " +
|
|
16567
|
+
"or 1-3 inputs consisting of an (optional) database, (optional) schema, and 'name'.";
|
|
16568
|
+
function toResolvable(ref, rest = []) {
|
|
16569
|
+
if (Array.isArray(ref) && rest.length > 0) {
|
|
16570
|
+
throw new Error(invalidRefInputMessage);
|
|
16571
|
+
}
|
|
16572
|
+
if (rest.length === 0 && !Array.isArray(ref)) {
|
|
16573
|
+
return ref;
|
|
16574
|
+
}
|
|
16575
|
+
const resolvableArray = Array.isArray(ref) ? ref.reverse() : [ref, ...rest].reverse();
|
|
16576
|
+
if (!isResolvableArray(resolvableArray)) {
|
|
16577
|
+
throw new Error(invalidRefInputMessage);
|
|
16578
|
+
}
|
|
16579
|
+
const [name, schema, database] = resolvableArray;
|
|
16580
|
+
return { database, schema, name };
|
|
16581
|
+
}
|
|
16582
|
+
function isResolvableArray(parts) {
|
|
16583
|
+
if (parts.some(part => typeof part !== "string")) {
|
|
16584
|
+
return false;
|
|
16585
|
+
}
|
|
16586
|
+
return parts.length > 0 && parts.length <= 3;
|
|
16587
|
+
}
|
|
16588
|
+
function resolvableAsTarget(resolvable) {
|
|
16589
|
+
if (typeof resolvable === "string") {
|
|
16590
|
+
return {
|
|
16591
|
+
name: resolvable
|
|
16592
|
+
};
|
|
16593
|
+
}
|
|
16594
|
+
return resolvable;
|
|
16595
|
+
}
|
|
16596
|
+
function stringifyResolvable(res) {
|
|
16597
|
+
return typeof res === "string" ? res : JSON.stringify(res);
|
|
16598
|
+
}
|
|
16599
|
+
function ambiguousActionNameMsg(act, allActs) {
|
|
16600
|
+
const allActNames = typeof allActs[0] === "string"
|
|
16601
|
+
? allActs
|
|
16602
|
+
: allActs.map(r => `${r.proto.target.schema}.${r.proto.target.name}`);
|
|
16603
|
+
return `Ambiguous Action name: ${stringifyResolvable(act)}. Did you mean one of: ${allActNames.join(", ")}.`;
|
|
16604
|
+
}
|
|
16605
|
+
function target(adapter, config, name, schema, database) {
|
|
16606
|
+
schema = schema || config.defaultSchema;
|
|
16607
|
+
database = database || config.defaultDatabase;
|
|
16608
|
+
return dataform.Target.create({
|
|
16609
|
+
name: adapter.normalizeIdentifier(name),
|
|
16610
|
+
schema: !!schema ? adapter.normalizeIdentifier(schema || config.defaultSchema) : undefined,
|
|
16611
|
+
database: !!database ? adapter.normalizeIdentifier(database) : undefined
|
|
16612
|
+
});
|
|
16613
|
+
}
|
|
16614
|
+
function setNameAndTarget(session, action, name, overrideSchema, overrideDatabase) {
|
|
16615
|
+
action.target = target(session.adapter(), session.config, name, overrideSchema, overrideDatabase);
|
|
16616
|
+
action.canonicalTarget = target(session.adapter(), session.canonicalConfig, name, overrideSchema, overrideDatabase);
|
|
16617
|
+
}
|
|
16618
|
+
function strictKeysOf() {
|
|
16619
|
+
return (array) => array;
|
|
16620
|
+
}
|
|
16621
|
+
function checkExcessProperties(reportError, object, supportedProperties, name) {
|
|
16622
|
+
const extraProperties = Object.keys(object).filter(key => !supportedProperties.includes(key));
|
|
16623
|
+
if (extraProperties.length > 0) {
|
|
16624
|
+
reportError(new Error(`Unexpected property "${extraProperties[0]}"${!!name ? ` in ${name}` : ""}. Supported properties are: ${JSON.stringify(supportedProperties)}`));
|
|
16625
|
+
}
|
|
16626
|
+
}
|
|
16627
|
+
function validateQueryString(session, query, filename) {
|
|
16628
|
+
if ((query === null || query === void 0 ? void 0 : query.trim().slice(-1)) === ";") {
|
|
16629
|
+
session.compileError(new Error("Semi-colons are not allowed at the end of SQL statements."), filename);
|
|
16630
|
+
}
|
|
16631
|
+
}
|
|
16632
|
+
function throwIfInvalid(proto, verify) {
|
|
16633
|
+
const verifyError = verify(proto);
|
|
16634
|
+
if (verifyError) {
|
|
16635
|
+
throw new Error(verifyError);
|
|
16636
|
+
}
|
|
16637
|
+
}
|
|
16638
|
+
function tableTypeStringToEnum(type, throwIfUnknown) {
|
|
16639
|
+
switch (type) {
|
|
16640
|
+
case "table":
|
|
16641
|
+
return dataform.TableType.TABLE;
|
|
16642
|
+
case "incremental":
|
|
16643
|
+
return dataform.TableType.INCREMENTAL;
|
|
16644
|
+
case "view":
|
|
16645
|
+
return dataform.TableType.VIEW;
|
|
16646
|
+
case "inline":
|
|
16647
|
+
return dataform.TableType.INLINE;
|
|
16648
|
+
default: {
|
|
16649
|
+
if (throwIfUnknown) {
|
|
16650
|
+
throw new Error(`Unexpected table type: ${type}`);
|
|
16651
|
+
}
|
|
16652
|
+
return dataform.TableType.UNKNOWN_TYPE;
|
|
16653
|
+
}
|
|
16654
|
+
}
|
|
16655
|
+
}
|
|
16656
|
+
function tableTypeEnumToString(enumType) {
|
|
16657
|
+
return dataform.TableType[enumType].toLowerCase();
|
|
16658
|
+
}
|
|
16659
|
+
|
|
16429
16660
|
class Adapter {
|
|
16430
16661
|
constructor(dataformCoreVersion) {
|
|
16431
16662
|
this.dataformCoreVersion = dataformCoreVersion;
|
|
@@ -16439,15 +16670,15 @@ class Adapter {
|
|
|
16439
16670
|
dropIfExists(target, type) {
|
|
16440
16671
|
return `drop ${this.tableTypeAsSql(type)} if exists ${this.resolveTarget(target)} ${type === dataform.TableMetadata.Type.TABLE ? "cascade" : ""}`;
|
|
16441
16672
|
}
|
|
16442
|
-
baseTableType(
|
|
16443
|
-
switch (
|
|
16444
|
-
case
|
|
16445
|
-
case
|
|
16673
|
+
baseTableType(enumType) {
|
|
16674
|
+
switch (enumType) {
|
|
16675
|
+
case dataform.TableType.TABLE:
|
|
16676
|
+
case dataform.TableType.INCREMENTAL:
|
|
16446
16677
|
return dataform.TableMetadata.Type.TABLE;
|
|
16447
|
-
case
|
|
16678
|
+
case dataform.TableType.VIEW:
|
|
16448
16679
|
return dataform.TableMetadata.Type.VIEW;
|
|
16449
16680
|
default:
|
|
16450
|
-
throw new Error(`Unexpected table type: ${
|
|
16681
|
+
throw new Error(`Unexpected table type: ${tableTypeEnumToString(enumType)}`);
|
|
16451
16682
|
}
|
|
16452
16683
|
}
|
|
16453
16684
|
tableTypeAsSql(type) {
|
|
@@ -16518,7 +16749,7 @@ from (${query}) as insertions`;
|
|
|
16518
16749
|
preOps(table, runConfig, tableMetadata) {
|
|
16519
16750
|
let preOps = table.preOps;
|
|
16520
16751
|
if (semver.gt(this.dataformCoreVersion, "1.4.8") &&
|
|
16521
|
-
table.
|
|
16752
|
+
table.enumType === dataform.TableType.INCREMENTAL &&
|
|
16522
16753
|
this.shouldWriteIncrementally(runConfig, tableMetadata)) {
|
|
16523
16754
|
preOps = table.incrementalPreOps;
|
|
16524
16755
|
}
|
|
@@ -16527,7 +16758,7 @@ from (${query}) as insertions`;
|
|
|
16527
16758
|
postOps(table, runConfig, tableMetadata) {
|
|
16528
16759
|
let postOps = table.postOps;
|
|
16529
16760
|
if (semver.gt(this.dataformCoreVersion, "1.4.8") &&
|
|
16530
|
-
table.
|
|
16761
|
+
table.enumType === dataform.TableType.INCREMENTAL &&
|
|
16531
16762
|
this.shouldWriteIncrementally(runConfig, tableMetadata)) {
|
|
16532
16763
|
postOps = table.incrementalPostOps;
|
|
16533
16764
|
}
|
|
@@ -16547,11 +16778,11 @@ class BigQueryAdapter extends Adapter {
|
|
|
16547
16778
|
publishTasks(table, runConfig, tableMetadata) {
|
|
16548
16779
|
const tasks = Tasks.create();
|
|
16549
16780
|
this.preOps(table, runConfig, tableMetadata).forEach(statement => tasks.add(statement));
|
|
16550
|
-
const baseTableType = this.baseTableType(table.
|
|
16781
|
+
const baseTableType = this.baseTableType(table.enumType);
|
|
16551
16782
|
if (tableMetadata && tableMetadata.type !== baseTableType) {
|
|
16552
16783
|
tasks.add(Task.statement(this.dropIfExists(table.target, this.oppositeTableType(baseTableType))));
|
|
16553
16784
|
}
|
|
16554
|
-
if (table.
|
|
16785
|
+
if (table.enumType === dataform.TableType.INCREMENTAL) {
|
|
16555
16786
|
if (!this.shouldWriteIncrementally(runConfig, tableMetadata)) {
|
|
16556
16787
|
tasks.add(Task.statement(this.createOrReplace(table)));
|
|
16557
16788
|
}
|
|
@@ -16592,7 +16823,7 @@ class BigQueryAdapter extends Adapter {
|
|
|
16592
16823
|
}
|
|
16593
16824
|
return `create or replace ${table.materialized
|
|
16594
16825
|
? "materialized "
|
|
16595
|
-
: ""}${this.tableTypeAsSql(this.baseTableType(table.
|
|
16826
|
+
: ""}${this.tableTypeAsSql(this.baseTableType(table.enumType))} ${this.resolveTarget(table.target)} ${table.bigquery && table.bigquery.partitionBy
|
|
16596
16827
|
? `partition by ${table.bigquery.partitionBy} `
|
|
16597
16828
|
: ""}${table.bigquery && table.bigquery.clusterBy && table.bigquery.clusterBy.length > 0
|
|
16598
16829
|
? `cluster by ${table.bigquery.clusterBy.join(", ")} `
|
|
@@ -16630,11 +16861,11 @@ class PrestoAdapter extends Adapter {
|
|
|
16630
16861
|
publishTasks(table, runConfig, tableMetadata) {
|
|
16631
16862
|
const tasks = Tasks.create();
|
|
16632
16863
|
this.preOps(table, runConfig, tableMetadata).forEach(statement => tasks.add(statement));
|
|
16633
|
-
const baseTableType = this.baseTableType(table.
|
|
16864
|
+
const baseTableType = this.baseTableType(table.enumType);
|
|
16634
16865
|
if (tableMetadata && tableMetadata.type !== baseTableType) {
|
|
16635
16866
|
tasks.add(Task.statement(this.dropIfExists(table.target, this.oppositeTableType(baseTableType))));
|
|
16636
16867
|
}
|
|
16637
|
-
if (table.
|
|
16868
|
+
if (table.enumType === dataform.TableType.INCREMENTAL) {
|
|
16638
16869
|
throw new Error("Incremental table types are not currently supported for Presto.");
|
|
16639
16870
|
}
|
|
16640
16871
|
else {
|
|
@@ -16680,11 +16911,11 @@ class RedshiftAdapter extends Adapter {
|
|
|
16680
16911
|
publishTasks(table, runConfig, tableMetadata) {
|
|
16681
16912
|
const tasks = Tasks.create();
|
|
16682
16913
|
this.preOps(table, runConfig, tableMetadata).forEach(statement => tasks.add(statement));
|
|
16683
|
-
const baseTableType = this.baseTableType(table.
|
|
16914
|
+
const baseTableType = this.baseTableType(table.enumType);
|
|
16684
16915
|
if (tableMetadata && tableMetadata.type !== baseTableType) {
|
|
16685
16916
|
tasks.add(Task.statement(this.dropIfExists(table.target, this.oppositeTableType(baseTableType))));
|
|
16686
16917
|
}
|
|
16687
|
-
if (table.
|
|
16918
|
+
if (table.enumType === dataform.TableType.INCREMENTAL) {
|
|
16688
16919
|
if (!this.shouldWriteIncrementally(runConfig, tableMetadata)) {
|
|
16689
16920
|
tasks.addAll(this.createOrReplace(table));
|
|
16690
16921
|
}
|
|
@@ -16722,12 +16953,12 @@ class RedshiftAdapter extends Adapter {
|
|
|
16722
16953
|
return `${createQuery} with no schema binding`;
|
|
16723
16954
|
}
|
|
16724
16955
|
createOrReplace(table) {
|
|
16725
|
-
if (table.
|
|
16956
|
+
if (table.enumType === dataform.TableType.VIEW) {
|
|
16726
16957
|
const isBindDefined = table.redshift && table.redshift.hasOwnProperty("bind");
|
|
16727
16958
|
const bindDefaultValue = semver.gte(this.dataformCoreVersion, "1.4.1") ? false : true;
|
|
16728
16959
|
const bind = (isBindDefined ? table.redshift.bind : bindDefaultValue) && this.isBindSupported();
|
|
16729
16960
|
return (Tasks.create()
|
|
16730
|
-
.add(Task.statement(this.dropIfExists(table.target, this.baseTableType(table.
|
|
16961
|
+
.add(Task.statement(this.dropIfExists(table.target, this.baseTableType(table.enumType))))
|
|
16731
16962
|
.add(Task.statement(this.createOrReplaceView(table.target, table.query, bind))));
|
|
16732
16963
|
}
|
|
16733
16964
|
const tempTableTarget = dataform.Target.create({
|
|
@@ -16735,7 +16966,7 @@ class RedshiftAdapter extends Adapter {
|
|
|
16735
16966
|
name: table.target.name + "_temp"
|
|
16736
16967
|
});
|
|
16737
16968
|
return Tasks.create()
|
|
16738
|
-
.add(Task.statement(this.dropIfExists(tempTableTarget, this.baseTableType(table.
|
|
16969
|
+
.add(Task.statement(this.dropIfExists(tempTableTarget, this.baseTableType(table.enumType))))
|
|
16739
16970
|
.add(Task.statement(this.createTable(table, tempTableTarget)))
|
|
16740
16971
|
.add(Task.statement(this.dropIfExists(table.target, dataform.TableMetadata.Type.TABLE)))
|
|
16741
16972
|
.add(Task.statement(`alter table ${this.resolveTarget(tempTableTarget)} rename to "${table.target.name}"`));
|
|
@@ -16787,11 +17018,11 @@ class SnowflakeAdapter extends Adapter {
|
|
|
16787
17018
|
publishTasks(table, runConfig, tableMetadata) {
|
|
16788
17019
|
const tasks = Tasks.create();
|
|
16789
17020
|
this.preOps(table, runConfig, tableMetadata).forEach(statement => tasks.add(statement));
|
|
16790
|
-
const baseTableType = this.baseTableType(table.
|
|
17021
|
+
const baseTableType = this.baseTableType(table.enumType);
|
|
16791
17022
|
if (tableMetadata && tableMetadata.type !== baseTableType) {
|
|
16792
17023
|
tasks.add(Task.statement(this.dropIfExists(table.target, this.oppositeTableType(baseTableType))));
|
|
16793
17024
|
}
|
|
16794
|
-
if (table.
|
|
17025
|
+
if (table.enumType === dataform.TableType.INCREMENTAL) {
|
|
16795
17026
|
if (!this.shouldWriteIncrementally(runConfig, tableMetadata)) {
|
|
16796
17027
|
tasks.add(Task.statement(this.createOrReplace(table)));
|
|
16797
17028
|
}
|
|
@@ -16819,7 +17050,7 @@ class SnowflakeAdapter extends Adapter {
|
|
|
16819
17050
|
}
|
|
16820
17051
|
createOrReplace(table) {
|
|
16821
17052
|
var _a, _b, _c, _d, _e;
|
|
16822
|
-
if (table.
|
|
17053
|
+
if (table.enumType === dataform.TableType.VIEW) {
|
|
16823
17054
|
return this.createOrReplaceView(table.target, table.query, (_a = table.snowflake) === null || _a === void 0 ? void 0 : _a.secure, table.materialized);
|
|
16824
17055
|
}
|
|
16825
17056
|
return `create or replace ${((_b = table.snowflake) === null || _b === void 0 ? void 0 : _b.transient) ? "transient " : ""}table ${this.resolveTarget(table.target)} ${((_d = (_c = table.snowflake) === null || _c === void 0 ? void 0 : _c.clusterBy) === null || _d === void 0 ? void 0 : _d.length) > 0
|
|
@@ -16853,11 +17084,11 @@ class SQLDataWarehouseAdapter extends Adapter {
|
|
|
16853
17084
|
publishTasks(table, runConfig, tableMetadata) {
|
|
16854
17085
|
const tasks = Tasks.create();
|
|
16855
17086
|
this.preOps(table, runConfig, tableMetadata).forEach(statement => tasks.add(statement));
|
|
16856
|
-
const baseTableType = this.baseTableType(table.
|
|
17087
|
+
const baseTableType = this.baseTableType(table.enumType);
|
|
16857
17088
|
if (tableMetadata && tableMetadata.type !== baseTableType) {
|
|
16858
17089
|
tasks.add(Task.statement(this.dropIfExists(table.target, this.oppositeTableType(baseTableType))));
|
|
16859
17090
|
}
|
|
16860
|
-
if (table.
|
|
17091
|
+
if (table.enumType === dataform.TableType.INCREMENTAL) {
|
|
16861
17092
|
if (!this.shouldWriteIncrementally(runConfig, tableMetadata)) {
|
|
16862
17093
|
tasks.addAll(this.createOrReplace(table, !!tableMetadata));
|
|
16863
17094
|
}
|
|
@@ -16895,7 +17126,7 @@ from (${query}
|
|
|
16895
17126
|
) as insertions`;
|
|
16896
17127
|
}
|
|
16897
17128
|
createOrReplace(table, alreadyExists) {
|
|
16898
|
-
if (table.
|
|
17129
|
+
if (table.enumType === dataform.TableType.VIEW) {
|
|
16899
17130
|
return Tasks.create().add(Task.statement(`${alreadyExists ? "alter" : "create"} view ${this.resolveTarget(table.target)} as ${table.query}`));
|
|
16900
17131
|
}
|
|
16901
17132
|
const tempTableTarget = dataform.Target.create({
|
|
@@ -16903,7 +17134,7 @@ from (${query}
|
|
|
16903
17134
|
name: table.target.name + "_temp"
|
|
16904
17135
|
});
|
|
16905
17136
|
return Tasks.create()
|
|
16906
|
-
.add(Task.statement(this.dropIfExists(tempTableTarget, this.baseTableType(table.
|
|
17137
|
+
.add(Task.statement(this.dropIfExists(tempTableTarget, this.baseTableType(table.enumType))))
|
|
16907
17138
|
.add(Task.statement(this.createTable(table, tempTableTarget)))
|
|
16908
17139
|
.add(Task.statement(this.dropIfExists(table.target, dataform.TableMetadata.Type.TABLE)))
|
|
16909
17140
|
.add(Task.statement(`rename object ${this.resolveTarget(tempTableTarget)} to ${table.target.name} `));
|
|
@@ -16991,7 +17222,7 @@ function collectEvaluationQueries(queryOrAction, concatenate, queryModifier = (q
|
|
|
16991
17222
|
else {
|
|
16992
17223
|
try {
|
|
16993
17224
|
if (queryOrAction instanceof dataform.Table) {
|
|
16994
|
-
if (queryOrAction.
|
|
17225
|
+
if (queryOrAction.enumType === dataform.TableType.INCREMENTAL) {
|
|
16995
17226
|
const incrementalTableQueries = queryOrAction.incrementalPreOps.concat(queryOrAction.incrementalQuery, queryOrAction.incrementalPostOps);
|
|
16996
17227
|
if (concatenate) {
|
|
16997
17228
|
validationQueries.push({
|
|
@@ -17049,145 +17280,6 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
17049
17280
|
collectEvaluationQueries: collectEvaluationQueries
|
|
17050
17281
|
});
|
|
17051
17282
|
|
|
17052
|
-
const pathSeperator = (() => {
|
|
17053
|
-
if (typeof process !== "undefined") {
|
|
17054
|
-
return process.platform === "win32" ? "\\" : "/";
|
|
17055
|
-
}
|
|
17056
|
-
return "/";
|
|
17057
|
-
})();
|
|
17058
|
-
function relativePath(fullPath, base) {
|
|
17059
|
-
if (base.length === 0) {
|
|
17060
|
-
return fullPath;
|
|
17061
|
-
}
|
|
17062
|
-
const stripped = fullPath.substr(base.length);
|
|
17063
|
-
if (stripped.startsWith(pathSeperator)) {
|
|
17064
|
-
return stripped.substr(1);
|
|
17065
|
-
}
|
|
17066
|
-
else {
|
|
17067
|
-
return stripped;
|
|
17068
|
-
}
|
|
17069
|
-
}
|
|
17070
|
-
function baseFilename(fullPath) {
|
|
17071
|
-
return fullPath
|
|
17072
|
-
.split(pathSeperator)
|
|
17073
|
-
.slice(-1)[0]
|
|
17074
|
-
.split(".")[0];
|
|
17075
|
-
}
|
|
17076
|
-
function getCallerFile(rootDir) {
|
|
17077
|
-
let lastfile;
|
|
17078
|
-
const stack = getCurrentStack();
|
|
17079
|
-
while (stack.length) {
|
|
17080
|
-
const nextLastfile = stack.shift().getFileName();
|
|
17081
|
-
if (!nextLastfile) {
|
|
17082
|
-
continue;
|
|
17083
|
-
}
|
|
17084
|
-
if (!nextLastfile.includes(rootDir)) {
|
|
17085
|
-
continue;
|
|
17086
|
-
}
|
|
17087
|
-
if (nextLastfile.includes("node_modules")) {
|
|
17088
|
-
continue;
|
|
17089
|
-
}
|
|
17090
|
-
lastfile = nextLastfile;
|
|
17091
|
-
if (!(nextLastfile.includes(`definitions${pathSeperator}`) ||
|
|
17092
|
-
nextLastfile.includes(`models${pathSeperator}`))) {
|
|
17093
|
-
continue;
|
|
17094
|
-
}
|
|
17095
|
-
break;
|
|
17096
|
-
}
|
|
17097
|
-
if (!lastfile) {
|
|
17098
|
-
throw new Error("Unable to find valid caller file; please report this issue.");
|
|
17099
|
-
}
|
|
17100
|
-
return relativePath(lastfile, rootDir);
|
|
17101
|
-
}
|
|
17102
|
-
function getCurrentStack() {
|
|
17103
|
-
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
17104
|
-
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
17105
|
-
try {
|
|
17106
|
-
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
17107
|
-
Error.prepareStackTrace = (err, stack) => {
|
|
17108
|
-
return stack;
|
|
17109
|
-
};
|
|
17110
|
-
return new Error().stack;
|
|
17111
|
-
}
|
|
17112
|
-
finally {
|
|
17113
|
-
Error.stackTraceLimit = originalStackTraceLimit;
|
|
17114
|
-
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
17115
|
-
}
|
|
17116
|
-
}
|
|
17117
|
-
const invalidRefInputMessage = "Invalid input. Accepted inputs include: a single object containing " +
|
|
17118
|
-
"an (optional) 'database', (optional) 'schema', and 'name', " +
|
|
17119
|
-
"or 1-3 inputs consisting of an (optional) database, (optional) schema, and 'name'.";
|
|
17120
|
-
function toResolvable(ref, rest = []) {
|
|
17121
|
-
if (Array.isArray(ref) && rest.length > 0) {
|
|
17122
|
-
throw new Error(invalidRefInputMessage);
|
|
17123
|
-
}
|
|
17124
|
-
if (rest.length === 0 && !Array.isArray(ref)) {
|
|
17125
|
-
return ref;
|
|
17126
|
-
}
|
|
17127
|
-
const resolvableArray = Array.isArray(ref) ? ref.reverse() : [ref, ...rest].reverse();
|
|
17128
|
-
if (!isResolvableArray(resolvableArray)) {
|
|
17129
|
-
throw new Error(invalidRefInputMessage);
|
|
17130
|
-
}
|
|
17131
|
-
const [name, schema, database] = resolvableArray;
|
|
17132
|
-
return { database, schema, name };
|
|
17133
|
-
}
|
|
17134
|
-
function isResolvableArray(parts) {
|
|
17135
|
-
if (parts.some(part => typeof part !== "string")) {
|
|
17136
|
-
return false;
|
|
17137
|
-
}
|
|
17138
|
-
return parts.length > 0 && parts.length <= 3;
|
|
17139
|
-
}
|
|
17140
|
-
function resolvableAsTarget(resolvable) {
|
|
17141
|
-
if (typeof resolvable === "string") {
|
|
17142
|
-
return {
|
|
17143
|
-
name: resolvable
|
|
17144
|
-
};
|
|
17145
|
-
}
|
|
17146
|
-
return resolvable;
|
|
17147
|
-
}
|
|
17148
|
-
function stringifyResolvable(res) {
|
|
17149
|
-
return typeof res === "string" ? res : JSON.stringify(res);
|
|
17150
|
-
}
|
|
17151
|
-
function ambiguousActionNameMsg(act, allActs) {
|
|
17152
|
-
const allActNames = typeof allActs[0] === "string"
|
|
17153
|
-
? allActs
|
|
17154
|
-
: allActs.map(r => `${r.proto.target.schema}.${r.proto.target.name}`);
|
|
17155
|
-
return `Ambiguous Action name: ${stringifyResolvable(act)}. Did you mean one of: ${allActNames.join(", ")}.`;
|
|
17156
|
-
}
|
|
17157
|
-
function target(adapter, config, name, schema, database) {
|
|
17158
|
-
schema = schema || config.defaultSchema;
|
|
17159
|
-
database = database || config.defaultDatabase;
|
|
17160
|
-
return dataform.Target.create({
|
|
17161
|
-
name: adapter.normalizeIdentifier(name),
|
|
17162
|
-
schema: !!schema ? adapter.normalizeIdentifier(schema || config.defaultSchema) : undefined,
|
|
17163
|
-
database: !!database ? adapter.normalizeIdentifier(database) : undefined
|
|
17164
|
-
});
|
|
17165
|
-
}
|
|
17166
|
-
function setNameAndTarget(session, action, name, overrideSchema, overrideDatabase) {
|
|
17167
|
-
action.target = target(session.adapter(), session.config, name, overrideSchema, overrideDatabase);
|
|
17168
|
-
action.canonicalTarget = target(session.adapter(), session.canonicalConfig, name, overrideSchema, overrideDatabase);
|
|
17169
|
-
}
|
|
17170
|
-
function strictKeysOf() {
|
|
17171
|
-
return (array) => array;
|
|
17172
|
-
}
|
|
17173
|
-
function checkExcessProperties(reportError, object, supportedProperties, name) {
|
|
17174
|
-
const extraProperties = Object.keys(object).filter(key => !supportedProperties.includes(key));
|
|
17175
|
-
if (extraProperties.length > 0) {
|
|
17176
|
-
reportError(new Error(`Unexpected property "${extraProperties[0]}"${!!name ? ` in ${name}` : ""}. Supported properties are: ${JSON.stringify(supportedProperties)}`));
|
|
17177
|
-
}
|
|
17178
|
-
}
|
|
17179
|
-
function validateQueryString(session, query, filename) {
|
|
17180
|
-
if ((query === null || query === void 0 ? void 0 : query.trim().slice(-1)) === ";") {
|
|
17181
|
-
session.compileError(new Error("Semi-colons are not allowed at the end of SQL statements."), filename);
|
|
17182
|
-
}
|
|
17183
|
-
}
|
|
17184
|
-
function throwIfInvalid(proto, verify) {
|
|
17185
|
-
const verifyError = verify(proto);
|
|
17186
|
-
if (verifyError) {
|
|
17187
|
-
throw new Error(verifyError);
|
|
17188
|
-
}
|
|
17189
|
-
}
|
|
17190
|
-
|
|
17191
17283
|
const IAssertionConfigProperties = strictKeysOf()([
|
|
17192
17284
|
"database",
|
|
17193
17285
|
"dependencies",
|
|
@@ -17652,6 +17744,7 @@ class Table {
|
|
|
17652
17744
|
constructor() {
|
|
17653
17745
|
this.proto = dataform.Table.create({
|
|
17654
17746
|
type: "view",
|
|
17747
|
+
enumType: dataform.TableType.VIEW,
|
|
17655
17748
|
disabled: false,
|
|
17656
17749
|
tags: []
|
|
17657
17750
|
});
|
|
@@ -17719,6 +17812,7 @@ class Table {
|
|
|
17719
17812
|
}
|
|
17720
17813
|
type(type) {
|
|
17721
17814
|
this.proto.type = type;
|
|
17815
|
+
this.proto.enumType = tableTypeStringToEnum(type, false);
|
|
17722
17816
|
return this;
|
|
17723
17817
|
}
|
|
17724
17818
|
query(query) {
|
|
@@ -17877,7 +17971,7 @@ class Table {
|
|
|
17877
17971
|
const context = new TableContext(this);
|
|
17878
17972
|
const incrementalContext = new TableContext(this, true);
|
|
17879
17973
|
this.proto.query = context.apply(this.contextableQuery);
|
|
17880
|
-
if (this.proto.
|
|
17974
|
+
if (this.proto.enumType === dataform.TableType.INCREMENTAL) {
|
|
17881
17975
|
this.proto.incrementalQuery = incrementalContext.apply(this.contextableQuery);
|
|
17882
17976
|
this.proto.incrementalPreOps = this.contextifyOps(this.contextablePreOps, incrementalContext);
|
|
17883
17977
|
this.proto.incrementalPostOps = this.contextifyOps(this.contextablePostOps, incrementalContext);
|
|
@@ -17900,20 +17994,18 @@ class Table {
|
|
|
17900
17994
|
return protoOps;
|
|
17901
17995
|
}
|
|
17902
17996
|
}
|
|
17903
|
-
Table.
|
|
17904
|
-
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
]
|
|
17916
|
-
};
|
|
17997
|
+
Table.INLINE_IGNORED_PROPS = [
|
|
17998
|
+
"bigquery",
|
|
17999
|
+
"redshift",
|
|
18000
|
+
"snowflake",
|
|
18001
|
+
"sqlDataWarehouse",
|
|
18002
|
+
"presto",
|
|
18003
|
+
"preOps",
|
|
18004
|
+
"postOps",
|
|
18005
|
+
"actionDescriptor",
|
|
18006
|
+
"disabled",
|
|
18007
|
+
"where"
|
|
18008
|
+
];
|
|
17917
18009
|
class TableContext {
|
|
17918
18010
|
constructor(table, isIncremental = false) {
|
|
17919
18011
|
this.table = table;
|
|
@@ -18962,7 +19054,7 @@ class Test {
|
|
|
18962
19054
|
if (!(dataset && dataset instanceof Table)) {
|
|
18963
19055
|
this.session.compileError(new Error(`Dataset ${stringifyResolvable(this.datasetToTest)} could not be found.`), this.proto.fileName);
|
|
18964
19056
|
}
|
|
18965
|
-
else if (dataset.proto.
|
|
19057
|
+
else if (dataset.proto.enumType === dataform.TableType.INCREMENTAL) {
|
|
18966
19058
|
this.session.compileError(new Error("Running tests on incremental datasets is not yet supported."), this.proto.fileName);
|
|
18967
19059
|
}
|
|
18968
19060
|
else {
|
|
@@ -19060,7 +19152,7 @@ class RefReplacingContext {
|
|
|
19060
19152
|
}
|
|
19061
19153
|
}
|
|
19062
19154
|
|
|
19063
|
-
const version = "2.
|
|
19155
|
+
const version = "2.4.0";
|
|
19064
19156
|
|
|
19065
19157
|
const SQL_DATA_WAREHOUSE_DIST_HASH_REGEXP = new RegExp("HASH\\s*\\(\\s*\\w*\\s*\\)\\s*");
|
|
19066
19158
|
const DEFAULT_CONFIG = {
|
|
@@ -19175,7 +19267,7 @@ class Session {
|
|
|
19175
19267
|
this.compileError(new Error(ambiguousActionNameMsg(ref, allResolved)));
|
|
19176
19268
|
}
|
|
19177
19269
|
const resolved = allResolved.length > 0 ? allResolved[0] : undefined;
|
|
19178
|
-
if (resolved && resolved instanceof Table && resolved.proto.
|
|
19270
|
+
if (resolved && resolved instanceof Table && resolved.proto.enumType === dataform.TableType.INLINE) {
|
|
19179
19271
|
return `(${resolved.proto.query})`;
|
|
19180
19272
|
}
|
|
19181
19273
|
if (resolved && resolved instanceof Operation && !resolved.proto.hasOutput) {
|
|
@@ -19337,7 +19429,7 @@ class Session {
|
|
|
19337
19429
|
}
|
|
19338
19430
|
else if (possibleDeps.length === 1) {
|
|
19339
19431
|
const protoDep = possibleDeps[0].proto;
|
|
19340
|
-
if (protoDep instanceof dataform.Table && protoDep.
|
|
19432
|
+
if (protoDep instanceof dataform.Table && protoDep.enumType === dataform.TableType.INLINE) {
|
|
19341
19433
|
protoDep.dependencyTargets.forEach(inlineDep => action.dependencyTargets.push(inlineDep));
|
|
19342
19434
|
}
|
|
19343
19435
|
else {
|
|
@@ -19379,25 +19471,25 @@ class Session {
|
|
|
19379
19471
|
checkTableConfigValidity(tables) {
|
|
19380
19472
|
tables.forEach(table => {
|
|
19381
19473
|
var _a, _b;
|
|
19382
|
-
if (
|
|
19474
|
+
if (table.enumType === dataform.TableType.UNKNOWN_TYPE) {
|
|
19383
19475
|
this.compileError(`Wrong type of table detected. Should only use predefined types: ${joinQuoted(TableType)}`, table.fileName, table.target);
|
|
19384
19476
|
}
|
|
19385
19477
|
if (!!table.materialized) {
|
|
19386
|
-
if (table.
|
|
19478
|
+
if (table.enumType !== dataform.TableType.VIEW ||
|
|
19387
19479
|
(this.config.warehouse !== "snowflake" && this.config.warehouse !== "bigquery")) {
|
|
19388
19480
|
this.compileError(new Error(`The 'materialized' option is only valid for Snowflake and BigQuery views`), table.fileName, table.target);
|
|
19389
19481
|
}
|
|
19390
19482
|
}
|
|
19391
19483
|
if (!!table.snowflake) {
|
|
19392
|
-
if (table.snowflake.secure && table.
|
|
19484
|
+
if (table.snowflake.secure && table.enumType !== dataform.TableType.VIEW) {
|
|
19393
19485
|
this.compileError(new Error(`The 'secure' option is only valid for Snowflake views`), table.fileName, table.target);
|
|
19394
19486
|
}
|
|
19395
|
-
if (table.snowflake.transient && table.
|
|
19487
|
+
if (table.snowflake.transient && table.enumType !== dataform.TableType.TABLE) {
|
|
19396
19488
|
this.compileError(new Error(`The 'transient' option is only valid for Snowflake tables`), table.fileName, table.target);
|
|
19397
19489
|
}
|
|
19398
19490
|
if (((_a = table.snowflake.clusterBy) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
19399
|
-
table.
|
|
19400
|
-
table.
|
|
19491
|
+
table.enumType !== dataform.TableType.TABLE &&
|
|
19492
|
+
table.enumType !== dataform.TableType.INCREMENTAL) {
|
|
19401
19493
|
this.compileError(new Error(`The 'clusterBy' option is only valid for Snowflake tables`), table.fileName, table.target);
|
|
19402
19494
|
}
|
|
19403
19495
|
}
|
|
@@ -19446,12 +19538,12 @@ class Session {
|
|
|
19446
19538
|
if ((table.bigquery.partitionBy || ((_b = table.bigquery.clusterBy) === null || _b === void 0 ? void 0 : _b.length) ||
|
|
19447
19539
|
table.bigquery.partitionExpirationDays ||
|
|
19448
19540
|
table.bigquery.requirePartitionFilter) &&
|
|
19449
|
-
table.
|
|
19541
|
+
table.enumType === dataform.TableType.VIEW) {
|
|
19450
19542
|
this.compileError(`partitionBy/clusterBy/requirePartitionFilter/partitionExpirationDays are not valid for BigQuery views; they are only valid for tables`, table.fileName, table.target);
|
|
19451
19543
|
}
|
|
19452
19544
|
else if (!table.bigquery.partitionBy &&
|
|
19453
19545
|
(table.bigquery.partitionExpirationDays || table.bigquery.requirePartitionFilter) &&
|
|
19454
|
-
table.
|
|
19546
|
+
table.enumType === dataform.TableType.TABLE) {
|
|
19455
19547
|
this.compileError(`requirePartitionFilter/partitionExpirationDays are not valid for non partitioned BigQuery tables`, table.fileName, table.target);
|
|
19456
19548
|
}
|
|
19457
19549
|
else if (table.bigquery.additionalOptions) {
|
|
@@ -19465,10 +19557,10 @@ class Session {
|
|
|
19465
19557
|
}
|
|
19466
19558
|
}
|
|
19467
19559
|
}
|
|
19468
|
-
if (
|
|
19469
|
-
Table.
|
|
19560
|
+
if (table.enumType === dataform.TableType.INLINE) {
|
|
19561
|
+
Table.INLINE_IGNORED_PROPS.forEach(ignoredProp => {
|
|
19470
19562
|
if (objectExistsOrIsNonEmpty(table[ignoredProp])) {
|
|
19471
|
-
this.compileError(`Unused property was detected: "${ignoredProp}". This property is not used for tables with type "
|
|
19563
|
+
this.compileError(`Unused property was detected: "${ignoredProp}". This property is not used for tables with type "inline" and will be ignored`, table.fileName, table.target);
|
|
19472
19564
|
}
|
|
19473
19565
|
});
|
|
19474
19566
|
}
|
package/core.proto
CHANGED
|
@@ -159,6 +159,14 @@ message ColumnDescriptor {
|
|
|
159
159
|
repeated string bigquery_policy_tags = 8;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
enum TableType {
|
|
163
|
+
UNKNOWN_TYPE = 0;
|
|
164
|
+
TABLE = 1;
|
|
165
|
+
INCREMENTAL = 2;
|
|
166
|
+
VIEW = 3;
|
|
167
|
+
INLINE = 4;
|
|
168
|
+
}
|
|
169
|
+
|
|
162
170
|
message Table {
|
|
163
171
|
Target target = 4;
|
|
164
172
|
Target canonical_target = 32;
|
|
@@ -168,10 +176,11 @@ message Table {
|
|
|
168
176
|
|
|
169
177
|
bool disabled = 6;
|
|
170
178
|
|
|
171
|
-
string type = 3;
|
|
179
|
+
string type = 3 [deprecated = true];
|
|
172
180
|
string query = 5;
|
|
173
181
|
bool protected = 9;
|
|
174
182
|
bool materialized = 35;
|
|
183
|
+
TableType enum_type = 36;
|
|
175
184
|
|
|
176
185
|
ActionDescriptor action_descriptor = 24;
|
|
177
186
|
|