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

Count isn't matching expected value #1786

Closed
Paultagoras opened this issue Aug 23, 2024 · 1 comment · Fixed by #1790
Closed

Count isn't matching expected value #1786

Paultagoras opened this issue Aug 23, 2024 · 1 comment · Fixed by #1790
Assignees
Labels
Milestone

Comments

@Paultagoras
Copy link
Contributor

Paultagoras commented Aug 23, 2024

So this is what's actually stored in the database:

Query id: 2c4bffc3-42ce-4aca-8739-0276271532de

┌─name───────────────┐
│ decimal_table_test │
└────────────────────┘

1 row in set. Elapsed: 0.003 sec. 

f0c582c28b28 :) SELECT COUNT(*) FROM decimal_table_test

SELECT COUNT(*)
FROM decimal_table_test

Query id: b90d9653-038a-447d-abeb-1b851f00b575

┌─count()─┐
│    1000 │
└─────────┘

1 row in set. Elapsed: 0.004 sec. 

This is what I'm getting back: 16718206241729413120

This is the code we're using to get that:

public static int countRows(ClickHouseHelperClient chc, String tableName) {
        String queryCount = String.format("SELECT COUNT(*) FROM `%s`", tableName);

        try {
            Records records = chc.getClient().queryRecords(queryCount).get(10, TimeUnit.SECONDS);
            // Note we probrbly need asInteger() here
            String value = records.iterator().next().getString(1);
            return Integer.parseInt(value);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
@TBBle
Copy link

TBBle commented Aug 26, 2024

16718206241729413120 is 1000 but in 64-bit but the wrong endianness (0xe803000000000000 vs 0x00000000000003e8) in case that helps.

@chernser chernser added this to the 0.6.5 milestone Aug 26, 2024
@chernser chernser assigned chernser and Paultagoras and unassigned chernser Aug 26, 2024
@Paultagoras Paultagoras linked a pull request Aug 26, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants