If early limit 0 optimization is set to true (alter session set `planner.enable_limit0_optimization` = true), when executing limit 0 queries Drill will return data type from available metadata if possible.
When Drill can not determine data types from metadata (or if early limit 0 optimization is set to false), Drill will read first batch of data and determine schema.
Hbase reader determines max batch size using magic number (4000) which can lead to OOM when row size is large. The overall vector/batch size issue will be reconsidered in future releases.This is temporary fix to avoid OOM.
To limit memory usage for Hbase reader we are adding max allowed allocated memory contant which will default to 64 mb. Thus batch size will be limited to 4000 (as before if memory limit does not exceed) or to number of records that are within max allowed memory limit. If first row in batch is larger than allowed default, it will be written in batch but batch will contain only this row.