与dbt在Oracle上的近似关系匹配

  • 本文关键字:关系 dbt Oracle oracle dbt
  • 更新时间 :
  • 英文 :


我是dbt的新手,我不确定我的问题是代码问题还是我对工具的理解问题。所以,我将尽我所能把这件事说清楚,希望有人能给我指出正确的方向。

相关信息
  • Server: Oracle 12.2
  • 桌面操作系统:Windows 10
  • 限制:很多——这是一个高度监管的环境,所以我不能去IT部门要求对服务器进行任何更改。我要么自己解决这个问题,要么做一些不同的事情。

我正在尝试转换自己,并最终我的团队使用dbt在我们的个人模式中构建可重复的数据库对象。我知道——我的模式不是一个数据集市。但那是我能做的。

置>我创建了一个简单的例子来演示我的问题,叫做simple_test,它有一个单一的模型。

dbt_project。yml

name: 'simple_test'
version: '1.0.0'
config-version: 2
profile: 'issuers_datamart'
model-paths: ["models"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]
target-path: "target"  # directory which will store compiled SQL files
clean-targets:         # directories to be removed by `dbt clean`
- "target"
- "dbt_packages"
# Configuring models
# Full documentation: https://docs.getdbt.com/docs/configuring-models
models:
simple_test:
+materialized: table

是的,我希望我的模型物化为表。这些查询可能需要几个小时才能运行,因此视图对我的用例根本无效。

在模型,我有一个文件properties.yml:

name: "{{ env_var('DBT_ORACLE_SCHEMA') }}"
version: 2
models:
- name: testy_mctest_face

最后在模型中,我有一个文件testy_mctest_face.sql:

select
1 an_int
,'two' a_string
,3.3 a_float
from dual

查询成功。

实际上,当我运行dbt调试时,一切看起来都很好。

18:40:50  Running with dbt=1.4.1
dbt version: 1.4.1
python version: 3.10.2
python path: C:Usersayc58AppDataLocalProgramsPythonPython310python.exe
os info: Windows-10-10.0.19045-SP0
Using profiles.yml file at C:Usersayc58.dbtprofiles.yml
Using dbt_project.yml file at C:Usersayc58Devsimple_testdbt_project.yml
18:40:51  oracle adapter: Running in thick mode
Configuration:
profiles.yml file [OK found and valid]
dbt_project.yml file [OK found and valid]
Required dependencies:
- git [OK found]
Connection:
user: ***
database: ***
schema: ***
protocol: ***
host: ***
port: ***
tns_name: ***
service: ***
connection_string: None
shardingkey: []
supershardingkey: []
cclass: None
purity: None
retry_count: 1
retry_delay: 3
Connection test: [OK connection ok]
All checks passed!

然后我可以运行我的"模型"testy_mctest_face .

19:08:57  oracle adapter: Running in thick mode
19:08:57  Running with dbt=1.4.1
19:08:57  Unable to do partial parsing because a project dependency has been added
19:08:58  Found 1 model, 0 tests, 0 snapshots, 1 analysis, 325 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
19:08:58
19:09:06  Concurrency: 4 threads (target='dev')
19:09:06
19:09:06  1 of 1 START sql table model AYC58.testy_mctest_face ........................... [RUN]
19:09:10  1 of 1 OK created sql table model AYC58.testy_mctest_face ...................... [OK in 4.04s]
19:09:12
19:09:12  Finished running 1 table model in 0 hours 0 minutes and 13.71 seconds (13.71s).
19:09:12
19:09:12  Completed successfully
19:09:12
19:09:12  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1

我的表的内容是我所期望的。

当我尝试使用dbt run -f重建我的模型时,我遇到了一个非常令人沮丧的问题:

19:09:31  oracle adapter: Running in thick mode
19:09:31  Running with dbt=1.4.1
19:09:31  Found 1 model, 0 tests, 0 snapshots, 1 analysis, 325 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
19:09:31  
19:09:38  Concurrency: 4 threads (target='dev')
19:09:38  
19:09:38  1 of 1 START sql table model AYC58.testy_mctest_face ........................... [RUN]
19:09:38  1 of 1 ERROR creating sql table model AYC58.testy_mctest_face .................. [ERROR in 0.06s]
19:09:40  
19:09:40  Finished running 1 table model in 0 hours 0 minutes and 8.95 seconds (8.95s).
19:09:40  
19:09:40  Completed with 1 error and 0 warnings:
19:09:40
19:09:40  Compilation Error in model testy_mctest_face (modelstesty_mctest_face.sql)
19:09:40    When searching for a relation, dbt found an approximate match. Instead of guessing
19:09:40    which relation to use, dbt will move on. Please delete AYC58.TESTY_MCTEST_FACE, or rename it to be less ambiguous.
19:09:40    Searched for: AYC58.TESTY_MCTEST_FACE
19:09:40    Found: AYC58.TESTY_MCTEST_FACE
19:09:40
19:09:40    > in macro materialization_table_oracle (macrosmaterializationstabletable.sql)
19:09:40    > called by model testy_mctest_face (modelstesty_mctest_face.sql)
19:09:40
19:09:40  Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1

是的,表存在。但我对dbt的理解是,它将在构建新表时创建一个临时表,删除旧表,并将临时表重命名为最终名称。相反,它只是被挂起。

  • 将模式名称更改为小写并将其硬编码到模型中。没有区别。
  • 我已经尝试了所有不同的引用排列,似乎没有任何区别。
    • 此外,DBT Oracle参考资料中没有提到需要这样做。
  • 现有SO问题不适合。示例:我已经使用dbt run -f
  • 例句:我想我没有拼写错误。我真正的项目没有那么愚蠢的拼写。
  • 我已经准备好了DBT文档。我甚至试过用预钩修复。我对DBT的理解是,这应该是不必要的,但我还是尝试了。我的理解/期望是DBT将用临时名称创建我的表,然后用我的新表替换我的旧表,因为我使用dbt run -f。我甚至查看了Oracle特定的宏,虽然我不理解那里的所有内容,但这就是它看起来的样子。

  • 我在我的组织中有完全相同的配置,我也在努力解决同样的问题。在我的情况下,有效的解决方案是将此添加到dbt_project中。yml文件:

    quoting:
    database: true
    

    最新更新