syntax = "proto3";

package raysql.protobuf;

option java_multiple_files = true;
option java_package = "raysql.protobuf";
option java_outer_classname = "RaySqlProto";

import "datafusion.proto";

message RaySqlExecNode {
  oneof PlanType {
    ShuffleReaderExecNode shuffle_reader = 1;
    ShuffleWriterExecNode shuffle_writer = 2;
    RayShuffleReaderExecNode ray_shuffle_reader = 3;
    RayShuffleWriterExecNode ray_shuffle_writer = 4;
  }
}

message ShuffleReaderExecNode {
  // stage to read from
  uint32 stage_id = 1;
  // schema of the shuffle stage
  datafusion.Schema schema = 2;
  // this must match the output partitioning of the writer we are reading from
  datafusion.PhysicalHashRepartition partitioning = 3;
  // directory for shuffle files
  string shuffle_dir = 4;
}

message ShuffleWriterExecNode {
  // stage that is writing the shuffle files
  uint32 stage_id = 1;
  // plan to execute
  datafusion.PhysicalPlanNode plan = 2;
  // output partitioning schema
  datafusion.PhysicalHashRepartition partitioning = 3;
  // directory for shuffle files
  string shuffle_dir = 4;
}

message RayShuffleReaderExecNode {
  // stage to read from
  uint32 stage_id = 1;
  // schema of the shuffle stage
  datafusion.Schema schema = 2;
  // this must match the output partitioning of the writer we are reading from
  datafusion.PhysicalHashRepartition partitioning = 3;
}

message RayShuffleWriterExecNode {
  // stage that is writing the shuffle files
  uint32 stage_id = 1;
  // plan to execute
  datafusion.PhysicalPlanNode plan = 2;
  // output partitioning schema
  datafusion.PhysicalHashRepartition partitioning = 3;
}
