executeSql method
Implementation
Future<DatasetSqlExecution> executeSql({
required String query,
List<TableRef>? tables,
ArrowTable? params,
List<String>? namespace,
String? branch,
}) async {
final response = await _invokeContent(
"execute_sql",
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) {
if (response.headers["kind"] != "query") {
throw RoomServerException("unexpected return type from datasets.execute_sql call");
}
final queryId = response.headers["query_id"];
if (queryId is! String || queryId.isEmpty) {
throw RoomServerException("unexpected return type from datasets.execute_sql call");
}
return DatasetSqlQuery(schema: ArrowIpcSchema(response.data).schema, queryId: queryId);
}
if (response is JsonContent) {
if (response.json["kind"] != "statement") {
throw RoomServerException("unexpected return type from datasets.execute_sql call");
}
final rowsAffected = response.json["rows_affected"];
if (rowsAffected is! int) {
throw RoomServerException("unexpected return type from datasets.execute_sql call");
}
return DatasetSqlStatement(rowsAffected: rowsAffected);
}
throw RoomServerException("unexpected return type from datasets.execute_sql call");
}