I have a presto logical execution plan, and I want to extract all the table and its fields used from it. Is there any way to do this?
Thanks for your help.
<code>Fragment 0 [SINGLE]
Output layout: [sum]
Output partitioning: SINGLE []
Stage Execution Strategy: UNGROUPED_EXECUTION
Output[employee_summary_employee_stock_yearly]
│ Layout: [sum:double]
│ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: ?}
│ employee_summary_employee_stock_yearly := sum
└─ Aggregate(FINAL)
│ Layout: [sum:double]
│ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: ?}
│ sum := sum("sum_0")
└─ LocalExchange[SINGLE] ()
│ Layout: [sum_0:row(bigint, boolean, double, boolean)]
│ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: ?}
└─ RemoteSource[1]
Layout: [sum_0:row(bigint, boolean, double, boolean)]
Fragment 1 [SOURCE]
Output layout: [sum_0]
Output partitioning: SINGLE []
Stage Execution Strategy: UNGROUPED_EXECUTION
Aggregate(PARTIAL)
│ Layout: [sum_0:row(bigint, boolean, double, boolean)]
│ sum_0 := sum("double_test")
└─ ScanFilterProject[table = hive:ads_test:number_test_1d_f, grouped = false, filterPredicate = (CAST("int_test" AS varchar) = CAST('1' AS varchar))]
Layout: [double_test:double]
Estimates: {rows: ? (?), cpu: ?, memory: 0B, network: 0B}/{rows: ? (?), cpu: ?, memory: 0B, network: 0B}/{rows: ? (?), cpu: ?, memory: 0B, network: 0B}
double_test := double_test:double:REGULAR
int_test := int_test:int:REGULAR
datetime:string:PARTITION_KEY
:: [[20240505]]
</code>
<code>Fragment 0 [SINGLE]
Output layout: [sum]
Output partitioning: SINGLE []
Stage Execution Strategy: UNGROUPED_EXECUTION
Output[employee_summary_employee_stock_yearly]
│ Layout: [sum:double]
│ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: ?}
│ employee_summary_employee_stock_yearly := sum
└─ Aggregate(FINAL)
│ Layout: [sum:double]
│ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: ?}
│ sum := sum("sum_0")
└─ LocalExchange[SINGLE] ()
│ Layout: [sum_0:row(bigint, boolean, double, boolean)]
│ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: ?}
└─ RemoteSource[1]
Layout: [sum_0:row(bigint, boolean, double, boolean)]
Fragment 1 [SOURCE]
Output layout: [sum_0]
Output partitioning: SINGLE []
Stage Execution Strategy: UNGROUPED_EXECUTION
Aggregate(PARTIAL)
│ Layout: [sum_0:row(bigint, boolean, double, boolean)]
│ sum_0 := sum("double_test")
└─ ScanFilterProject[table = hive:ads_test:number_test_1d_f, grouped = false, filterPredicate = (CAST("int_test" AS varchar) = CAST('1' AS varchar))]
Layout: [double_test:double]
Estimates: {rows: ? (?), cpu: ?, memory: 0B, network: 0B}/{rows: ? (?), cpu: ?, memory: 0B, network: 0B}/{rows: ? (?), cpu: ?, memory: 0B, network: 0B}
double_test := double_test:double:REGULAR
int_test := int_test:int:REGULAR
datetime:string:PARTITION_KEY
:: [[20240505]]
</code>
Fragment 0 [SINGLE]
Output layout: [sum]
Output partitioning: SINGLE []
Stage Execution Strategy: UNGROUPED_EXECUTION
Output[employee_summary_employee_stock_yearly]
│ Layout: [sum:double]
│ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: ?}
│ employee_summary_employee_stock_yearly := sum
└─ Aggregate(FINAL)
│ Layout: [sum:double]
│ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: ?}
│ sum := sum("sum_0")
└─ LocalExchange[SINGLE] ()
│ Layout: [sum_0:row(bigint, boolean, double, boolean)]
│ Estimates: {rows: ? (?), cpu: ?, memory: ?, network: ?}
└─ RemoteSource[1]
Layout: [sum_0:row(bigint, boolean, double, boolean)]
Fragment 1 [SOURCE]
Output layout: [sum_0]
Output partitioning: SINGLE []
Stage Execution Strategy: UNGROUPED_EXECUTION
Aggregate(PARTIAL)
│ Layout: [sum_0:row(bigint, boolean, double, boolean)]
│ sum_0 := sum("double_test")
└─ ScanFilterProject[table = hive:ads_test:number_test_1d_f, grouped = false, filterPredicate = (CAST("int_test" AS varchar) = CAST('1' AS varchar))]
Layout: [double_test:double]
Estimates: {rows: ? (?), cpu: ?, memory: 0B, network: 0B}/{rows: ? (?), cpu: ?, memory: 0B, network: 0B}/{rows: ? (?), cpu: ?, memory: 0B, network: 0B}
double_test := double_test:double:REGULAR
int_test := int_test:int:REGULAR
datetime:string:PARTITION_KEY
:: [[20240505]]
I can see all the fields in the bottom of logical plan. But the text version is hard for Java App to process.
New contributor
Luke Tang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.