Skip to content

Instantly share code, notes, and snippets.

@campoy
Created April 12, 2018 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save campoy/20f00b94cafa81f27e85a169b8513be0 to your computer and use it in GitHub Desktop.
Save campoy/20f00b94cafa81f27e85a169b8513be0 to your computer and use it in GitHub Desktop.
function intdiv(row, emit) {
emit({ d: row.x / row.y, m: row.x % row.y });
}
bigquery.defineFunction(
'intdiv',
['x', 'y'],
[{ 'name': 'd', 'type': 'integer' },
{ 'name': 'm', 'type': 'integer' }],
intdiv
);
SELECT d, m FROM intdiv(
SELECT 21 as x, 4 as y
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment