druid-io / pydruid

A Python connector for Druid
Other
506 stars 194 forks source link

Fix empty result #133

Closed betodealmeida closed 6 years ago

betodealmeida commented 6 years ago

The DB API will stream the results from Druid, yielding data as soon as it's read from the network. In order to get the cursor description describing the results, the first row is read, the cursor is set, and the row is chained back to the results.

Unfortunately, this fails when there are no rows, raising a StopIteration exception. I changed the code to return an empty list instead. I also added two unit tests for the cursor, that can be expanded in the future.