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

Support DateTime64 for ODBC (MsSql) #21961

Closed
majorovms opened this issue Mar 22, 2021 · 0 comments · Fixed by #21972
Closed

Support DateTime64 for ODBC (MsSql) #21961

majorovms opened this issue Mar 22, 2021 · 0 comments · Fixed by #21972
Assignees
Labels
comp-datetime date & time & timezone related comp-odbc unfinished code

Comments

@majorovms
Copy link

Unfortunately it's impossible to select DateTime64 type through ODBC engine.

Error: Unsupported value type

2021.03.22 11:27:40.420143 [ 1730 ] {19f3b339-b64d-4023-a76f-3775fbe69cef} <Error> executeQuery: Code: 86, e.displayText() = DB::Exception: Received error from remote server /?connection_string=DSN%3Dmssqlconn%3BUID%3Dsa%3BPWD%3D123&columns=columns%20format%20version%3A%201%0A4%20columns%3A%0A%60uuid%60%20String%0A%60name%60%20String%0A%60date%60%20DateTime64%283%29%0A%60value%60%20Float64%0A&max_block_size=65505. HTTP status code: 500 Internal Server Error, body: �Code: 50, e.displayText() = DB::Exception: Unsupported value type, Stack trace (when copying this message, always include the lines below):

0. ? @ 0x2b81918 in /usr/bin/clickhouse-odbc-bridge
1. ? @ 0x2b810bc in /usr/bin/clickhouse-odbc-bridge
2. ? @ 0x2bca70c in /usr/bin/clickhouse-odbc-bridge
3. ? @ 0x2bd9a9f in /usr/bin/clickhouse-odbc-bridge
4. ? @ 0x2b68d39 in /usr/bin/clickhouse-odbc-bridge
5. ? @ 0x5cc2b85 in /usr/bin/clickhouse-odbc-bridge
6. ? @ 0x5ce89df in /usr/bin/clickhouse-odbc-bridge
7. ? @ 0x5cea3e1 in /usr/bin/clickhouse-odbc-bridge
8. ? @ 0x5f66429 in ?
9. ? @ 0x5f62d4a in ?
10. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
11. __clone @ 0x122293 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
 (version 21.2.2.8 (official build)) (version 21.2.2.8 (official build)) (from 172.31.0.20:50057) (in query: select uuid, name, value, date from test_odbc_data FORMAT TabSeparatedWithNamesAndTypes;), Stack trace (when copying this message, always include the lines below):

0. DB::assertResponseIsOk(Poco::Net::HTTPRequest const&, Poco::Net::HTTPResponse&, std::__1::basic_istream<char, std::__1::char_traits<char> >&, bool) @ 0xcdfcd63 in /usr/bin/clickhouse
1. DB::detail::ReadWriteBufferFromHTTPBase<std::__1::shared_ptr<DB::UpdatableSession> >::call(Poco::URI, Poco::Net::HTTPResponse&) @ 0xcdf18ff in /usr/bin/clickhouse
2. DB::detail::ReadWriteBufferFromHTTPBase<std::__1::shared_ptr<DB::UpdatableSession> >::ReadWriteBufferFromHTTPBase(std::__1::shared_ptr<DB::UpdatableSession>, Poco::URI, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::function<void (std::__1::basic_ostream<char, std::__1::char_traits<char> >&)>, Poco::Net::HTTPBasicCredentials const&, unsigned long, std::__1::vector<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >, DB::RemoteHostFilter const&) @ 0xcdee077 in /usr/bin/clickhouse
3. DB::ReadWriteBufferFromHTTP::ReadWriteBufferFromHTTP(Poco::URI, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::function<void (std::__1::basic_ostream<char, std::__1::char_traits<char> >&)>, DB::ConnectionTimeouts const&, unsigned long, Poco::Net::HTTPBasicCredentials const&, unsigned long, std::__1::vector<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&, DB::RemoteHostFilter const&) @ 0xcded897 in /usr/bin/clickhouse
4. DB::IStorageURLBase::read(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::SelectQueryInfo&, DB::Context const&, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) @ 0xf1e7e8f in /usr/bin/clickhouse
5. DB::StorageXDBC::read(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::SelectQueryInfo&, DB::Context const&, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) @ 0xf1f0444 in /usr/bin/clickhouse
6. DB::IStorage::read(DB::QueryPlan&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::SelectQueryInfo&, DB::Context const&, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) @ 0xf04a31f in /usr/bin/clickhouse
7. DB::InterpreterSelectQuery::executeFetchColumns(DB::QueryProcessingStage::Enum, DB::QueryPlan&, std::__1::shared_ptr<DB::PrewhereDAGInfo> const&, std::__1::unordered_set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0xebacfbb in /usr/bin/clickhouse
8. DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::__1::shared_ptr<DB::IBlockInputStream> const&, std::__1::optional<DB::Pipe>) @ 0xeba2011 in /usr/bin/clickhouse
9. DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) @ 0xeba1734 in /usr/bin/clickhouse
10. DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) @ 0xed46e33 in /usr/bin/clickhouse
11. DB::InterpreterSelectWithUnionQuery::execute() @ 0xed47fb4 in /usr/bin/clickhouse
12. ? @ 0xeed0ea2 in /usr/bin/clickhouse
13. DB::executeQuery(DB::ReadBuffer&, DB::WriteBuffer&, bool, DB::Context&, std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>) @ 0xeed4592 in /usr/bin/clickhouse
14. DB::HTTPHandler::processQuery(DB::Context&, Poco::Net::HTTPServerRequest&, HTMLForm&, Poco::Net::HTTPServerResponse&, DB::HTTPHandler::Output&, std::__1::optional<DB::CurrentThread::QueryScope>&) @ 0xf5776b4 in /usr/bin/clickhouse
15. DB::HTTPHandler::handleRequest(Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse&) @ 0xf57b6c1 in /usr/bin/clickhouse
16. Poco::Net::HTTPServerConnection::run() @ 0x11b40e75 in /usr/bin/clickhouse
17. Poco::Net::TCPServerConnection::start() @ 0x11b76baf in /usr/bin/clickhouse
18. Poco::Net::TCPServerDispatcher::run() @ 0x11b785c1 in /usr/bin/clickhouse
19. Poco::PooledThread::run() @ 0x11caf669 in /usr/bin/clickhouse
20. Poco::ThreadImpl::runnableEntry(void*) @ 0x11cab4ca in /usr/bin/clickhouse
21. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
22. __clone @ 0x122293 in /usr/lib/x86_64-linux-gnu/libc-2.31.so

How to reproduce

  1. Create this table in MsSql
create table test_data(
    name varchar(255),
    date datetime,
    value double precision
);
  1. Setup odbc connection in /etc/odbc.ini
[mssqlconn]
Driver = ODBC Driver 17 for SQL Server
Server = tcp:127.0.0.1,1433
  1. Create this table in Clickhouse
create table test_odbc_data(
  name String,
  date DateTime64(3),
  value Float64
) ENGINE ODBC('DSN=mssqlconn;UID=sa;PWD=123', 'dbo', 'test_data');
  1. Select data without date column. It's OK
select name, value from test_odbc_data;
  1. Select data with date column. Error occurs.
select name, value, date from test_odbc_data;

Other details

  1. DateTime works but without millis.
  2. MsSql type datetime2(3) causes an error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-datetime date & time & timezone related comp-odbc unfinished code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants