Query editor
-- Query to retrieve geo data (type=7) for all FIDs from caster credibility score-- Only includes FIDs that actually have geo data and creates a simple location hash-- Filters by rounded longitude and latitude using {{lon}} and {{lat}} parameters-- Includes username_link from ccs tableWITH geo_parsed AS (SELECTccs.fid,ccs.username_link,ud.type,ud.value AS original_geo_data,-- Extract latitude and longitude from geo:lat,lon formatCAST(SPLIT_PART(REPLACE(ud.value, 'geo:', ''), ',', 1) AS DOUBLE) AS latitude,CAST(SPLIT_PART(REPLACE(ud.value, 'geo:', ''), ',', 2) AS DOUBLE) AS longitude,ud.timestamp,ud.hashFROM dune.nhejyht.result_caster_credibility_score_ccs ccsINNER JOIN dune.neynar.dataset_farcaster_user_data udON ccs.fid = ud.fidWHERE ud.type = 7 -- Only geo data (type=7)AND ud.value LIKE 'geo:%' -- Ensure it's in the expected format)SELECTfid,type,'Geo Location' AS data_type_description,username_link,original_geo_data,latitude,longitude,-- Rounded latitude and longitude as separate numeric columns (whole degrees)ROUND(latitude, 0) AS rounded_lat,ROUND(longitude, 0) AS rounded_long,-- Create a simple coordinate-based hash (alternative to geohash)-- This creates a grid-based identifier using whole degreesCONCAT(CAST(FLOOR(latitude) AS VARCHAR), '_',CAST(FLOOR(longitude) AS VARCHAR)) AS location_grid_id,-- Create a rounded coordinate string for grouping nearby locations (whole degrees)CONCAT(CAST(ROUND(latitude, 0) AS VARCHAR), ',',CAST(ROUND(longitude, 0) AS VARCHAR)) AS rounded_coordinates,timestamp,hashFROM geo_parsedWHERE 1=1-- Filter by rounded longitude (use {{lon}} parameter)AND ('{{lon}}' = '' OR {{lon}} IS NULL OR ROUND(longitude, 0) = {{lon}})-- Filter by rounded latitude (use {{lat}} parameter)AND ('{{lat}}' = '' OR {{lat}} IS NULL OR ROUND(latitude, 0) = {{lat}})ORDER BY fid ASC, timestamp DESC;