Skip to content

Instantly share code, notes, and snippets.

View dbergqvist's full-sized avatar

Daniel Bergqvist dbergqvist

View GitHub Profile

Keybase proof

I hereby claim:

  • I am dbergqvist on github.
  • I am dbergqvist (https://keybase.io/dbergqvist) on keybase.
  • I have a public key ASDGRX2WPSuLLFY44_7FvgP9TwE4NRUZ4o3wBiB8GfVeVwo

To claim this, I am signing this object:

SELECT
AVG(s.totalSale)
OVER (ORDER BY orderDay
ROWS BETWEEN 7 PRECEDING AND CURRENT ROW) as runningAverage,
p.name as productName,
s.orderDay as orderDay,
FROM (
SELECT SUM(salesOrderLines.totalSale) as totalSale,
DATE(orderDate) as orderDay, salesOrderLines.productKey as productKey
FROM [google.com:bigquery-petabyte:retail_petabyte.sales_partitioned]
private static final byte[] COLUMN_FAMILY_NAME = Bytes.toBytes("cf");
private static final byte[] LAT_COLUMN_NAME = Bytes.toBytes("VehicleLocation.Latitude");
private static final byte[] LONG_COLUMN_NAME = Bytes.toBytes("VehicleLocation.Longitude");
String rowKey = "MTA/M86-SBS/1496275200000/NYCT_5824";
Result getResult =
table.get(
new Get(Bytes.toBytes(rowKey))
.addColumn(COLUMN_FAMILY_NAME, LAT_COLUMN_NAME)
.addColumn(COLUMN_FAMILY_NAME, LONG_COLUMN_NAME));
Result getResult =
table.get(
new Get(Bytes.toBytes(rowKey))
.setMaxVersions(Integer.MAX_VALUE)
.addColumn(COLUMN_FAMILY_NAME, LAT_COLUMN_NAME)
.addColumn(COLUMN_FAMILY_NAME, LONG_COLUMN_NAME));
private static final String COLUMN_FAMILY_NAME_STRING = "cf";
private static final String LAT_COLUMN_NAME_STRING = "VehicleLocation.Latitude";
private static final String LONG_COLUMN_NAME_STRING = "VehicleLocation.Longitude";
String rowKey = "MTA/M86-SBS/1496275200000/NYCT_5824";
Row row = dataClient.readRow(TABLE_ID, rowKey,
FILTERS.interleave()
.filter(FILTERS.qualifier().exactMatch(LAT_COLUMN_NAME_STRING))
.filter(FILTERS.qualifier().exactMatch(LONG_COLUMN_NAME_STRING)));
Scan scan;
scan = new Scan();
scan.setMaxVersions(Integer.MAX_VALUE)
.addColumn(COLUMN_FAMILY_NAME, LAT_COLUMN_NAME)
.addColumn(COLUMN_FAMILY_NAME, LONG_COLUMN_NAME)
.withStartRow(Bytes.toBytes("MTA/M86-SBS/1496275200000"))
.setRowPrefixFilter(Bytes.toBytes("MTA/M86-SBS/1496275200000"));
ResultScanner scanner = table.getScanner(scan);
Query query = Query.create(TABLE_ID)
.prefix("MTA/M86-SBS/1496275200000")
.filter(FILTERS
.interleave()
.filter(FILTERS.qualifier().exactMatch(LAT_COLUMN_NAME_STRING))
.filter(FILTERS.qualifier().exactMatch(LONG_COLUMN_NAME_STRING)));
ServerStream<Row> rows = dataClient.readRows(query);
scan.withStartRow(Bytes.toBytes("MTA/M86-SBS/"))
.setRowPrefixFilter(Bytes.toBytes("MTA/M86-SBS/"));
//Optionally, reduce the result to receive one version per column
scan.setMaxVersions(1);
Query.create(TABLE_ID)
.prefix("MTA/M86-SBS/")
.filter(FILTERS.limit().cellsPerColumn(1))
Scan scan = new Scan();
SingleColumnValueFilter valueFilter =
new SingleColumnValueFilter(
COLUMN_FAMILY_NAME,
Bytes.toBytes("DestinationName"),
CompareOp.EQUAL,
Bytes.toBytes("Select Bus Service Yorkville East End AV"));
scan.setMaxVersions(1)