activerecord-dbt 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +213 -72
- data/lib/active_record/dbt/column/{test.rb → data_test.rb} +16 -16
- data/lib/active_record/dbt/column/{testable/accepted_values_testable.rb → data_testable/accepted_values_data_testable.rb} +2 -2
- data/lib/active_record/dbt/column/{testable/not_null_testable.rb → data_testable/not_null_data_testable.rb} +9 -3
- data/lib/active_record/dbt/column/{testable/relationships_testable.rb → data_testable/relationships_data_testable.rb} +3 -3
- data/lib/active_record/dbt/column/{testable/unique_testable.rb → data_testable/unique_data_testable.rb} +2 -2
- data/lib/active_record/dbt/column/{column.rb → yml.rb} +9 -20
- data/lib/active_record/dbt/config.rb +2 -30
- data/lib/active_record/dbt/configuration/i18n_configuration.rb +14 -0
- data/lib/active_record/dbt/configuration/source.rb +40 -0
- data/lib/active_record/dbt/data_type/mapper.rb +81 -14
- data/lib/active_record/dbt/dbt_package/dbt_utils/table/{testable/unique_combination_of_columns_testable.rb → data_testable/unique_combination_of_columns_data_testable.rb} +2 -2
- data/lib/active_record/dbt/dbt_package/dbterd/column/{testable → data_testable}/relationships_meta_relationship_type.rb +4 -5
- data/lib/active_record/dbt/factory/columns/yml_factory.rb +33 -0
- data/lib/active_record/dbt/factory/model/staging/yml_factory.rb +24 -0
- data/lib/active_record/dbt/factory/source/yml_factory.rb +17 -0
- data/lib/active_record/dbt/factory/table/yml_factory.rb +18 -0
- data/lib/active_record/dbt/factory/tables/yml_factory.rb +17 -0
- data/lib/active_record/dbt/i18n_wrapper/translate.rb +34 -0
- data/lib/active_record/dbt/model/staging/base.rb +1 -1
- data/lib/active_record/dbt/model/staging/yml.rb +10 -6
- data/lib/active_record/dbt/seed/enum/base.rb +48 -0
- data/lib/active_record/dbt/seed/enum/csv.rb +85 -0
- data/lib/active_record/dbt/seed/enum/yml.rb +128 -0
- data/lib/active_record/dbt/source/yml.rb +13 -5
- data/lib/active_record/dbt/table/{test.rb → data_test.rb} +3 -3
- data/lib/active_record/dbt/table/yml.rb +7 -10
- data/lib/active_record/dbt/version.rb +1 -1
- data/lib/generators/active_record/dbt/config/templates/source_config.yml.tt +5 -2
- data/lib/generators/active_record/dbt/enum/USAGE +9 -0
- data/lib/generators/active_record/dbt/enum/enum_generator.rb +31 -0
- data/lib/generators/active_record/dbt/initializer/templates/dbt.rb +9 -7
- data/lib/generators/active_record/dbt/source/USAGE +1 -1
- data/lib/generators/active_record/dbt/source/source_generator.rb +3 -4
- data/lib/generators/active_record/dbt/staging_model/USAGE +2 -2
- data/lib/generators/active_record/dbt/staging_model/staging_model_generator.rb +2 -2
- metadata +24 -21
- data/lib/active_record/dbt/data_type/dwh_platform/apache_spark.rb +0 -27
- data/lib/active_record/dbt/data_type/dwh_platform/bigquery.rb +0 -26
- data/lib/active_record/dbt/data_type/dwh_platform/postgre_sql.rb +0 -27
- data/lib/active_record/dbt/data_type/dwh_platform/redshift.rb +0 -27
- data/lib/active_record/dbt/data_type/dwh_platform/snowflake.rb +0 -27
- data/lib/active_record/dbt/factory/columns_factory.rb +0 -31
- data/lib/active_record/dbt/factory/model/staging_factory.rb +0 -22
- data/lib/active_record/dbt/factory/source_factory.rb +0 -16
- data/lib/active_record/dbt/factory/table_factory.rb +0 -16
- data/lib/active_record/dbt/factory/tables_factory.rb +0 -15
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module Dbt
|
5
|
+
module Seed
|
6
|
+
module Enum
|
7
|
+
module Base
|
8
|
+
attr_reader :table_name, :enum_column_name
|
9
|
+
|
10
|
+
delegate :source_name, :export_directory_path, to: :@config
|
11
|
+
delegate :singularize, to: :table_name, prefix: true
|
12
|
+
|
13
|
+
def initialize(table_name, enum_column_name)
|
14
|
+
@table_name = table_name
|
15
|
+
@enum_column_name = enum_column_name
|
16
|
+
@config = ActiveRecord::Dbt::Config.instance
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def basename
|
22
|
+
"#{export_directory_path}/seeds/#{source_name}/#{seed_name}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def seed_name
|
26
|
+
"seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def locales
|
30
|
+
@locales ||= I18n.available_locales
|
31
|
+
end
|
32
|
+
|
33
|
+
def application_record_klass
|
34
|
+
@application_record_klass ||= table_name_singularize.classify.constantize
|
35
|
+
rescue NameError => _e
|
36
|
+
raise DoesNotExistTableError, "#{table_name} table does not exist."
|
37
|
+
end
|
38
|
+
|
39
|
+
def enum_pluralized
|
40
|
+
enum_column_name.pluralize
|
41
|
+
end
|
42
|
+
|
43
|
+
class DoesNotExistTableError < StandardError; end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'csv'
|
4
|
+
|
5
|
+
module ActiveRecord
|
6
|
+
module Dbt
|
7
|
+
module Seed
|
8
|
+
module Enum
|
9
|
+
class Csv
|
10
|
+
include ActiveRecord::Dbt::Seed::Enum::Base
|
11
|
+
|
12
|
+
delegate :singularize, to: :table_name, prefix: true
|
13
|
+
|
14
|
+
def export_path
|
15
|
+
"#{basename}.csv"
|
16
|
+
end
|
17
|
+
|
18
|
+
def dump
|
19
|
+
CSV.generate(headers: true) do |csv|
|
20
|
+
rows.each { |row| csv << row }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def rows
|
27
|
+
[
|
28
|
+
header,
|
29
|
+
*enum_rows
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
def header
|
34
|
+
[
|
35
|
+
"#{enum_column_name}_before_type_of_cast",
|
36
|
+
"#{enum_column_name}_key",
|
37
|
+
*locale_header
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def locale_header
|
42
|
+
locales.map { |locale| "#{enum_column_name}_#{locale}" }
|
43
|
+
end
|
44
|
+
|
45
|
+
def enum_rows
|
46
|
+
enums.map do |enum_key, enum_before_type_of_cast|
|
47
|
+
[
|
48
|
+
enum_before_type_of_cast,
|
49
|
+
enum_key,
|
50
|
+
*enum_values(enum_key)
|
51
|
+
]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def enums
|
56
|
+
application_record_klass.defined_enums.fetch(enum_column_name)
|
57
|
+
rescue KeyError => _e
|
58
|
+
raise NotEnumColumnError, "#{table_name}.#{enum_column_name} column is not an enum." if enum_column?
|
59
|
+
|
60
|
+
raise DoesNotExistColumnError, "The #{enum_column_name} column in the #{table_name} table does not exist."
|
61
|
+
end
|
62
|
+
|
63
|
+
def enum_column?
|
64
|
+
application_record_klass.column_names.include?(enum_column_name)
|
65
|
+
end
|
66
|
+
|
67
|
+
def enum_values(enum_key)
|
68
|
+
locales.map { |locale| translated_enum_value(enum_key, locale) }
|
69
|
+
end
|
70
|
+
|
71
|
+
def translated_enum_value(enum_key, locale)
|
72
|
+
I18n.t(
|
73
|
+
"activerecord.enum.#{table_name_singularize}.#{enum_column_name}.#{enum_key}",
|
74
|
+
locale: locale,
|
75
|
+
default: nil
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
class DoesNotExistColumnError < StandardError; end
|
80
|
+
class NotEnumColumnError < StandardError; end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module Dbt
|
5
|
+
module Seed
|
6
|
+
module Enum
|
7
|
+
class Yml
|
8
|
+
include ActiveRecord::Dbt::Column::DataTestable::UniqueDataTestable
|
9
|
+
include ActiveRecord::Dbt::Column::DataTestable::NotNullDataTestable
|
10
|
+
include ActiveRecord::Dbt::DataType::Mapper
|
11
|
+
include ActiveRecord::Dbt::I18nWrapper::Translate
|
12
|
+
include ActiveRecord::Dbt::Seed::Enum::Base
|
13
|
+
|
14
|
+
delegate :source_config, to: :@config
|
15
|
+
|
16
|
+
alias column_name enum_column_name
|
17
|
+
|
18
|
+
def export_path
|
19
|
+
"#{basename}.yml"
|
20
|
+
end
|
21
|
+
|
22
|
+
def dump
|
23
|
+
YAML.dump(properties.deep_stringify_keys)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def properties
|
29
|
+
{
|
30
|
+
'version' => 2,
|
31
|
+
'seeds' => [
|
32
|
+
'name' => seed_name,
|
33
|
+
'description' => seed_description,
|
34
|
+
'config' => {
|
35
|
+
'column_types' => column_types
|
36
|
+
}
|
37
|
+
],
|
38
|
+
'columns' => columns
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def seed_description
|
43
|
+
default_seed_description ||
|
44
|
+
"#{source_name} #{translated_table_name} #{translated_attribute_name} enum".strip
|
45
|
+
end
|
46
|
+
|
47
|
+
def default_seed_description
|
48
|
+
source_config.dig(:defaults, :seed_descriptions, :enum, :description)
|
49
|
+
&.gsub(/{{\s*source_name\s*}}/, source_name)
|
50
|
+
&.gsub(/{{\s*translated_table_name\s*}}/, translated_table_name)
|
51
|
+
&.gsub(/{{\s*translated_attribute_name\s*}}/, translated_attribute_name)
|
52
|
+
end
|
53
|
+
|
54
|
+
def column_types
|
55
|
+
{
|
56
|
+
"#{enum_column_name}_before_type_of_cast" => data_type(before_type_of_cast_type),
|
57
|
+
"#{enum_column_name}_key" => data_type(:string),
|
58
|
+
**enum_column_types
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
def before_type_of_cast_type
|
63
|
+
application_record_klass.columns_hash[enum_column_name].type
|
64
|
+
end
|
65
|
+
|
66
|
+
def enum_column_types
|
67
|
+
locales.each_with_object({}) do |locale, hash|
|
68
|
+
hash["#{enum_column_name}_#{locale}"] = data_type(:string)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def columns
|
73
|
+
[
|
74
|
+
before_type_of_cast_column,
|
75
|
+
enum_key_column,
|
76
|
+
*enum_columns
|
77
|
+
].compact
|
78
|
+
end
|
79
|
+
|
80
|
+
def before_type_of_cast_column
|
81
|
+
{
|
82
|
+
'name' => "#{enum_column_name}_before_type_of_cast",
|
83
|
+
'description' => translated_attribute_name,
|
84
|
+
'data_tests' => data_tests
|
85
|
+
}.compact
|
86
|
+
end
|
87
|
+
|
88
|
+
def enum_key_column
|
89
|
+
{
|
90
|
+
'name' => "#{enum_column_name}_key",
|
91
|
+
'description' => "#{translated_attribute_name}(key)",
|
92
|
+
'data_tests' => data_tests
|
93
|
+
}.compact
|
94
|
+
end
|
95
|
+
|
96
|
+
def enum_columns
|
97
|
+
locales.each_with_object([]) do |locale, array|
|
98
|
+
array.push(
|
99
|
+
{
|
100
|
+
'name' => "#{enum_column_name}_#{locale}",
|
101
|
+
'description' => "#{translated_attribute_name}(#{locale})",
|
102
|
+
'data_tests' => data_tests
|
103
|
+
}.compact
|
104
|
+
)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def data_tests
|
109
|
+
[
|
110
|
+
unique_test,
|
111
|
+
not_null_test
|
112
|
+
].compact.presence
|
113
|
+
end
|
114
|
+
|
115
|
+
# MEMO: I think all enums are unique.
|
116
|
+
def unique?
|
117
|
+
true
|
118
|
+
end
|
119
|
+
|
120
|
+
# MEMO: I think all enums are null.
|
121
|
+
def null?
|
122
|
+
false
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -6,14 +6,24 @@ module ActiveRecord
|
|
6
6
|
class Yml
|
7
7
|
attr_reader :tables
|
8
8
|
|
9
|
-
delegate :source_config, to: :@config
|
9
|
+
delegate :source_config, :export_directory_path, :source_name, to: :@config
|
10
10
|
|
11
11
|
def initialize(tables)
|
12
12
|
@tables = tables
|
13
13
|
@config = ActiveRecord::Dbt::Config.instance
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def export_path
|
17
|
+
"#{export_directory_path}/models/sources/#{source_name}/src_#{source_name}.yml"
|
18
|
+
end
|
19
|
+
|
20
|
+
def dump
|
21
|
+
YAML.dump(properties.deep_stringify_keys)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def properties
|
17
27
|
{
|
18
28
|
'version' => 2,
|
19
29
|
'sources' => [
|
@@ -22,14 +32,12 @@ module ActiveRecord
|
|
22
32
|
}
|
23
33
|
end
|
24
34
|
|
25
|
-
private
|
26
|
-
|
27
35
|
def source_properties
|
28
36
|
source_config[:sources]
|
29
37
|
end
|
30
38
|
|
31
39
|
def tables_properties
|
32
|
-
tables.map(&:
|
40
|
+
tables.map(&:properties)
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
@@ -3,12 +3,12 @@
|
|
3
3
|
module ActiveRecord
|
4
4
|
module Dbt
|
5
5
|
module Table
|
6
|
-
class
|
7
|
-
include ActiveRecord::Dbt::DbtPackage::DbtUtils::Table::
|
6
|
+
class DataTest
|
7
|
+
include ActiveRecord::Dbt::DbtPackage::DbtUtils::Table::DataTestable::UniqueCombinationOfColumnsDataTestable
|
8
8
|
|
9
9
|
include ActiveRecord::Dbt::Table::Base
|
10
10
|
|
11
|
-
def
|
11
|
+
def properties
|
12
12
|
[
|
13
13
|
*unique_combination_of_columns_test
|
14
14
|
].compact.presence
|
@@ -4,22 +4,23 @@ module ActiveRecord
|
|
4
4
|
module Dbt
|
5
5
|
module Table
|
6
6
|
class Yml
|
7
|
+
include ActiveRecord::Dbt::I18nWrapper::Translate
|
7
8
|
include ActiveRecord::Dbt::Table::Base
|
8
9
|
|
9
|
-
attr_reader :
|
10
|
+
attr_reader :table_data_test, :columns
|
10
11
|
|
11
12
|
delegate :source_config, to: :@config
|
12
13
|
|
13
|
-
def initialize(table_name,
|
14
|
+
def initialize(table_name, table_data_test, columns)
|
14
15
|
super(table_name)
|
15
|
-
@
|
16
|
+
@table_data_test = table_data_test
|
16
17
|
@columns = columns
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
+
def properties
|
20
21
|
{
|
21
22
|
**table_properties,
|
22
|
-
'columns' => columns.map(&:
|
23
|
+
'columns' => columns.map(&:properties)
|
23
24
|
}.compact
|
24
25
|
end
|
25
26
|
|
@@ -30,7 +31,7 @@ module ActiveRecord
|
|
30
31
|
'name' => table_name,
|
31
32
|
'description' => description,
|
32
33
|
**table_overrides.except(:columns),
|
33
|
-
'
|
34
|
+
'data_tests' => table_data_test.properties
|
34
35
|
}
|
35
36
|
end
|
36
37
|
|
@@ -51,10 +52,6 @@ module ActiveRecord
|
|
51
52
|
"Write a logical_name of the '#{table_name}' table."
|
52
53
|
end
|
53
54
|
|
54
|
-
def translated_table_name
|
55
|
-
I18n.t("activerecord.models.#{table_name.singularize}", default: nil)
|
56
|
-
end
|
57
|
-
|
58
55
|
def default_logical_name
|
59
56
|
source_config.dig(:defaults, :table_descriptions, :logical_name)
|
60
57
|
&.gsub(/{{\s*table_name\s*}}/, table_name)
|
@@ -11,7 +11,7 @@ table_overrides:
|
|
11
11
|
meta: {<dictionary>}
|
12
12
|
identifier: <table_name>
|
13
13
|
loaded_at_field: <column_name>
|
14
|
-
|
14
|
+
data_tests:
|
15
15
|
- <test>
|
16
16
|
tags: [<string>]
|
17
17
|
freshness:
|
@@ -31,7 +31,7 @@ table_overrides:
|
|
31
31
|
<column_name>:
|
32
32
|
meta: {<dictionary>}
|
33
33
|
quote: true | false
|
34
|
-
|
34
|
+
data_tests:
|
35
35
|
- <test>
|
36
36
|
tags: [<string>]
|
37
37
|
|
@@ -40,6 +40,9 @@ defaults:
|
|
40
40
|
logical_name: Write a logical_name of the '{{ table_name }}' table.
|
41
41
|
columns:
|
42
42
|
description: Write a description of the '{{ table_name }}.{{ column_name }}' column.
|
43
|
+
seed_descriptions:
|
44
|
+
enum:
|
45
|
+
description: "{{ source_name }} {{ translated_table_name }} {{ translated_attribute_name }} enum"
|
43
46
|
|
44
47
|
table_descriptions:
|
45
48
|
ar_internal_metadata:
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Description:
|
2
|
+
Generate seed enum files for dbt from the specified TABLE_NAME and ENUM_COLUMN_NAME.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
bin/rails generate active_record:dbt:enum TABLE_NAME ENUM_COLUMN_NAME
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
#{export_directory_path}/seeds/#{source_name}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.csv
|
9
|
+
#{export_directory_path}/seeds/#{source_name}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.yml
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module Dbt
|
5
|
+
module Generators
|
6
|
+
class EnumGenerator < Rails::Generators::NamedBase
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
|
9
|
+
argument :enum_column_name, type: :string, default: nil
|
10
|
+
|
11
|
+
def create_enum_seed_csv_file
|
12
|
+
create_file csv.export_path, csv.dump
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_enum_seed_yml_file
|
16
|
+
create_file yml.export_path, yml.dump
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def csv
|
22
|
+
@csv ||= ActiveRecord::Dbt::Seed::Enum::Csv.new(name, enum_column_name)
|
23
|
+
end
|
24
|
+
|
25
|
+
def yml
|
26
|
+
@yml ||= ActiveRecord::Dbt::Seed::Enum::Yml.new(name, enum_column_name)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
if Rails.env.development?
|
4
|
+
require 'active_record/dbt'
|
4
5
|
|
5
|
-
ActiveRecord::Dbt.configure do |c|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
ActiveRecord::Dbt.configure do |c|
|
7
|
+
c.config_directory_path = 'lib/dbt'
|
8
|
+
c.export_directory_path = 'doc/dbt'
|
9
|
+
c.dwh_platform = 'bigquery'
|
10
|
+
c.data_sync_delayed = false
|
11
|
+
c.used_dbt_package_names = []
|
12
|
+
end
|
11
13
|
end
|
@@ -7,14 +7,13 @@ module ActiveRecord
|
|
7
7
|
source_root File.expand_path('templates', __dir__)
|
8
8
|
|
9
9
|
def create_source_yml_file
|
10
|
-
create_file
|
11
|
-
ActiveRecord::Dbt::Factory::SourceFactory.build
|
10
|
+
create_file yml.export_path, yml.dump
|
12
11
|
end
|
13
12
|
|
14
13
|
private
|
15
14
|
|
16
|
-
def
|
17
|
-
@
|
15
|
+
def yml
|
16
|
+
@yml ||= ActiveRecord::Dbt::Factory::Source::YmlFactory.build
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -5,5 +5,5 @@ Example:
|
|
5
5
|
bin/rails generate active_record:dbt:staging_model TABLE_NAME
|
6
6
|
|
7
7
|
This will create:
|
8
|
-
#{export_directory_path}/stg_#{source_name}__#{table_name}.sql
|
9
|
-
#{export_directory_path}/stg_#{source_name}__#{table_name}.yml
|
8
|
+
#{export_directory_path}/models/staging/#{source_name}/stg_#{source_name}__#{table_name}.sql
|
9
|
+
#{export_directory_path}/models/staging/#{source_name}/stg_#{source_name}__#{table_name}.yml
|
@@ -11,7 +11,7 @@ module ActiveRecord
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def create_staging_model_yml_file
|
14
|
-
create_file yml.export_path, yml.
|
14
|
+
create_file yml.export_path, yml.dump
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -21,7 +21,7 @@ module ActiveRecord
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def yml
|
24
|
-
@yml ||= ActiveRecord::Dbt::Factory::Model::
|
24
|
+
@yml ||= ActiveRecord::Dbt::Factory::Model::Staging::YmlFactory.build(name)
|
25
25
|
end
|
26
26
|
|
27
27
|
def source_paths
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-dbt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yamotech
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -64,44 +64,47 @@ files:
|
|
64
64
|
- README.md
|
65
65
|
- Rakefile
|
66
66
|
- lib/active_record/dbt.rb
|
67
|
-
- lib/active_record/dbt/column/
|
68
|
-
- lib/active_record/dbt/column/
|
69
|
-
- lib/active_record/dbt/column/
|
70
|
-
- lib/active_record/dbt/column/
|
71
|
-
- lib/active_record/dbt/column/
|
72
|
-
- lib/active_record/dbt/column/
|
67
|
+
- lib/active_record/dbt/column/data_test.rb
|
68
|
+
- lib/active_record/dbt/column/data_testable/accepted_values_data_testable.rb
|
69
|
+
- lib/active_record/dbt/column/data_testable/not_null_data_testable.rb
|
70
|
+
- lib/active_record/dbt/column/data_testable/relationships_data_testable.rb
|
71
|
+
- lib/active_record/dbt/column/data_testable/unique_data_testable.rb
|
72
|
+
- lib/active_record/dbt/column/yml.rb
|
73
73
|
- lib/active_record/dbt/config.rb
|
74
74
|
- lib/active_record/dbt/configuration/data_sync.rb
|
75
75
|
- lib/active_record/dbt/configuration/dwh_platform.rb
|
76
|
+
- lib/active_record/dbt/configuration/i18n_configuration.rb
|
76
77
|
- lib/active_record/dbt/configuration/logger.rb
|
77
78
|
- lib/active_record/dbt/configuration/parser.rb
|
79
|
+
- lib/active_record/dbt/configuration/source.rb
|
78
80
|
- lib/active_record/dbt/configuration/used_dbt_package.rb
|
79
|
-
- lib/active_record/dbt/data_type/dwh_platform/apache_spark.rb
|
80
|
-
- lib/active_record/dbt/data_type/dwh_platform/bigquery.rb
|
81
|
-
- lib/active_record/dbt/data_type/dwh_platform/postgre_sql.rb
|
82
|
-
- lib/active_record/dbt/data_type/dwh_platform/redshift.rb
|
83
|
-
- lib/active_record/dbt/data_type/dwh_platform/snowflake.rb
|
84
81
|
- lib/active_record/dbt/data_type/mapper.rb
|
85
|
-
- lib/active_record/dbt/dbt_package/dbt_utils/table/
|
86
|
-
- lib/active_record/dbt/dbt_package/dbterd/column/
|
87
|
-
- lib/active_record/dbt/factory/
|
88
|
-
- lib/active_record/dbt/factory/model/
|
89
|
-
- lib/active_record/dbt/factory/
|
90
|
-
- lib/active_record/dbt/factory/
|
91
|
-
- lib/active_record/dbt/factory/
|
82
|
+
- lib/active_record/dbt/dbt_package/dbt_utils/table/data_testable/unique_combination_of_columns_data_testable.rb
|
83
|
+
- lib/active_record/dbt/dbt_package/dbterd/column/data_testable/relationships_meta_relationship_type.rb
|
84
|
+
- lib/active_record/dbt/factory/columns/yml_factory.rb
|
85
|
+
- lib/active_record/dbt/factory/model/staging/yml_factory.rb
|
86
|
+
- lib/active_record/dbt/factory/source/yml_factory.rb
|
87
|
+
- lib/active_record/dbt/factory/table/yml_factory.rb
|
88
|
+
- lib/active_record/dbt/factory/tables/yml_factory.rb
|
89
|
+
- lib/active_record/dbt/i18n_wrapper/translate.rb
|
92
90
|
- lib/active_record/dbt/model/staging/base.rb
|
93
91
|
- lib/active_record/dbt/model/staging/sql.rb
|
94
92
|
- lib/active_record/dbt/model/staging/yml.rb
|
95
93
|
- lib/active_record/dbt/railtie.rb
|
96
94
|
- lib/active_record/dbt/required_methods.rb
|
95
|
+
- lib/active_record/dbt/seed/enum/base.rb
|
96
|
+
- lib/active_record/dbt/seed/enum/csv.rb
|
97
|
+
- lib/active_record/dbt/seed/enum/yml.rb
|
97
98
|
- lib/active_record/dbt/source/yml.rb
|
98
99
|
- lib/active_record/dbt/table/base.rb
|
99
|
-
- lib/active_record/dbt/table/
|
100
|
+
- lib/active_record/dbt/table/data_test.rb
|
100
101
|
- lib/active_record/dbt/table/yml.rb
|
101
102
|
- lib/active_record/dbt/version.rb
|
102
103
|
- lib/generators/active_record/dbt/config/USAGE
|
103
104
|
- lib/generators/active_record/dbt/config/config_generator.rb
|
104
105
|
- lib/generators/active_record/dbt/config/templates/source_config.yml.tt
|
106
|
+
- lib/generators/active_record/dbt/enum/USAGE
|
107
|
+
- lib/generators/active_record/dbt/enum/enum_generator.rb
|
105
108
|
- lib/generators/active_record/dbt/initializer/USAGE
|
106
109
|
- lib/generators/active_record/dbt/initializer/initializer_generator.rb
|
107
110
|
- lib/generators/active_record/dbt/initializer/templates/dbt.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module DataType
|
6
|
-
module DwhPlatform
|
7
|
-
module ApacheSpark
|
8
|
-
# TODO: I have not tried it. I don't know if this is the correct data_type.
|
9
|
-
# [Data Types - Spark 3.5.1 Documentation](https://spark.apache.org/docs/latest/sql-ref-datatypes.html)
|
10
|
-
RUBY_TO_SPARK_TYPES = {
|
11
|
-
binary: 'binary',
|
12
|
-
boolean: 'boolean',
|
13
|
-
date: 'date',
|
14
|
-
datetime: 'timestamp',
|
15
|
-
decimal: 'decimal',
|
16
|
-
float: 'float',
|
17
|
-
integer: 'integer',
|
18
|
-
json: 'string',
|
19
|
-
string: 'string',
|
20
|
-
text: 'string',
|
21
|
-
time: 'string'
|
22
|
-
}.freeze
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module DataType
|
6
|
-
module DwhPlatform
|
7
|
-
module Bigquery
|
8
|
-
# [Data types | BigQuery | Google Cloud](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#data_type_list)
|
9
|
-
RUBY_TO_BIGQUERY_TYPES = {
|
10
|
-
binary: 'bytes',
|
11
|
-
boolean: 'bool',
|
12
|
-
date: 'date',
|
13
|
-
datetime: 'datetime',
|
14
|
-
decimal: 'int64',
|
15
|
-
float: 'float64',
|
16
|
-
integer: 'int64',
|
17
|
-
json: 'json',
|
18
|
-
string: 'string',
|
19
|
-
text: 'string',
|
20
|
-
time: 'time'
|
21
|
-
}.freeze
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|