@@ -23,6 +23,16 @@ export function isDatabaseClient(value, mode) {
2323  ) ; 
2424} 
2525
26+ // Returns true if the vaue is an Apache Arrow table. 
27+ export  function  isArrowTable ( value )  { 
28+   return  ( 
29+     value  && 
30+     value . schema  && 
31+     Array . isArray ( value . schema . fields )  && 
32+     typeof  value [ Symbol . iterator ]  ===  "function" 
33+   ) ; 
34+ } 
35+ 
2636// Returns true if the value is a typed array (for a single-column table), or if 
2737// it’s an array. In the latter case, the elements of the array must be 
2838// consistently typed: either plain objects or primitives or dates. 
@@ -145,6 +155,7 @@ export const __query = Object.assign(
145155    source  =  await  loadDataSource ( await  source ,  "table" ) ; 
146156    if  ( isDatabaseClient ( source ) )  return  evaluateQuery ( source ,  makeQueryTemplate ( operations ,  source ) ,  invalidation ) ; 
147157    if  ( isDataArray ( source ) )  return  __table ( source ,  operations ) ; 
158+     if  ( isArrowTable ( source ) )  return  __arrow ( source ,  operations ) ; 
148159    if  ( ! source )  throw  new  Error ( "missing data source" ) ; 
149160    throw  new  Error ( "invalid data source" ) ; 
150161  } , 
@@ -164,7 +175,7 @@ export async function loadDataSource(source, mode) {
164175        case  "text/csv" : return  source . csv ( { typed : true } ) ; 
165176        case  "text/tab-separated-values" : return  source . tsv ( { typed : true } ) ; 
166177        case  "application/json" : return  source . json ( ) ; 
167-         default : if  ( / \. a r r o w $ / i. test ( source . name ) )  return  source . arrow ( ) ;   // TODO apache-arrow@10 
178+         default : if  ( / \. a r r o w $ / i. test ( source . name ) )  return  source . arrow ( { version :  10 } ) ; 
168179      } 
169180    } 
170181    if  ( mode  ===  "table"  ||  mode  ===  "sql" )  { 
@@ -391,9 +402,16 @@ function likeOperand(operand) {
391402  return  { ...operand ,  value : `%${ operand . value }  } ; 
392403} 
393404
405+ // This function applies table cell operations to an in-memory Apache Arrow 
406+ // table; it should be equivalent to the corresponding SQL query. 
407+ function  __arrow ( source ,  operations )  { 
408+   operations ; 
409+   return  source ;  // TODO 
410+ } 
411+ 
394412// This function applies table cell operations to an in-memory table (array of 
395413// objects); it should be equivalent to the corresponding SQL query. 
396- export   function  __table ( source ,  operations )  { 
414+ function  __table ( source ,  operations )  { 
397415  const  input  =  source ; 
398416  let  { schema,  columns}  =  source ; 
399417  let  primitive  =  arrayIsPrimitive ( source ) ; 
0 commit comments