Build schema from data and fix for array field query