ClickHouse / clickhouse-js

Official JS client for ClickHouse DB
https://clickhouse.com
Apache License 2.0
205 stars 25 forks source link

Temporary Table unusable from client #194

Closed aarmandas closed 1 year ago

aarmandas commented 1 year ago

To trigger the error: ClickHouseError: Table data.test doesn't exist You have to initialise a client, create a temporary table and then try getting any data out of it.

The following is the code I used to trigger the error

(async () => {

  const client = createClient({
      // ...settings
      database: 'data',
  });

  await client.command({
      query: `
        CREATE TEMPORARY TABLE test (
          url String,
          timestamp Float64
        );
      `,
  });

  await client.query({
      query: `
        SELECT * FROM test;
      `,
  });

})();
slvrtrn commented 1 year ago

You need to include a session id. See the related test: https://github.com/ClickHouse/clickhouse-js/blob/b38613832b70e7b8744d15b9a0914e264cc7e747/packages/client-common/__tests__/integration/exec.test.ts#L75-L95

aarmandas commented 1 year ago

Thank you, I didn't find any mention of this in the docs so I was a bit confused

slvrtrn commented 1 year ago

@ArmyDev, no worries, I've added an example now: https://github.com/ClickHouse/clickhouse-js/blob/main/examples/session_id_and_temporary_tables.ts