{"record":{"id":"b9578357c4e9f05c","repo":"prestodb/presto","slug":"total-rows-is-larger-than-2-64","errorCode":null,"errorMessage":"Total rows is larger than 2^64","messagePattern":"Total rows is larger than 2\\^64","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-tpch/src/main/java/com/facebook/presto/tpch/TpchMetadata.java","lineNumber":559,"sourceCode":"            case IDENTIFIER:\n                return BIGINT;\n            case INTEGER:\n                return INTEGER;\n            case DATE:\n                return DATE;\n            case DOUBLE:\n                return DOUBLE;\n            case VARCHAR:\n                return createVarcharType((int) (long) tpchType.getPrecision().get());\n        }\n        throw new IllegalArgumentException(\"Unsupported type \" + tpchType);\n    }\n\n    private long calculateTotalRows(int scaleBase, double scaleFactor)\n    {\n        double totalRows = scaleBase * scaleFactor;\n        if (totalRows > Long.MAX_VALUE) {\n            throw new IllegalArgumentException(\"Total rows is larger than 2^64\");\n        }\n        return (long) totalRows;\n    }\n}\n","sourceCodeStart":541,"sourceCodeEnd":564,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-tpch/src/main/java/com/facebook/presto/tpch/TpchMetadata.java#L541-L564","documentation":"TpchMetadata.calculateTotalRows computes a table's row count as scaleBase * scaleFactor. Because the result must fit in a Java long, any product exceeding Long.MAX_VALUE (~9.2e18) throws this IllegalArgumentException. It guards TpchTable row-count generation (e.g. getTableLayoutForConstraint computing row counts for statistics).","triggerScenarios":"Calling getTableLayoutForConstraint (or any caller of calculateTotalRows) with a scale factor so large that scaleBase * scaleFactor overflows Long.MAX_VALUE — practically, TPC-H scale factors far beyond the supported range.","commonSituations":"Configuring the TPCH connector with an enormous scale factor (e.g. sf1000000+) or misconfigured scale properties where a percentage/factor string is parsed incorrectly, producing an astronomically large multiplier.","solutions":["Reduce the configured TPC-H scale factor to a supported value (e.g. sf1–sf10000).","Verify the scale factor configuration/property is parsed with the correct units (no accidental multiplication).","If larger datasets are genuinely needed, split the workload or use a different connector designed for huge scale."],"exampleFix":"// before\nproperties.put(\"tpch.scale-factor\", 100000000.0); // overflows row counts\n// after\nproperties.put(\"tpch.scale-factor\", 100.0);","handlingStrategy":"validation","validationCode":"double totalRows = scaleBase * scaleFactor;\nif (totalRows > (double) Long.MAX_VALUE) {\n    throw new IllegalArgumentException(\"Scale factor too large: \" + scaleFactor);\n}","typeGuard":null,"tryCatchPattern":"try {\n    layout = metadata.getTableLayoutForConstraint(...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Total rows\")) {\n        // lower the scale factor and retry\n    }\n}","preventionTips":["Keep TPC-H scale factors within supported ranges (sf1–sf10000).","Validate scale factor configuration at startup, before query planning.","Confirm scale-factor property parsing uses the intended units."],"tags":["tpch-connector","overflow","illegal-argument"],"backgroundTag":"numeric-overflow","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}