1616
1717package io .delta .kernel .defaults .benchmarks .models ;
1818
19+ import com .fasterxml .jackson .annotation .JsonIgnore ;
1920import com .fasterxml .jackson .annotation .JsonProperty ;
21+ import com .fasterxml .jackson .databind .ObjectMapper ;
2022import java .io .File ;
2123import java .io .IOException ;
22- import org . codehaus . jackson . map . ObjectMapper ;
24+ import java . nio . file . Paths ;
2325
2426/**
2527 * Represents metadata about a Delta table used in benchmark workloads.
3032 *
3133 * <p>TableInfo instances are typically loaded from JSON files in the workload specifications
3234 * directory structure. Each table directory should contain a {@code table_info.json} file with the
33- * table metadata and a {@code delta} subdirectory containing the actual table data. The table root
34- * path is the absolute path to the root of the table and is provided separately in {@link
35- * WorkloadSpec#fromJsonPath(String, String, TableInfo)}.
35+ * table metadata and a {@code delta} subdirectory containing the actual table data.
3636 *
37- * <p>Example JSON structure:
37+ * <p>Example JSON structure for relative table (default) :
3838 *
3939 * <pre>{@code
4040 * {
41- * "name": "large-table",
42- * "description": "A large Delta table with multi-part checkpoints for performance testing",
43- * "engineInfo": "Apache-Spark/3.5.1 Delta-Lake/3.1.0"
41+ * "name": "basic_table",
42+ * "description": "A basic Delta table for benchmarking",
43+ * "engine_info": "Apache-Spark/3.5.1 Delta-Lake/3.1.0"
44+ * }
45+ * }</pre>
46+ *
47+ * <p>Example JSON structure for absolute path table:
48+ *
49+ * <pre>{@code
50+ * {
51+ * "name": "s3_table",
52+ * "description": "Table stored in S3",
53+ * "table_type": "absolute",
54+ * "table_path": "s3://my-bucket/path/to/table"
4455 * }
4556 * }</pre>
4657 */
@@ -60,23 +71,28 @@ public class TableInfo {
6071 @ JsonProperty ("engine_info" )
6172 public String engineInfo ;
6273
63- /** The root path where the Delta table is stored. */
64- @ JsonProperty ("table_root" )
65- public String tableRoot ;
74+ /**
75+ * The type of table location: "relative" (default) or "absolute".
76+ *
77+ * <p>When "relative", the table is located at {table_info_directory}/delta. When "absolute", the
78+ * table is located at the path specified in {@link #tablePath}.
79+ */
80+ @ JsonProperty ("table_type" )
81+ private String tableType ;
6682
67- /** @return the absolute path to the root of the table */
68- public String getTableRoot () {
69- return tableRoot ;
70- }
83+ /**
84+ * The absolute path to the table when {@link #tableType} is "absolute". Can be a local path
85+ * (file:///) or S3 path (s3://). Null when table_type is "relative".
86+ */
87+ @ JsonProperty ("table_path" )
88+ private String tablePath ;
7189
7290 /**
73- * Sets the root path of the Delta table.
74- *
75- * @param tableRoot the absolute path to the root of the table
91+ * The resolved absolute path to the root of the table. This is computed after deserialization
92+ * based on {@link #tableType} and {@link #tablePath}.
7693 */
77- public void setTableRoot (String tableRoot ) {
78- this .tableRoot = tableRoot ;
79- }
94+ @ JsonProperty ("table_info_path" )
95+ private String tableInfoPath ;
8096
8197 /**
8298 * Default constructor for Jackson deserialization.
@@ -86,23 +102,47 @@ public void setTableRoot(String tableRoot) {
86102 */
87103 public TableInfo () {}
88104
105+ /** Resolves the table root path based on the table type and location configuration. */
106+ @ JsonIgnore
107+ public String getResolvedTableRoot () {
108+ if ("absolute" .equals (tableType )) {
109+ if (tablePath == null || tablePath .trim ().isEmpty ()) {
110+ throw new IllegalStateException (
111+ "table_path must be specified when table_type is 'absolute'" );
112+ }
113+ return tablePath ;
114+ } else {
115+ // Default to "relative" if tableType is null or "relative"
116+ return Paths .get (tableInfoPath , "delta" ).toAbsolutePath ().toString ();
117+ }
118+ }
119+
120+ public String getTableInfoPath () {
121+ return tableInfoPath ;
122+ }
123+
124+ public void setTableInfoPath (String tableInfoDirectory ) {
125+ this .tableInfoPath = tableInfoDirectory ;
126+ }
127+
89128 /**
90129 * Creates a TableInfo instance by reading from a JSON file at the specified path.
91130 *
92- * <p>This method loads table metadata from a JSON file and sets the table root path. The JSON
93- * file should contain the table name and description, while the table root path is provided
94- * separately with the absolute path .
131+ * <p>This method loads table metadata from a JSON file and resolves the table root path. The JSON
132+ * file should contain the table name and description, while the table root path is computed based
133+ * on the table_type and table_path fields .
95134 *
96135 * @param jsonPath the path to the JSON file containing the TableInfo metadata
97- * @param tableRoot the absolute path to the root of the Delta table
98- * @return a TableInfo instance populated from the JSON file and table root path
136+ * @param tableInfoPath the directory containing the table_info.json file (used for relative path
137+ * resolution)
138+ * @return a TableInfo instance populated from the JSON file with resolved table root path
99139 * @throws RuntimeException if there is an error reading or parsing the JSON file
100140 */
101- public static TableInfo fromJsonPath (String jsonPath , String tableRoot ) {
141+ public static TableInfo fromJsonPath (String jsonPath , String tableInfoPath ) {
102142 ObjectMapper mapper = new ObjectMapper ();
103143 try {
104144 TableInfo info = mapper .readValue (new File (jsonPath ), TableInfo .class );
105- info .setTableRoot ( tableRoot );
145+ info .setTableInfoPath ( tableInfoPath );
106146 return info ;
107147 } catch (IOException e ) {
108148 throw new RuntimeException ("Failed to read TableInfo from JSON file: " + jsonPath , e );
@@ -112,8 +152,8 @@ public static TableInfo fromJsonPath(String jsonPath, String tableRoot) {
112152 /**
113153 * Returns a string representation of this TableInfo.
114154 *
115- * <p>The string includes the table name, description, and engine info, but excludes the table
116- * root path for security reasons (as it may contain sensitive path information).
155+ * <p>The string includes the table name, description, engine info, and CCv2 status, but excludes
156+ * the table root path for security reasons (as it may contain sensitive path information).
117157 *
118158 * @return a string representation of this TableInfo
119159 */
@@ -125,6 +165,8 @@ public String toString() {
125165 + description
126166 + "', engineInfo='"
127167 + engineInfo
128- + "'}" ;
168+ + "', tableType='"
169+ + tableType
170+ + "}" ;
129171 }
130172}
0 commit comments