ClickHouse / dbt-clickhouse

The Clickhouse plugin for dbt (data build tool)
Apache License 2.0
253 stars 113 forks source link

Remove stacktrace from database errors #382

Closed 3fonov closed 1 week ago

3fonov commented 1 week ago

Summary

I'm always frustrated when scrolling throw stack trace to my actual errors in database.

381

Solution Remove stack trace and keep only database errors.

Before

clickhouse adapter: ClickHouse server does not support exchange tables Database Error
  Code: 1.
  DB::Exception: System call renameat2() is not supported. Stack trace:

  0. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0xce3f35a in /usr/bin/clickhouse
  1. DB::renameExchange(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&) @ 0x11a385a5 in /usr/bin/clickhouse
  2. DB::DatabaseAtomic::renameTable(std::__1::shared_ptr<DB::Context const>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::IDatabase&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool) @ 0x11a2f0dd in /usr/bin/clickhouse
  3. DB::InterpreterRenameQuery::executeToTables(DB::ASTRenameQuery const&, std::__1::vector<DB::RenameDescription, std::__1::allocator<DB::RenameDescription> > const&, std::__1::map<DB::UniqueTableName, std::__1::unique_ptr<DB::DDLGuard, std::__1::default_delete<DB::DDLGuard> >, std::__1::less<DB::UniqueTableName>, std::__1::allocator<std::__1::pair<DB::UniqueTableName const, std::__1::unique_ptr<DB::DDLGuard, std::__1::default_delete<DB::DDLGuard> > > > >&) @ 0x125ca713 in /usr/bin/clickhouse
  4. DB::InterpreterRenameQuery::execute() @ 0x125c9608 in /usr/bin/clickhouse
  5. ? @ 0x1297956b in /usr/bin/clickhouse
  6. DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) @ 0x1297682d in /usr/bin/clickhouse
  7. DB::TCPHandler::runImpl() @ 0x1353d924 in /usr/bin/clickhouse
  8. DB::TCPHandler::run() @ 0x13551919 in /usr/bin/clickhouse
  9. Poco::Net::TCPServerConnection::start() @ 0x1636236f in /usr/bin/clickhouse
  10. Poco::Net::TCPServerDispatcher::run() @ 0x163646fb in /usr/bin/clickhouse
  11. Poco::PooledThread::run() @ 0x1651ff92 in /usr/bin/clickhouse
  12. Poco::ThreadImpl::runnableEntry(void*) @ 0x1651d71d in /usr/bin/clickhouse
  13. ? @ 0x7fd8e7797609 in ?
  14. clone @ 0x7fd8e76bc133 in ?

After

clickhouse adapter: ClickHouse server does not support exchange tables Database Error
  Code: 1.
  DB::Exception: System call renameat2() is not supported.

Checklist

Delete items not relevant to your PR:

BentsiLeviav commented 1 week ago

Hi @3fonov

Thank you for your contribution! I'm not sure this behavior would be desired, as we often use the stack trace to investigate CH side issues.

In addition, usually, the error appears right at the beginning of the stack trace, so in what case do you need to scroll to find it? You can just ignore the reset of the lines.

I understand that it might be frustrating for you to have irrelevant text, but it is crucial for many other users.

We would love to get your help with other critical issues in this repo.

Thank you again for your contribution.

3fonov commented 1 week ago

@BentsiLeviav added ENV VAR to control behavior and corresponding tests.

BentsiLeviav commented 1 week ago

Could you please fix the lint issue?

3fonov commented 1 week ago

Could you please fix the lint issue?

It seems that it is from file that i didn't touched: tests/integration/adapter/dictionary/test_dictionary.py. Fixed it anyway.

BentsiLeviav commented 1 week ago

Ohh thanks for that!