(dbtvenv) PS C:\Users\Alexander\PycharmProjects\SberPullerFelina\sberpuller> dbt run…
- User
(dbt_venv) PS C:\Users\Alexander\PycharmProjects\SberPullerFelina\sberpuller> dbt run 20:04:21 Running with dbt=1.8.6 20:04:21 Registered adapter: postgres=1.8.2 20:04:21 Found 3 models, 4 data tests, 1 source, 420 macros 20:04:21 20:04:21 Concurrency: 1 threads (target='dev') 20:04:21 20:04:21 1 of 3 START sql incremental model public_public_mega.my_first_dbt_model ....... [RUN] 20:04:22 1 of 3 ERROR creating sql incremental model public_public_mega.my_first_dbt_model [ERROR in 0.15s] 20:04:22 2 of 3 START sql table model public_public_mega.my_second_dbt_model ............ [RUN] 20:04:22 2 of 3 OK created sql table model public_public_mega.my_second_dbt_model ....... [SELECT 25 in 0.14s] 20:04:22 3 of 3 START sql incremental model public_public_mega.spot_klines .............. [RUN] 20:04:22 3 of 3 ERROR creating sql incremental model public_public_mega.spot_klines ..... [ERROR in 0.08s] 20:04:22
20:04:22 Finished running 2 incremental models, 1 table model in 0 hours 0 minutes and 0.72 seconds (0.72s). 20:04:22
20:04:22 Completed with 2 errors and 0 warnings: 20:04:22 20:04:22 Database Error in model my_first_dbt_model (models\example\my_first_dbt_model.sql) invalid input syntax for type bigint: "42558.02000000" 20:04:22 20:04:22 Database Error in model spot_klines (models\spot_klines.sql) invalid input syntax for type bigint: "42558.02000000" 20:04:22 20:04:22 Done. PASS=1 WARN=0 ERROR=2 SKIP=0 TOTAL=3 (dbt_venv) PS C:\Users\Alexander\PycharmProjects\SberPullerFelina\sberpuller> {{ config( materialized='incremental', incremental_strategy='delete+insert', unique_key=['timestamp', 'exchange_id', 'venue', 'symbol'], pre_hook=[ "CREATE EXTENSION IF NOT EXISTS timescaledb;" ], post_hook=[ "CREATE INDEX IF NOT EXISTS idx_timestamp ON {{ this }} (timestamp);" ] ) }}with raw_klines as ( select timestamp, symbol, jsonb_array_elements(payload::jsonb) as payload_element from public.binance_spot_klines ), parsed_data as ( select timestamp, symbol, (payload_element->>0)::bigint / 1000 as open_time_unix, -- Преобразование времени из миллисекунд в секунды to_timestamp((payload_element->>0)::bigint / 1000) as open_time, (payload_element->>1)::numeric as open, (payload_element->>2)::numeric as high, (payload_element->>3)::numeric as low, (payload_element->>4)::numeric as close from raw_klines ), converted_data as ( select timestamp::timestamp as timestamp, 'binance' as exchange_id, 'spot' as venue, symbol, open as open_price, high as high_price, low as low_price, close as close_price, open_time from parsed_data )
select * from converted_data
- Assistant
The error message indicates that there is an "invalid input syntax for type bigint" with the value
"42558.02000000". This suggests that there is an attempt to cast a numeric value with decimal places to a . In SQL, a type is an integer type that does not support decimal points. Therefore, you need to ensure that you're only attempting to cast values that are integers to . - User
write correct code that works
- Assistant
Given the error, we need to ensure that the value retrieved and manipulated does not have a decimal point when casting it to a . You can modify the SQL query to correctly handle the data types associated with your JSON payload.
- User
(dbt_venv) PS C:\Users\Alexander\PycharmProjects\SberPullerFelina\sberpuller> dbt run 20:06:43 Running with dbt=1.8.6 20:06:43 Registered adapter: postgres=1.8.2 20:06:44 Encountered an error: Compilation Error in model my_first_dbt_model (models\example\my_first_dbt_model.sql) unexpected char '‘' at 36 line 3 materialized=‘incremental’,
- Assistant
The error message indicates a
Compilation Errordue to an unexpected character'‘'in your config block. This usually happens when a non-standard single quote character, often formatted by text editors or copy-pasting from certain sources, is used instead of a standard single quote . - User
still same error fix it
- Assistant