Commit b2696ad
authored
SNOW-2478173: Improve single-row transpose helper for 1-column frames (#3975)
While testing #3973, I noticed that aggregations on single-column frames/series were producing queries with JSON serialization and unnecessary UNPIVOT operations. The QC's `transpose_single_row` helper method is used in aggregations to skip a PIVOT operation used in the general transpose case, but for transposing a 1x1 frame, we don't even need to UNPIVOT and need only re-label the index since we already know that the column's dtype will not change.
This PR adds a fast path for 1x1 `transpose_single_row` operations, which replaces JSON/UNPIVOT operations with simple projections. It produces some modest performance improvements for operations on a 2000x1 frame:
- `DataFrame.count`: 1.48s -> 1.31s (11.2% improvement)
- `DataFrame.describe`: 2.64s -> 2.36s (10.9% improvement)
- `DataFrame.nunique`: 1.25s -> 1.21s (3.4% improvement)
These improvements are likely to be more noticeable on frame produced from more complex queries.
This PR also adds explicit row count caching for the general transpose case. We currently cannot directly use the `transpose_single_row` path for the `transpose` API itself since the helper function drops the column labels of the result.1 parent 85997e1 commit b2696ad
File tree
6 files changed
+77
-28
lines changed- src/snowflake/snowpark/modin/plugin
- _internal
- compiler
- tests/integ/modin/frame
6 files changed
+77
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1144 | 1144 | | |
1145 | 1145 | | |
1146 | 1146 | | |
| 1147 | + | |
| 1148 | + | |
1147 | 1149 | | |
1148 | 1150 | | |
1149 | 1151 | | |
| |||
1171 | 1173 | | |
1172 | 1174 | | |
1173 | 1175 | | |
| 1176 | + | |
| 1177 | + | |
1174 | 1178 | | |
1175 | 1179 | | |
1176 | 1180 | | |
| |||
1252 | 1256 | | |
1253 | 1257 | | |
1254 | 1258 | | |
1255 | | - | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
1256 | 1262 | | |
1257 | 1263 | | |
1258 | 1264 | | |
| |||
Lines changed: 50 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11875 | 11875 | | |
11876 | 11876 | | |
11877 | 11877 | | |
11878 | | - | |
| 11878 | + | |
11879 | 11879 | | |
11880 | | - | |
| 11880 | + | |
11881 | 11881 | | |
| 11882 | + | |
| 11883 | + | |
| 11884 | + | |
| 11885 | + | |
| 11886 | + | |
| 11887 | + | |
| 11888 | + | |
| 11889 | + | |
| 11890 | + | |
| 11891 | + | |
| 11892 | + | |
| 11893 | + | |
| 11894 | + | |
| 11895 | + | |
| 11896 | + | |
| 11897 | + | |
| 11898 | + | |
| 11899 | + | |
| 11900 | + | |
| 11901 | + | |
| 11902 | + | |
| 11903 | + | |
| 11904 | + | |
| 11905 | + | |
| 11906 | + | |
| 11907 | + | |
| 11908 | + | |
| 11909 | + | |
| 11910 | + | |
| 11911 | + | |
| 11912 | + | |
| 11913 | + | |
| 11914 | + | |
| 11915 | + | |
| 11916 | + | |
| 11917 | + | |
| 11918 | + | |
| 11919 | + | |
| 11920 | + | |
| 11921 | + | |
| 11922 | + | |
| 11923 | + | |
| 11924 | + | |
| 11925 | + | |
11882 | 11926 | | |
11883 | 11927 | | |
11884 | 11928 | | |
| |||
11909 | 11953 | | |
11910 | 11954 | | |
11911 | 11955 | | |
| 11956 | + | |
11912 | 11957 | | |
11913 | 11958 | | |
11914 | 11959 | | |
| |||
11922 | 11967 | | |
11923 | 11968 | | |
11924 | 11969 | | |
| 11970 | + | |
11925 | 11971 | | |
11926 | | - | |
| 11972 | + | |
11927 | 11973 | | |
11928 | 11974 | | |
11929 | 11975 | | |
| |||
12061 | 12107 | | |
12062 | 12108 | | |
12063 | 12109 | | |
| 12110 | + | |
12064 | 12111 | | |
12065 | 12112 | | |
12066 | 12113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
197 | 199 | | |
198 | 200 | | |
199 | 201 | | |
| |||
628 | 630 | | |
629 | 631 | | |
630 | 632 | | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
631 | 643 | | |
632 | 644 | | |
633 | 645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1077 | 1077 | | |
1078 | 1078 | | |
1079 | 1079 | | |
1080 | | - | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | 1080 | | |
1093 | 1081 | | |
1094 | | - | |
| 1082 | + | |
1095 | 1083 | | |
1096 | 1084 | | |
1097 | 1085 | | |
| |||
1101 | 1089 | | |
1102 | 1090 | | |
1103 | 1091 | | |
1104 | | - | |
| 1092 | + | |
1105 | 1093 | | |
1106 | 1094 | | |
1107 | 1095 | | |
1108 | 1096 | | |
1109 | 1097 | | |
1110 | 1098 | | |
1111 | 1099 | | |
1112 | | - | |
1113 | 1100 | | |
1114 | 1101 | | |
1115 | 1102 | | |
1116 | 1103 | | |
1117 | 1104 | | |
1118 | | - | |
| 1105 | + | |
1119 | 1106 | | |
1120 | 1107 | | |
1121 | 1108 | | |
| |||
1129 | 1116 | | |
1130 | 1117 | | |
1131 | 1118 | | |
1132 | | - | |
| 1119 | + | |
1133 | 1120 | | |
1134 | 1121 | | |
1135 | 1122 | | |
| |||
1151 | 1138 | | |
1152 | 1139 | | |
1153 | 1140 | | |
1154 | | - | |
| 1141 | + | |
1155 | 1142 | | |
1156 | 1143 | | |
1157 | 1144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 34 | + | |
39 | 35 | | |
40 | 36 | | |
41 | 37 | | |
| |||
0 commit comments