PNixx / clickhouse-activerecord

A Ruby database ActiveRecord driver for ClickHouse

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Response code: 400:\nCode: 27. DB::ParsingException: Cannot parse input: expected '(' before: 'FORMAT JSONCompact': at row 49: While executing ValuesBlockInputFormat. (CANNOT_PARSE_INPUT_ASSERTION_FAILED) (version 23.8.1.41541 (official build))\n

bitla-sridevi opened this issue · comments

gem 'clickhouse-activerecord', '0.5.15'
Rails 6
When i do TicFact.insert_all(recs)
Clickhouse TicFact Bulk Insert (697.3ms) INSERT INTO tic_facts(fact_id,travel_id,travel_name,origin_name,destination_name,pnr_number,travel_date,actual_travel_date,seat_number,round_trip_number,route_number,reservation_id,final_coach,passenger_title,passenger_name,email,phone_number,adult_fare,additional_fare,offer_discount,discount_amount,service_tax_amount,tcs_amount,convenience_charge_amount,transaction_charges,offer_amount,cancelled_fare,cancelled_service_tax_amount,cancelled_convenience_charge_amount,is_cancelled_ticket,gst_on_cancel_charges,cancel_percent,branch_name,branch_commission,agent_discount,agent_commission,agent_cancel_refund_amount,agent_topup,agent_booking_number,it_tds_amount,tds,branch_tds,can_tcs_amount,can_it_tds_amount,ts_pay_gay_type,pay_gay_type,credit_transaction_number,pg_commission,pg_comm_service_tax,txn_details,booked_on,issued_on,created_by,sale_type,is_open_ticket,is_pre_post_pone,is_blocked_ticket,is_open_ticket_coupon_used,booking_type,licences,is_online,payment_confirmed,pre_post_pone_pnr,boarding_at,drop_off,onbehalf_paid,onbehalf_paid_comments,cancelled_onbehalf_paid,onbehalf_branch_name,cancel_onbehalf_travel_branch,issued_by,cancelled_by,created_on,cancelled_date,cancelled_on,payment_type,sign,version) VALUES (10102, 4, 'RSKK Travels', 'Tirunelveli', 'Chennai', '1219791', '2022-04-13', '2022-04-13', '1LA', '', 'NGL-test', 5096, '', 'Mr', 'Testagent1', 'testagent1@gmail.com', '9011111111, 1799.0, NULL, 0.0, 0.0, 0.0, 17.99, 161.91, 0.0, NULL, NULL, 0.0, 0.0, 0, NULL, NULL, '', 0.0, 0.0, 0.0, 0.0, NULL, '', 0.0, 0.0, 0.0, 0.0, 0.0, '13', 32, '', 102.54, 8.2, '', '2022-04-13 08:01:14', '2022-04-13 08:01:31', 'System Administrator', '', 0, 0, 0, 0, '5', '00000000000000000000010000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000', 0, 0, '', 'Tirunelveli', 'Koyambedu', 0, '', 0, '', '', 'System Administrator', '', '2022-04-13 08:01:15', '2018-09-23 00:00:00', '2018-01-01 05:31:06', 'Cash', 1, 0), (10109, 4, 'RDDKK Travels', 'Chennai', 'Coimbatore', '1219811', '2022-06-30', '2022-06-30', '4', '', 'BH 505', 8978, '', 'Mr', 'Sfds', '', '9011111111', 1500.0, 0.0, 0.0, 0.0, 0.0, 0.0, 135.0, 0.0, NULL, NULL, 0.0, 0.0, 0, NULL, NULL, 'VVT Travels', 0.0, 0.0, 0.0, 0.0, 0.0, '', 0.0, 0.0, 0.0, 0.0, 0.0, '', NULL, '', 0.0, 0.0, '', '2022-06-30 07:45:46', '2022-06-30 07:45:46', '', '', 0, 0, 0, 0, '1', '00000000000000000000000100000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 1, 0, '', 'Ashok Pillar', 'Coimbatore', 0, '', 0, 'VVT Travels', '', '', '', '2022-06-30 07:45:46', '2018-09-23 00:00:00', '2018-01-01 05:31:06', 'Cash', 1, 0)

Code: 27. DB::ParsingException: Cannot parse input: expected '(' before: 'FORMAT JSONCompact': at row 49: While executing ValuesBlockInputFormat. (CANNOT_PARSE_INPUT_ASSERTION_FAILED) (version 23.8.1.41541 (official build))

Note:
Same works fine in Rails 7

Overriden below method format = nil instead of format='JSONCompact'

ActiveRecord::ConnectionAdapters::Clickhouse::SchemaStatements.module_eval do
def do_execute(sql, name = nil, format: nil, settings: {})
log(sql, "#{adapter_name} #{name}") do
formatted_sql = apply_format(sql, format)
request_params = @config || {}
res = @connection.post("/?#{request_params.merge(settings).to_param}", formatted_sql, 'User-Agent' => "Clickhouse ActiveRecord #{ClickhouseActiverecord::VERSION}")
process_response(res)
end
end
end

insert_all works fine but table creation fails

fixed in v0.6.0