Hi,
I'm trying to make a file that gives me useful information. Format of file is below:-
--- (Tue Apr 14 09:46:43 EDT 2020): JOIN_Constraints_Schema:test_simple_joins -------------
internal optimizer errors: 0
--- (Tue Apr 14 09:48:10 EDT 2020): JOIN_Constraints_Schema:test_constraint_joins_setop_dis_oby_lmt -------------
Number of queries that causes internal optimizer errors: 0
--- (Tue Apr 14 09:49:02 EDT 2020): in External_Table_Schema:test_subquery_in_from ---------------
--- (Tue Apr 14 09:49:10 EDT 2020): EventSeries_Schema:test_Event_Series1 -------------
--- (Tue Apr 14 09:49:17 EDT 2020): Gosalesdw_Schema:test_complex_analytics -------------
--- (Tue Apr 14 09:49:25 EDT 2020): GBY_Schema1:test_Groupby_Rollup -------------
internal optimizer errors: 0
--- (Tue Apr 14 09:49:40 EDT 2020): GBY_Schema1:test_Groupby_GroupingSets -------------
internal optimizer errors: 0
--- (Tue Apr 14 09:49:52 EDT 2020): GBY_Schema1:test_Groupby_Cube -------------
internal optimizer errors: 0
--- (Tue Apr 14 09:50:05 EDT 2020): GBY_Schema1:test_gby -------------
internal optimizer errors: 0
I need to extract the text after the timestamp and immediately next line error number having internal optimizer error.
It should be like - newout.txt
JOIN_Constraints_Schema,test_simple_joins,0
JOIN_Constraints_Schema,test_constraint_joins_setop_dis_oby_lmt,0
GBY_Schema1,test_Groupby_Rollup,0
GBY_Schema1,test_Groupby_GroupingSets,0
GBY_Schema1,test_Groupby_Cube,0
GBY_Schema1,test_gby,0
Exception - If there is no internal optimizer error attached to any field given in timestamp then no need to print
I tried using a simple script but not works for me
cat newout.txt | while read x
do
if [ $(echo $x | grep -E '20[0-9][0-9]\):' | wc -l) == 1 ]
then
schema=$(echo $x | awk '{print $(NF-1)}' | awk -F ':' '{print $1}')
config=$(echo $x | awk '{print $(NF-1)}' | awk -F ':' '{print $2}')
else
internal=$(echo $x | awk -F ':' '{print $2}')
fi
echo $schema,$config,$internal
done
Please help me achieve this.