This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Reads the manifest file and creates a schema and table for each parquet file in the manifest. | |
* It will create a DB called `local.duckdb` in the root of the project. | |
* | |
* Usage: | |
* 1. Copy this file to the root of your project Evidence project. | |
* 2. `npm run sources` | |
* 3. `node createLocalDuckDB.js` | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
regr_slope(num_orders, sales) AS slope, | |
regr_intercept(num_orders, sales) AS intercept, | |
regr_r2(num_orders, sales) AS r_squared | |
FROM orders_by_state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALL 'icu'; | |
LOAD 'icu'; | |
SET TimeZone = 'Europe/Berlin'; | |
create or replace table metrics as SELECT TIMESTAMP '2024-06-07 00:00:00' AS mytimestamp, TIMESTAMP WITH TIME ZONE '2024-06-07 00:00:00+02' AS mytimestamptz, 1000 AS sales, 50 AS orders, 20 AS customers; | |
-- Check the stored timestamps to ensure they match Berlin time | |
SELECT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with cleaned_docs as ( | |
select | |
tweet_id, | |
regexp_replace(regexp_replace(text, '\\n', ' ', 'g'), 'https[^\\s]+', '', 'g') as cleaned_text | |
from tweets | |
where text is not null | |
), | |
tokenized_docs as ( | |
select |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
date, | |
contractname as candidate, | |
substring(closeshareprice,2,10)::double as implied_probability | |
from read_csv('https://www.predictit.org/Resource/DownloadMarketChartData?marketid=7456') | |
order by date desc, implied_probability desc | |
limit 8 |