Skip to content

Instantly share code, notes, and snippets.

View julianhyde's full-sized avatar

Julian Hyde julianhyde

View GitHub Profile
@julianhyde
julianhyde / scott-big-query-cte
Created November 10, 2023 02:03
Query that uses the "SCOTT" schema (tables EMP, DEPT, BONUS, SALGRADE, DUMMY) as CTEs, in BigQuery SQL
with dummy as (
select 0 as dummy
), dept AS (
select 10 as deptno, 'ACCOUNTING' as dname, 'NEW YORK' as loc union all
select 20, 'RESEARCH', 'DALLAS' union all
select 30, 'SALES', 'CHICAGO' union all
select 40, 'OPERATIONS', 'BOSTON'
), emp AS (
select 7839 as empno, 'KING' as ename, 'PRESIDENT' AS JOB, null AS mgr, date '1981-11-17' as hiredate, 5000 as sal, null as comm, 10 as deptno union all
select 7698, 'BLAKE', 'MANAGER', 7839, '1981-05-01', 2850, null, 30 union all
@julianhyde
julianhyde / gist:9ca5915bfb91494b7f91405ad15d698e
Created December 3, 2021 01:21
Comparing the dependencies of Apache Calcite releases
# An example of using bash commands to track dependency changes in Apache Calcite.
# This example compares Calcite 1.27 with 1.28.
git checkout calcite-1.27.0
./gradlew dependencies > /tmp/d27.txt
git checkout calcite-1.28.0
./gradlew dependencies > /tmp/d28.txt
diff -y /tmp/d27.txt /tmp/d28.txt | expand
...
@julianhyde
julianhyde / git-rename-local-master-to-main.sh
Created October 29, 2021 18:38
How to fix a GitHub clone after the remote 'master' branch has been renamed to 'main'
# (Instructions are based on the "What Your Teammates Have to Do" section
# in https://www.git-tower.com/learn/git/faq/git-rename-master-to-main.)
# Switch to the "master" branch:
$ git checkout master
# Rename it to "main":
$ git branch -m master main
# Get the latest commits (and branches!) from the remote:
@julianhyde
julianhyde / scott-sql-fiddle-mssql.sql
Created September 10, 2021 00:05
Script to create the "SCOTT" schema (tables EMP, DEPT, BONUS, SALGRADE, DUMMY), in a format suitable for pasting into SQL Fiddle for Microsoft SQL Server
-- Script to create Oracle's "SCOTT" schema with tables
-- EMP, DEPT, BONUS, SALGRADE, DUMMY. Originally Oracle's demobld.sql.
--
-- In a format suitable for pasting into SQL Fiddle for Microsoft SQL Server:
-- http://sqlfiddle.com/#!18
begin transaction;
create table dept(
deptno decimal(2,0) not null,
dname varchar(14),
loc varchar(13));
@julianhyde
julianhyde / scott-big-query.sql
Created April 23, 2021 02:00
Script to create, in Google BigQuery, Oracle's "SCOTT" schema (tables EMP, DEPT, BONUS, SALGRADE, DUMMY), in a format suitable for pasting into Cloud Console
-- Script to create, in Google BigQuery,
-- Oracle's "SCOTT" schema with tables
-- EMP, DEPT, BONUS, SALGRADE, DUMMY.
--
-- In a format suitable for pasting into Cloud Console.
-- Before you run this script, create a dataset called 'Scott' in your current project.
--
drop table if exists scott.dept;
drop table if exists scott.emp;
drop table if exists scott.bonus;
@julianhyde
julianhyde / scott-sql-fiddle-postgresql.sql
Created November 2, 2020 06:52
Script to create the "SCOTT" schema (tables EMP, DEPT, BONUS, SALGRADE, DUMMY), in a format suitable for pasting into SQL Fiddle for PostgreSQL
-- Script to create Oracle's "SCOTT" schema with tables
-- EMP, DEPT, BONUS, SALGRADE, DUMMY. Originally Oracle's demobld.sql.
--
-- In a format suitable for pasting into SQL Fiddle for PostgreSQL:
-- http://sqlfiddle.com/#!17
create table dept(
deptno decimal(2,0) not null,
dname varchar(14),
loc varchar(13));
create table emp(
@julianhyde
julianhyde / scott-sql-fiddle.sql
Last active April 2, 2024 23:56
Script to create Oracle's "SCOTT" schema (tables EMP, DEPT, BONUS, SALGRADE, DUMMY), in a format suitable for pasting into SQL Fiddle
-- Script to create Oracle's "SCOTT" schema with tables
-- EMP, DEPT, BONUS, SALGRADE, DUMMY. Originally demobld.sql.
--
-- In a format suitable for pasting into SQL Fiddle:
-- http://sqlfiddle.com/#!4
--
create table dept(
deptno number(2,0) not null,
dname varchar2(14),
loc varchar2(13));
@julianhyde
julianhyde / scott.sql
Last active November 15, 2023 09:35
Script to create Oracle's "SCOTT" schema (EMP, DEPT, BONUS, SALGRADE, DUMMY tables) in a format suitable for pasting into RexTester
-- Script to create Oracle's "SCOTT" schema with tables
-- EMP, DEPT, BONUS, SALGRADE, DUMMY. Originally demobld.sql.
--
-- In a format suitable for pasting into RexTester:
-- https://rextester.com/l/oracle_online_compiler
--
drop table dept
\\
drop table emp
\\
@julianhyde
julianhyde / Optiq-generated.java
Created April 21, 2014 18:18
Invalid java code generated by Optiq for TPC-H query 14
public static class Record4_0 implements java.io.Serializable {
public Double f0;
public long f1;
public Double f2;
public long f3;
public Record4_0(Double f0, long f1, Double f2, long f3) {
this.f0 = f0;
this.f1 = f1;
this.f2 = f2;
this.f3 = f3;
@julianhyde
julianhyde / CaseInsensitiveMapVersusListBenchmark.java
Created November 21, 2013 18:23
Benchmark that measures alternative implementations of a map with case-insensitive string keys. The first implementation is a hash-map whose keys are converted to upper-case. The second implementation is a list whose entries are compared using String.equalsIgnoreCase. The two interesting variables are n (the number of elements in the collection)…
/**
* Benchmark that measures alternative implementations of a map with case-insensitive
* string keys. The first implementation is a hash-map whose keys are converted to
* upper-case. The second implementation is a list whose entries are compared using
* String.equalsIgnoreCase.
*
* <p>The two interesting variables are n (the number of elements in the collection)
* and name(int x) (the function that generates the list of entries).
*
* <p>We access each element of the collection once, because that will be typical for