|
15 | 15 | */
|
16 | 16 |
|
17 | 17 | locals {
|
18 |
| - prefix = var.prefix == null ? "" : "${var.prefix}-" |
19 |
| - _parsed_data_quality_spec = try(yamldecode(file(var.data_quality_spec_file.path)), null) |
20 |
| - _convert_camel_case = local._parsed_data_quality_spec == null ? null : try(var.data_quality_spec_file.convert_camel_case, false) |
21 |
| - _converted_data_quality_spec = local._parsed_data_quality_spec == null ? null : { |
22 |
| - sampling_percent = try(local._convert_camel_case ? local._parsed_data_quality_spec.samplingPercent : local._parsed_data_quality_spec.sampling_percent, null) |
23 |
| - row_filter = try(local._convert_camel_case ? local._parsed_data_quality_spec.rowFilter : local._parsed_data_quality_spec.row_filter, null) |
| 18 | + prefix = var.prefix == null ? "" : "${var.prefix}-" |
| 19 | + _file_data_quality_spec_raw = var.data_quality_spec_file != null ? yamldecode(file(var.data_quality_spec_file)) : tomap({}) |
| 20 | + _file_data_quality_spec = var.data_quality_spec_file == null ? null : { |
| 21 | + sampling_percent = try(local._file_data_quality_spec_raw.samplingPercent, local._file_data_quality_spec_raw.sampling_percent, null) |
| 22 | + row_filter = try(local._file_data_quality_spec_raw.rowFilter, local._file_data_quality_spec_raw.row_filter, null) |
24 | 23 | rules = [
|
25 |
| - for rule in try(local._parsed_data_quality_spec.rules, []) : { |
| 24 | + for rule in try(local._file_data_quality_spec_raw.rules, []) : { |
26 | 25 | column = try(rule.column, null)
|
27 |
| - ignore_null = try(local._convert_camel_case ? rule.ignoreNull : rule.ignore_null, null) |
| 26 | + ignore_null = try(rule.ignoreNull, rule.ignore_null, null) |
28 | 27 | dimension = rule.dimension
|
29 | 28 | threshold = try(rule.threshold, null)
|
30 |
| - non_null_expectation = try(local._convert_camel_case ? rule.nonNullExpectation : rule.non_null_expectation, null) |
31 |
| - range_expectation = local._convert_camel_case ? ( |
32 |
| - can(rule.rangeExpectation) ? |
33 |
| - { |
34 |
| - min_value = try(rule.rangeExpectation.minValue, null) |
35 |
| - max_value = try(rule.rangeExpectation.maxValue, null) |
36 |
| - strict_min_enabled = try(rule.rangeExpectation.strictMinEnabled, null) |
37 |
| - strict_max_enabled = try(rule.rangeExpectation.strictMaxEnabled, null) |
38 |
| - } : null |
39 |
| - ) : try(rule.range_expectation, null) |
40 |
| - regex_expectation = local._convert_camel_case ? ( |
41 |
| - can(rule.regexExpectation) ? |
42 |
| - { |
43 |
| - regex = try(rule.regexExpectation.regex, null) |
44 |
| - } : null |
45 |
| - ) : try(rule.regex_expectation, null) |
46 |
| - set_expectation = local._convert_camel_case ? ( |
47 |
| - can(rule.setExpectation) ? |
48 |
| - { |
49 |
| - values = try(rule.setExpectation.values, null) |
50 |
| - } : null |
51 |
| - ) : try(rule.set_expectation, null) |
52 |
| - uniqueness_expectation = try(local._convert_camel_case ? rule.uniquenessExpectation : rule.uniqueness_expectation, null) |
53 |
| - statistic_range_expectation = local._convert_camel_case ? ( |
54 |
| - can(rule.statisticRangeExpectation) ? |
55 |
| - { |
56 |
| - statistic = rule.statisticRangeExpectation.statistic |
57 |
| - min_value = try(rule.statisticRangeExpectation.minValue, null) |
58 |
| - max_value = try(rule.statisticRangeExpectation.maxValue, null) |
59 |
| - strict_min_enabled = try(rule.statisticRangeExpectation.strictMinEnabled, null) |
60 |
| - strict_max_enabled = try(rule.statisticRangeExpectation.strictMaxEnabled, null) |
61 |
| - } : null |
62 |
| - ) : try(rule.statistic_range_expectation, null) |
63 |
| - row_condition_expectation = local._convert_camel_case ? ( |
64 |
| - can(rule.rowConditionExpectation) ? |
65 |
| - { |
66 |
| - sql_expression = try(rule.rowConditionExpectation.sqlExpression, null) |
67 |
| - } : null |
68 |
| - ) : try(rule.row_condition_expectation, null) |
69 |
| - table_condition_expectation = local._convert_camel_case ? ( |
70 |
| - can(rule.tableConditionExpectation) ? |
71 |
| - { |
72 |
| - sql_expression = try(rule.tableConditionExpectation.sqlExpression, null) |
73 |
| - } : null |
74 |
| - ) : try(rule.table_condition_expectation, null) |
| 29 | + non_null_expectation = try(rule.nonNullExpectation, rule.non_null_expectation, null) |
| 30 | + range_expectation = can(rule.rangeExpectation) || can(rule.range_expectation) ? { |
| 31 | + min_value = try(rule.rangeExpectation.minValue, rule.range_expectation.min_value, null) |
| 32 | + max_value = try(rule.rangeExpectation.maxValue, rule.range_expectation.max_value, null) |
| 33 | + strict_min_enabled = try(rule.rangeExpectation.strictMinEnabled, rule.range_expectation.strict_min_enabled, null) |
| 34 | + strict_max_enabled = try(rule.rangeExpectation.strictMaxEnabled, rule.range_expectation.strict_max_enabled, null) |
| 35 | + } : null |
| 36 | + regex_expectation = can(rule.regexExpectation) || can(rule.regex_expectation) ? { |
| 37 | + regex = try(rule.regexExpectation.regex, rule.regex_expectation.regex, null) |
| 38 | + } : null |
| 39 | + set_expectation = can(rule.setExpectation) || can(rule.set_expectation) ? { |
| 40 | + values = try(rule.setExpectation.values, rule.set_expectation.values, null) |
| 41 | + } : null |
| 42 | + uniqueness_expectation = try(rule.uniquenessExpectation, rule.uniqueness_expectation, null) |
| 43 | + statistic_range_expectation = can(rule.statisticRangeExpectation) || can(rule.statistic_range_expectation) ? { |
| 44 | + statistic = try(rule.statisticRangeExpectation.statistic, rule.statistic_range_expectation.statistic) |
| 45 | + min_value = try(rule.statisticRangeExpectation.minValue, rule.statistic_range_expectation.min_value, null) |
| 46 | + max_value = try(rule.statisticRangeExpectation.maxValue, rule.statistic_range_expectation.max_value, null) |
| 47 | + strict_min_enabled = try(rule.statisticRangeExpectation.strictMinEnabled, rule.statistic_range_expectation.strict_min_enabled, null) |
| 48 | + strict_max_enabled = try(rule.statisticRangeExpectation.strictMaxEnabled, rule.statistic_range_expectation.strict_max_enabled, null) |
| 49 | + } : null |
| 50 | + row_condition_expectation = can(rule.rowConditionExpectation) || can(rule.row_condition_expectation) ? { |
| 51 | + sql_expression = try(rule.rowConditionExpectation.sqlExpression, rule.row_condition_expectation.sql_expression, null) |
| 52 | + } : null |
| 53 | + table_condition_expectation = can(rule.tableConditionExpectation) || can(rule.table_condition_expectation) ? { |
| 54 | + sql_expression = try(rule.tableConditionExpectation.sqlExpression, rule.table_condition_expectation.sql_expression, null) |
| 55 | + } : null |
75 | 56 | }
|
76 | 57 | ]
|
77 | 58 | }
|
78 | 59 | data_quality_spec = (
|
79 | 60 | var.data_quality_spec != null || var.data_quality_spec_file != null ?
|
80 |
| - merge(var.data_quality_spec, local._converted_data_quality_spec) : |
| 61 | + merge(var.data_quality_spec, local._file_data_quality_spec) : |
81 | 62 | null
|
82 | 63 | )
|
| 64 | + # data_quality_spec = ( |
| 65 | + # var.data_quality_spec |
| 66 | + # ) |
83 | 67 | }
|
84 | 68 |
|
85 | 69 | resource "google_dataplex_datascan" "datascan" {
|
|
0 commit comments