athena-jdbc icon indicating copy to clipboard operation
athena-jdbc copied to clipboard

Infinate loop in Result iterator for DML commands

Open DALDEI opened this issue 4 years ago • 2 comments

Some SQL commands can produce an infinite loop iterating the result set. Ive tracked this down to them producing either unsupported protobuf types (eg. type 1) or 0 columns (may be related). The 0 column problem results in the iterator code to not advance the CSV pointer -- e.g the conditions never call the appropreate methods to read more from the CSV file if there are ' 0 columns' (triggered likely by the former issue) .

Examples to try

SHOW TABLES MSCK REPAIR TABLE tablename

DALDEI avatar Jan 02 '21 20:01 DALDEI

src/main/java/io/burt/athena/result/csv/VeryBasicCsvParser.java If columnCount ends up 0 then next() never advances.

DALDEI avatar Jan 02 '21 20:01 DALDEI

Thank you, good catch. Would you like to take a stab at fixing it? You've already identified the source of the CSV parsing issue. I think you can duplicate this test https://github.com/burtcorp/athena-jdbc/blob/b0268c9ee63f52a10b5713259203f0daf504ff80/src/test/java/io/burt/athena/result/csv/VeryBasicCsvParserTest.java#L100-L111 and change the 3 (the number of columns) to a 0 to trigger the bug (also duplicate the corresponding test for hasNext).

iconara avatar Jan 03 '21 20:01 iconara