syntax = "proto3";
package pretransform;

import "tasks.proto";

/// Pre transform spec messages
message PreTransformSpecOpts {
  optional uint32 row_limit = 1;
  repeated PreTransformInlineDataset inline_datasets = 2;
  bool preserve_interactivity = 3;
}

message PreTransformSpecRequest {
  string spec = 1;
  string local_tz = 2;
  optional string output_tz = 3;
  PreTransformSpecOpts opts = 4;
}

message PreTransformSpecResponse {
  string spec = 1;
  repeated PreTransformSpecWarning warnings = 2;
}

message PreTransformSpecWarning {
  oneof warning_type {
    PreTransformRowLimitWarning row_limit = 1;
    PreTransformBrokenInteractivityWarning broken_interactivity = 2;
    PreTransformUnsupportedWarning unsupported = 3;
    PlannerWarning planner = 4;
  }
}

message PreTransformRowLimitWarning {
  repeated tasks.Variable datasets = 1;
}

message PreTransformBrokenInteractivityWarning {
  repeated tasks.Variable vars = 1;
}

message PreTransformUnsupportedWarning {}

/// Pre transform value messages
message PreTransformVariable {
  tasks.Variable variable = 1;
  repeated uint32 scope = 2;
}

message PreTransformValuesOpts {
  repeated PreTransformVariable variables = 1;
  repeated PreTransformInlineDataset inline_datasets = 2;
  optional uint32 row_limit = 3;
}

message PreTransformValuesRequest {
  string spec = 1;
  string local_tz = 2;
  optional string default_input_tz = 3;
  PreTransformValuesOpts opts = 4;
}

message PreTransformValuesResponse {
  repeated tasks.ResponseTaskValue values = 1;
  repeated PreTransformValuesWarning warnings = 2;
}

message PreTransformValuesWarning {
  oneof warning_type {
    PreTransformRowLimitWarning row_limit = 1;
    PlannerWarning planner = 2;
  }
}

/// Common pre-transform messages
message PreTransformInlineDataset {
  // Inline dataset name
  string name = 1;
  // Serialized Arrow record batch in Arrow IPC format
  bytes table = 2;
}

message PlannerWarning {
  string message = 1;
}

/// Pre Transform Extract Datasets
message PreTransformExtractDataset {
  // Result dataset name
  string name = 1;

  // Result dataset scope
  repeated uint32 scope = 2;

  // Serialized Arrow record batch in Arrow IPC format
  bytes table = 3;
}

message PreTransformExtractWarning {
  oneof warning_type {
    PlannerWarning planner = 1;
  }
}

message PreTransformExtractResponse {
  string spec = 1;
  repeated PreTransformExtractDataset datasets = 2;
  repeated PreTransformExtractWarning warnings = 3;
}

message PreTransformExtractRequest {
  string spec = 1;
  string local_tz = 2;
  optional string default_input_tz = 3;
  bool preserve_interactivity = 4;
  repeated PreTransformInlineDataset inline_datasets = 5;
}