Skip to content

Commit

Permalink
fix: Removing line breaks (#1052)
Browse files Browse the repository at this point in the history
* removing line breaks

* updating versions

* adding skip dependent tables to test to shorten length

* adding more whitespace trimming

* more whitespace trimming
  • Loading branch information
k-rheinheimer authored Aug 29, 2024
1 parent 4d9fd6d commit c2754f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ SPLIT_PART(arn, ':', 3) AS service,
FROM {{ table_name | string }}
{% endmacro %}

{% macro bigquery__aws_asset_resources(table_name, ARN_EXIST, ACCOUNT_ID_EXIST, REQUEST_ACCOUNT_ID_EXIST, REGION_EXIST, TAGS_EXIST) -%}
SELECT
_cq_id, _cq_source_name, _cq_sync_time,{% if ACCOUNT_ID_EXIST %} account_id {% else %} SPLIT(arn, ':')[5] {% endif %} AS account_id, {% if REQUEST_ACCOUNT_ID_EXIST %} request_account_id {% else %} SPLIT(arn, ':')[5] {% endif %} AS request_account_id, CASE WHEN SPLIT(SPLIT(arn, ':')[6], '/')[2] = '' AND SPLIT(arn, ':')[7] = '' THEN NULL ELSE SPLIT(SPLIT(arn, ':')[6], '/')[1] END AS TYPE, arn, {% if REGION_EXIST %} region {% else %} 'unavailable' {% endif %} AS region, {% if TAGS_EXIST %} TO_JSON_STRING(tags) {% else %} TO_JSON_STRING(STRUCT()) {% endif %} AS tags, SPLIT(arn, ':')[2] AS PARTITIONS, SPLIT(arn, ':')[3] AS service, '{{ table_name | string }}' AS _cq_table
{%- macro bigquery__aws_asset_resources(table_name, ARN_EXIST, ACCOUNT_ID_EXIST, REQUEST_ACCOUNT_ID_EXIST, REGION_EXIST, TAGS_EXIST) -%}
SELECT
_cq_id, _cq_source_name, _cq_sync_time,{% if ACCOUNT_ID_EXIST %} account_id {% else %} SPLIT(arn, ':')[5] {% endif %} AS account_id, {% if REQUEST_ACCOUNT_ID_EXIST %} request_account_id {% else %} SPLIT(arn, ':')[5] {% endif %} AS request_account_id, CASE WHEN SPLIT(SPLIT(arn, ':')[6], '/')[2] = '' AND SPLIT(arn, ':')[7] = '' THEN NULL ELSE SPLIT(SPLIT(arn, ':')[6], '/')[1] END AS TYPE, arn, {% if REGION_EXIST %} region {% else %} 'unavailable' {% endif %} AS region, {% if TAGS_EXIST %} TO_JSON_STRING(tags) {% else %} TO_JSON_STRING(STRUCT()) {% endif %} AS tags, SPLIT(arn, ':')[2] AS PARTITIONS, SPLIT(arn, ':')[3] AS service, '{{ table_name | string }}' AS _cq_table
FROM {{ full_table_name(table_name | string) }}
{% endmacro %}
{%- endmacro -%}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
{{ aws_tables_dyn() }}
{% endset %}

-- Generate dynamic SQL statements
{% for row in run_query(aws_tables) -%}
{% if row.table_name is not none and row.table_name != '' -%}
{%- for row in run_query(aws_tables) -%}
{%- if row.table_name is not none and row.table_name != '' -%}
{{ aws_asset_resources(row.table_name, row.arn_exist, row.account_id_exist, row.request_account_id_exist, row.region_exist, row.tags_exist) }}
{% if not loop.last -%} UNION ALL {% endif -%}
{%- endif %}
{%- endfor %}
{%- if not loop.last -%} UNION ALL {% endif -%}
{%- endif -%}
{%- endfor -%}
5 changes: 3 additions & 2 deletions transformations/aws/asset-inventory-free/tests/bigquery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ spec:
name: aws
path: cloudquery/aws
registry: cloudquery
version: "v27.15.0" # latest version of source aws plugin
version: "v27.17.0" # latest version of source aws plugin
destinations: ["bigquery"]
tables: ["*"]
skip_dependent_tables: true
---
kind: destination
spec:
name: bigquery
path: cloudquery/bigquery
registry: cloudquery
version: "v3.3.9"
version: "v4.1.7"
write_mode: "append"
spec:
project_id: cq-integration-tests
Expand Down

0 comments on commit c2754f7

Please sign in to comment.