import { ReadableStream } from 'readable-stream' ; import { Timezone } from "chronoshift" ; import { Expression , Datum , RefExpression , PlywoodValue , SQLParse } from "plywood" ; function upperCaseRefs ( expression ) { return expression . substitute ( ( ex ) => { if ( ex instanceof RefExpression ) { let v = ex . valueOf ( ) ; v . name = v . name . toUpperCase ( ) ; return new RefExpression ( v ) ; } return null ; } ) ; } export function executeSQLParse ( sqlParse , context , timezone ) { let { expression , database } = sqlParse ; if ( database && database . toLowerCase ( ) === 'information_schema' ) { expression = upperCaseRefs ( expression ) ; } return expression . compute ( context , { timezone } ) ; } export function executeSQLParseStream ( sqlParse , context , timezone ) { let { expression , database } = sqlParse ; if ( database && database . toLowerCase ( ) === 'information_schema' ) { expression = upperCaseRefs ( expression ) ; } return expression . computeStream ( context , { timezone } ) ; } export function executePlywood ( expression , context , timezone ) { return expression . compute ( context , { timezone } ) ; }