openSqlQuery method

Future<DatasetSqlQuery> openSqlQuery({
  1. required String query,
  2. List<TableRef>? tables,
  3. ArrowTable? params,
  4. List<String>? namespace,
  5. String? branch,
})

Implementation

Future<DatasetSqlQuery> openSqlQuery({
  required String query,
  List<TableRef>? tables,
  ArrowTable? params,
  List<String>? namespace,
  String? branch,
}) async {
  final response = await _invokeContent(
    "open_sql_query",
    BinaryContent(
      data: params == null ? Uint8List(0) : ArrowIpcStreamWriter.fromTable(params).write(),
      headers: {
        "query": query,
        "tables": (tables ?? const <TableRef>[]).map((table) => table.toJson()).toList(growable: false),
        "namespace": namespace,
        "branch": branch,
      },
    ),
  );
  if (response is! BinaryContent) {
    throw RoomServerException("unexpected return type from datasets.open_sql_query call");
  }
  final queryId = response.headers["query_id"];
  if (queryId is! String || queryId.isEmpty) {
    throw RoomServerException("unexpected return type from datasets.open_sql_query call");
  }
  return DatasetSqlQuery(schema: ArrowIpcSchema(response.data).schema, queryId: queryId);
}