Rewrite and test basic query functionality. Includes query end statements: Run, Scan, Count, and IdsOnly, but no query modifiers yet.