Skip to content

Count isn't matching expected value #1786

Closed
@Paultagoras

Description

@Paultagoras

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);
        }
    }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions