Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ClickHouse URI #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/URI/clickhouse.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package URI::clickhouse;
use base 'URI::_odbc';
our $VERSION = '0.20';

sub default_port { 8123 }

1;
30 changes: 30 additions & 0 deletions t/dbi.t
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,36 @@ for my $spec (
dbi => [ [Server => 'foo'], [Port => 123], [Database => 'try'] ],
qry => [ foo => 1, foo => 2, lol => 'yes', Driver => 'Snowflaker' ],
},
{
uri => 'db:clickhouse:',
dsn => 'dbi:ODBC:',
dbi => [ [DSN => undef] ],
qry => [],
},
{
uri => 'db:clickhouse:dbadmin',
dsn => 'dbi:ODBC:DSN=dbadmin',
dbi => [ [DSN => 'dbadmin'] ],
qry => [],
},
{
uri => 'db:clickhouse://yow',
dsn => 'dbi:ODBC:Server=yow;Port=8123',
dbi => [ [Server => 'yow'], [Port => 8123], [Database => undef] ],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me if these typical ODBC config params are what click house's ODBC driver in fact supports. I don't see any param docs in the clickhouse-odbc project page, but I'm happy to take your word for it.

qry => [],
},
{
uri => 'db:clickhouse://yow:33',
dsn => 'dbi:ODBC:Server=yow;Port=33',
dbi => [ [Server => 'yow'], [Port => 33], [Database => undef] ],
qry => [],
},
{
uri => 'db:clickhouse://foo:123/try?foo=1&foo=2&lol=yes&Driver=ClickHouse',
dsn => 'dbi:ODBC:Server=foo;Port=123;Database=try;foo=1;foo=2;lol=yes;Driver=ClickHouse',
dbi => [ [Server => 'foo'], [Port => 123], [Database => 'try'] ],
qry => [ foo => 1, foo => 2, lol => 'yes', Driver => 'ClickHouse' ],
},
) {
my $uri = $spec->{uri};
ok my $u = URI->new($uri), "URI $uri";
Expand Down
85 changes: 43 additions & 42 deletions t/engines.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,49 @@ use URI;
use URI::QueryParam;

for my $spec (
[ db => undef, undef ],
[ unknown => undef, undef ],
[ postgresql => 5432, 'pg' ],
[ postgres => 5432, 'pg' ],
[ pgsql => 5432, 'pg' ],
[ pg => 5432, 'pg' ],
[ pgxc => 5432, 'pg' ],
[ postgresxc => 5432, 'pg' ],
[ redshift => 5432, 'pg' ],
[ mysql => 3306, 'mysql' ],
[ mariadb => 3306, 'mysql' ],
[ maria => 3306, 'mysql' ],
[ sqlite => undef, 'sqlite' ],
[ sqlite3 => undef, 'sqlite' ],
[ oracle => 1521, 'oracle' ],
[ cubrid => 33000, 'cubrid' ], # ?
[ firebird => 3050, 'firebird' ],
[ mssql => 1433, 'mssql' ],
[ sqlserver => 1433, 'mssql' ],
[ db2 => 50000, 'db2' ], # ?
[ ingres => 1524, 'ingres' ],
[ sybase => 2638, 'sybase' ],
[ informix => 1526, 'informix' ], # ?
[ teradata => 1025, 'teradata' ],
[ interbase => 3050, 'interbase' ],
[ unify => 27117, 'unify' ], # ?
[ mongodb => 27017, 'mongodb' ],
[ mongo => 27017, 'mongodb' ],
[ monetdb => 50000, 'monetdb' ], # ?
[ monet => 50000, 'monetdb' ], # ?
[ maxdb => 7673, 'maxdb' ], # ?
[ max => 7673, 'maxdb' ], # ?
[ impala => 21000, 'impala' ],
[ couchdb => 5984, 'couchdb' ],
[ couch => 5984, 'couchdb' ],
[ hive => 10000, 'hive' ],
[ cassandra => 9160, 'cassandra' ],
[ derby => 1527, 'derby' ],
[ vertica => 5433, 'vertica' ],
[ ldapdb => undef, 'ldapdb' ],
[ exasol => 8563, 'exasol' ],
[ snowflake => 443, 'snowflake' ],
[ db => undef, undef ],
[ unknown => undef, undef ],
[ postgresql => 5432, 'pg' ],
[ postgres => 5432, 'pg' ],
[ pgsql => 5432, 'pg' ],
[ pg => 5432, 'pg' ],
[ pgxc => 5432, 'pg' ],
[ postgresxc => 5432, 'pg' ],
[ redshift => 5432, 'pg' ],
[ mysql => 3306, 'mysql' ],
[ mariadb => 3306, 'mysql' ],
[ maria => 3306, 'mysql' ],
[ sqlite => undef, 'sqlite' ],
[ sqlite3 => undef, 'sqlite' ],
[ oracle => 1521, 'oracle' ],
[ cubrid => 33000, 'cubrid' ], # ?
[ firebird => 3050, 'firebird' ],
[ mssql => 1433, 'mssql' ],
[ sqlserver => 1433, 'mssql' ],
[ db2 => 50000, 'db2' ], # ?
[ ingres => 1524, 'ingres' ],
[ sybase => 2638, 'sybase' ],
[ informix => 1526, 'informix' ], # ?
[ teradata => 1025, 'teradata' ],
[ interbase => 3050, 'interbase' ],
[ unify => 27117, 'unify' ], # ?
[ mongodb => 27017, 'mongodb' ],
[ mongo => 27017, 'mongodb' ],
[ monetdb => 50000, 'monetdb' ], # ?
[ monet => 50000, 'monetdb' ], # ?
[ maxdb => 7673, 'maxdb' ], # ?
[ max => 7673, 'maxdb' ], # ?
[ impala => 21000, 'impala' ],
[ couchdb => 5984, 'couchdb' ],
[ couch => 5984, 'couchdb' ],
[ hive => 10000, 'hive' ],
[ cassandra => 9160, 'cassandra' ],
[ derby => 1527, 'derby' ],
[ vertica => 5433, 'vertica' ],
[ ldapdb => undef, 'ldapdb' ],
[ exasol => 8563, 'exasol' ],
[ snowflake => 443, 'snowflake' ],
[ clickhouse => 8123, 'clickhouse' ],
) {
my ($engine, $port, $canon) = @{ $spec };
my $prefix = "db:$engine";
Expand Down