Skip to content

Instantly share code, notes, and snippets.

@tom-clickhouse
Created January 8, 2024 11:46
Show Gist options
  • Save tom-clickhouse/359b40dd6368f57e5e5c633f6a5710d8 to your computer and use it in GitHub Desktop.
Save tom-clickhouse/359b40dd6368f57e5e5c633f6a5710d8 to your computer and use it in GitHub Desktop.
data insert
INSERT INTO uk_property_offers
WITH
splitByChar(' ', postcode) AS p
SELECT
toUInt32(price_string) AS price,
parseDateTimeBestEffortUS(time) AS date,
p[1] AS postcode1,
p[2] AS postcode2,
transform(a, ['T', 'S', 'D', 'F', 'O'], ['terraced', 'semi-detached', 'detached', 'flat', 'other']) AS type,
b = 'Y' AS is_new,
transform(c, ['F', 'L', 'U'], ['freehold', 'leasehold', 'unknown']) AS duration,
addr1,
addr2,
street,
locality,
town,
district,
county
FROM url(
'http://prod.publicdata.landregistry.gov.uk.s3-website-eu-west-1.amazonaws.com/pp-complete.csv',
'CSV',
'uuid_string String,
price_string String,
time String,
postcode String,
a String,
b String,
c String,
addr1 String,
addr2 String,
street String,
locality String,
town String,
district String,
county String,
d String,
e String'
) SETTINGS max_http_get_redirects=10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment