activerecord-dbt 0.2.0 → 0.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.
- 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
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module DataType
|
6
|
-
module DwhPlatform
|
7
|
-
module PostgreSql
|
8
|
-
# TODO: I have not tried it. I don't know if this is the correct data_type.
|
9
|
-
# [PostgreSQL: Documentation: 16: Chapter 8. Data Types](https://www.postgresql.org/docs/current/datatype.html)
|
10
|
-
RUBY_TO_POSTGRES_TYPES = {
|
11
|
-
binary: 'bytea',
|
12
|
-
boolean: 'boolean',
|
13
|
-
date: 'date',
|
14
|
-
datetime: 'timestamp',
|
15
|
-
decimal: 'bigint',
|
16
|
-
float: 'double precision',
|
17
|
-
integer: 'bigint',
|
18
|
-
json: 'json',
|
19
|
-
string: 'text',
|
20
|
-
text: 'text',
|
21
|
-
time: 'time'
|
22
|
-
}.freeze
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module DataType
|
6
|
-
module DwhPlatform
|
7
|
-
module Redshift
|
8
|
-
# TODO: I have not tried it. I don't know if this is the correct data_type.
|
9
|
-
# [Data types - Amazon Redshift](https://docs.aws.amazon.com/redshift/latest/dg/c_Supported_data_types.html)
|
10
|
-
RUBY_TO_REDSHIFT_TYPES = {
|
11
|
-
binary: 'varbyte',
|
12
|
-
boolean: 'bool',
|
13
|
-
date: 'date',
|
14
|
-
datetime: 'timestamp',
|
15
|
-
decimal: 'decimal',
|
16
|
-
float: 'double precision',
|
17
|
-
integer: 'integer',
|
18
|
-
json: 'super',
|
19
|
-
string: 'varchar',
|
20
|
-
text: 'varchar',
|
21
|
-
time: 'time'
|
22
|
-
}.freeze
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module DataType
|
6
|
-
module DwhPlatform
|
7
|
-
module Snowflake
|
8
|
-
# TODO: I have not tried it. I don't know if this is the correct data_type.
|
9
|
-
# [Summary of data types | Snowflake Documentation](https://docs.snowflake.com/en/sql-reference/intro-summary-data-types)
|
10
|
-
RUBY_TO_SNOWFLAKE_TYPES = {
|
11
|
-
binary: 'binary',
|
12
|
-
boolean: 'boolean',
|
13
|
-
date: 'date',
|
14
|
-
datetime: 'datetime',
|
15
|
-
decimal: 'decimal',
|
16
|
-
float: 'float',
|
17
|
-
integer: 'integer',
|
18
|
-
json: 'variant',
|
19
|
-
string: 'varchar',
|
20
|
-
text: 'varchar',
|
21
|
-
time: 'time'
|
22
|
-
}.freeze
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module Factory
|
6
|
-
module ColumnsFactory
|
7
|
-
def self.build(
|
8
|
-
table_name,
|
9
|
-
primary_keys: ActiveRecord::Base.connection.primary_keys(table_name),
|
10
|
-
foreign_keys: ActiveRecord::Base.connection.foreign_keys(table_name)
|
11
|
-
)
|
12
|
-
ActiveRecord::Base.connection.columns(table_name).map do |column|
|
13
|
-
column_test = ActiveRecord::Dbt::Column::Test.new(
|
14
|
-
table_name,
|
15
|
-
column,
|
16
|
-
primary_keys: primary_keys,
|
17
|
-
foreign_keys: foreign_keys
|
18
|
-
)
|
19
|
-
|
20
|
-
ActiveRecord::Dbt::Column::Column.new(
|
21
|
-
table_name,
|
22
|
-
column,
|
23
|
-
column_test,
|
24
|
-
primary_keys: primary_keys
|
25
|
-
)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module Factory
|
6
|
-
module Model
|
7
|
-
module StagingFactory
|
8
|
-
def self.yml_build(table_name)
|
9
|
-
table_factory = ActiveRecord::Dbt::Factory::TableFactory.build(table_name)
|
10
|
-
yml = ActiveRecord::Dbt::Model::Staging::Yml.new(table_factory)
|
11
|
-
struct = Struct.new(:export_path, :yml_dump, keyword_init: true)
|
12
|
-
|
13
|
-
struct.new(
|
14
|
-
export_path: yml.export_path,
|
15
|
-
yml_dump: YAML.dump(yml.config.deep_stringify_keys)
|
16
|
-
)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module Factory
|
6
|
-
module SourceFactory
|
7
|
-
def self.build
|
8
|
-
tables_factory = ActiveRecord::Dbt::Factory::TablesFactory.build
|
9
|
-
config = ActiveRecord::Dbt::Source::Yml.new(tables_factory).config
|
10
|
-
|
11
|
-
YAML.dump(config.deep_stringify_keys)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module Factory
|
6
|
-
module TableFactory
|
7
|
-
def self.build(table_name)
|
8
|
-
table_test = ActiveRecord::Dbt::Table::Test.new(table_name)
|
9
|
-
columns = ActiveRecord::Dbt::Factory::ColumnsFactory.build(table_name)
|
10
|
-
|
11
|
-
ActiveRecord::Dbt::Table::Yml.new(table_name, table_test, columns)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveRecord
|
4
|
-
module Dbt
|
5
|
-
module Factory
|
6
|
-
module TablesFactory
|
7
|
-
def self.build
|
8
|
-
ActiveRecord::Base.connection.tables.sort.map do |table_name|
|
9
|
-
ActiveRecord::Dbt::Factory::TableFactory.build(table_name)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|