Im trying to get laravel 7x
to work with impala/kudu
provided by cloudera
. Ive got the ODBC connection
which connects fine and if you run raw sql query it also works fine.
Database connection entry:
'impala_connect' => [
'driver' => 'sqlsrv',
'odbc' => true,
'odbc_datasource_name'=> 'cloudera_odbc_connection',
'host' => '',
'port' => '',
'database' => '',
'username' => '',
'password' => '',
'pooling' => false,
],
Raw queries work fine:
DB::connection('impala_connect')->raw("insert into test1 values(4, 'z')");
DB::connection('impala_connect')->select(DB::raw('select * from test1'));
Query builder fails:
However, when Im using the laravel's query builder to run some queries they all fail with brackets that laravel adds on its own.
DB::connection('impala_connect')->table('test1')->get(['id', 'val']);
//or
DB::connection('impala_connect')->table('test1')->insert([
'id'=> 5,
'val'=> 'z'
]);
This is the error I get:
SQLSTATE: General error: 0 [Cloudera][ImpalaODBC] (110) Error while executing a query in Impala : ParseException: Syntax error in line 1: select [id], [val] from [test1] ^
Encountered: COMMA Expected: CASE, CAST, DEFAULT, EXISTS, FALSE, IF, INTERVAL, LEFT, NOT, NULL, REPLACE, RIGHT, TRUNCATE, TRUE, IDENTIFIER
CAUSED BY: Exception: Syntax error (SQLPrepare[0] at pdo_odbc\odbc_driver.c:206) (SQL: select [id], [val] from [test1])
You can see the actual query became a bracket for each item and thats where it failed.
So how do you make laravel NOT wrap brackets?!
EDIT:
I did figure out how to get table name at least without brackets.
->table(db::raw('test1'))->
However, I cant get the column names in insert
and update
.