VARCHAR represents variable-length character strings. In data workflows, it provides a safe landing type when source values are inconsistent or automatic type detection cannot classify them reliably. section 5.6 section 5.2.1
Use VARCHAR when:
- Importing SQLite columns whose observed values conflict with declared types. section 5.6
- Preserving CSV values that cannot be cast to BOOLEAN, BIGINT, DOUBLE, TIME, DATE, or TIMESTAMP. section 5.2.1
- Delaying interpretation until values can be explicitly cast to their intended types. section 5.6
Normalize an imported SQLite view
Set sqlite_all_varchar to true, then redefine the Player view from sqlite_scan. Keep source values as VARCHAR and explicitly cast identifiers to BIGINT, birthday to DATE, and measurements to FLOAT. Querying the revised view returns usable int64, date, and float columns. section 5.6
USE main;
CREATE OR REPLACE VIEW Player AS
FROM sqlite_scan('database.sqlite', 'Player')
SELECT * REPLACE (
id :: BIGINT AS id,
player_api_id :: BIGINT AS player_api_id,
player_fifa_api_id :: BIGINT AS player_fifa_api_id,
birthday :: DATE AS birthday,
height :: FLOAT AS height,
weight :: FLOAT AS weight
);
Inspect the complete CREATE OR REPLACE VIEW statement for the VARCHAR-first import and explicit recasting workflow. section 5.6



