|
4 | 4 | "cell_type": "markdown",
|
5 | 5 | "metadata": {
|
6 | 6 | "application/vnd.databricks.v1+cell": {
|
7 |
| - "cellMetadata": {}, |
| 7 | + "cellMetadata": { |
| 8 | + "byteLimit": 2048000, |
| 9 | + "rowLimit": 10000 |
| 10 | + }, |
8 | 11 | "inputWidgets": {},
|
9 | 12 | "nuid": "4e9d71b1-88e9-445c-820a-b842e217a4e7",
|
10 | 13 | "showTitle": false,
|
|
21 | 24 | "execution_count": 0,
|
22 | 25 | "metadata": {
|
23 | 26 | "application/vnd.databricks.v1+cell": {
|
24 |
| - "cellMetadata": {}, |
| 27 | + "cellMetadata": { |
| 28 | + "byteLimit": 2048000, |
| 29 | + "rowLimit": 10000 |
| 30 | + }, |
25 | 31 | "inputWidgets": {},
|
26 | 32 | "nuid": "e6624c4d-8cb8-4ac4-8c72-81d1b4ecdb57",
|
27 | 33 | "showTitle": false,
|
|
40 | 46 | "cell_type": "markdown",
|
41 | 47 | "metadata": {
|
42 | 48 | "application/vnd.databricks.v1+cell": {
|
43 |
| - "cellMetadata": {}, |
| 49 | + "cellMetadata": { |
| 50 | + "byteLimit": 2048000, |
| 51 | + "rowLimit": 10000 |
| 52 | + }, |
44 | 53 | "inputWidgets": {},
|
45 | 54 | "nuid": "c3788fe5-f4c9-420f-ad72-ec1a39310a2a",
|
46 | 55 | "showTitle": false,
|
|
107 | 116 | "execution_count": 0,
|
108 | 117 | "metadata": {
|
109 | 118 | "application/vnd.databricks.v1+cell": {
|
110 |
| - "cellMetadata": {}, |
| 119 | + "cellMetadata": { |
| 120 | + "byteLimit": 2048000, |
| 121 | + "rowLimit": 10000 |
| 122 | + }, |
111 | 123 | "inputWidgets": {},
|
112 | 124 | "nuid": "137536ea-9bec-4171-8dc2-4bf8b0d771b4",
|
113 | 125 | "showTitle": false,
|
114 | 126 | "tableResultSettingsMap": {},
|
115 | 127 | "title": ""
|
116 | 128 | }
|
117 | 129 | },
|
118 |
| - "outputs": [], |
| 130 | + "outputs": [ |
| 131 | + { |
| 132 | + "output_type": "stream", |
| 133 | + "name": "stdout", |
| 134 | + "output_type": "stream", |
| 135 | + "text": [ |
| 136 | + "+------------+----+\n|topping_name|cost|\n+------------+----+\n| Pepperoni| 0.5|\n| Sausage| 0.7|\n| Chicken|0.55|\n|Extra Cheese| 0.4|\n+------------+----+\n\n" |
| 137 | + ] |
| 138 | + } |
| 139 | + ], |
119 | 140 | "source": [
|
120 | 141 | "toppings_data_3050 = [\n",
|
121 | 142 | " (\"Pepperoni\", 0.50),\n",
|
|
128 | 149 | "toppings_df_3050 = spark.createDataFrame(toppings_data_3050, toppings_columns_3050)\n",
|
129 | 150 | "toppings_df_3050.show()"
|
130 | 151 | ]
|
| 152 | + }, |
| 153 | + { |
| 154 | + "cell_type": "code", |
| 155 | + "execution_count": 0, |
| 156 | + "metadata": { |
| 157 | + "application/vnd.databricks.v1+cell": { |
| 158 | + "cellMetadata": { |
| 159 | + "byteLimit": 2048000, |
| 160 | + "rowLimit": 10000 |
| 161 | + }, |
| 162 | + "inputWidgets": {}, |
| 163 | + "nuid": "98fe0f40-1c3c-4706-b434-f3dd26b926f0", |
| 164 | + "showTitle": false, |
| 165 | + "tableResultSettingsMap": {}, |
| 166 | + "title": "" |
| 167 | + } |
| 168 | + }, |
| 169 | + "outputs": [], |
| 170 | + "source": [ |
| 171 | + "t1_3050 = toppings_df_3050.alias(\"t1_3050\")\n", |
| 172 | + "t2_3050 = toppings_df_3050.alias(\"t2_3050\")\n", |
| 173 | + "t3_3050 = toppings_df_3050.alias(\"t3_3050\")" |
| 174 | + ] |
| 175 | + }, |
| 176 | + { |
| 177 | + "cell_type": "code", |
| 178 | + "execution_count": 0, |
| 179 | + "metadata": { |
| 180 | + "application/vnd.databricks.v1+cell": { |
| 181 | + "cellMetadata": { |
| 182 | + "byteLimit": 2048000, |
| 183 | + "rowLimit": 10000 |
| 184 | + }, |
| 185 | + "inputWidgets": {}, |
| 186 | + "nuid": "65db7168-b7bc-4698-9e42-76d10e74da32", |
| 187 | + "showTitle": false, |
| 188 | + "tableResultSettingsMap": {}, |
| 189 | + "title": "" |
| 190 | + } |
| 191 | + }, |
| 192 | + "outputs": [ |
| 193 | + { |
| 194 | + "output_type": "display_data", |
| 195 | + "data": { |
| 196 | + "text/html": [ |
| 197 | + "<style scoped>\n", |
| 198 | + " .table-result-container {\n", |
| 199 | + " max-height: 300px;\n", |
| 200 | + " overflow: auto;\n", |
| 201 | + " }\n", |
| 202 | + " table, th, td {\n", |
| 203 | + " border: 1px solid black;\n", |
| 204 | + " border-collapse: collapse;\n", |
| 205 | + " }\n", |
| 206 | + " th, td {\n", |
| 207 | + " padding: 5px;\n", |
| 208 | + " }\n", |
| 209 | + " th {\n", |
| 210 | + " text-align: left;\n", |
| 211 | + " }\n", |
| 212 | + "</style><div class='table-result-container'><table class='table-result'><thead style='background-color: white'><tr><th>pizza</th><th>total_cost</th></tr></thead><tbody><tr><td>Chicken,Pepperoni,Sausage</td><td>1.75</td></tr><tr><td>Chicken,Extra Cheese,Sausage</td><td>1.65</td></tr><tr><td>Extra Cheese,Pepperoni,Sausage</td><td>1.6</td></tr><tr><td>Chicken,Extra Cheese,Pepperoni</td><td>1.45</td></tr></tbody></table></div>" |
| 213 | + ] |
| 214 | + }, |
| 215 | + "metadata": { |
| 216 | + "application/vnd.databricks.v1+output": { |
| 217 | + "addedWidgets": {}, |
| 218 | + "aggData": [], |
| 219 | + "aggError": "", |
| 220 | + "aggOverflow": false, |
| 221 | + "aggSchema": [], |
| 222 | + "aggSeriesLimitReached": false, |
| 223 | + "aggType": "", |
| 224 | + "arguments": {}, |
| 225 | + "columnCustomDisplayInfos": {}, |
| 226 | + "data": [ |
| 227 | + [ |
| 228 | + "Chicken,Pepperoni,Sausage", |
| 229 | + 1.75 |
| 230 | + ], |
| 231 | + [ |
| 232 | + "Chicken,Extra Cheese,Sausage", |
| 233 | + 1.65 |
| 234 | + ], |
| 235 | + [ |
| 236 | + "Extra Cheese,Pepperoni,Sausage", |
| 237 | + 1.6 |
| 238 | + ], |
| 239 | + [ |
| 240 | + "Chicken,Extra Cheese,Pepperoni", |
| 241 | + 1.45 |
| 242 | + ] |
| 243 | + ], |
| 244 | + "datasetInfos": [], |
| 245 | + "dbfsResultPath": null, |
| 246 | + "isJsonSchema": true, |
| 247 | + "metadata": {}, |
| 248 | + "overflow": false, |
| 249 | + "plotOptions": { |
| 250 | + "customPlotOptions": {}, |
| 251 | + "displayType": "table", |
| 252 | + "pivotAggregation": null, |
| 253 | + "pivotColumns": null, |
| 254 | + "xColumns": null, |
| 255 | + "yColumns": null |
| 256 | + }, |
| 257 | + "removedWidgets": [], |
| 258 | + "schema": [ |
| 259 | + { |
| 260 | + "metadata": "{}", |
| 261 | + "name": "pizza", |
| 262 | + "type": "\"string\"" |
| 263 | + }, |
| 264 | + { |
| 265 | + "metadata": "{}", |
| 266 | + "name": "total_cost", |
| 267 | + "type": "\"double\"" |
| 268 | + } |
| 269 | + ], |
| 270 | + "type": "table" |
| 271 | + } |
| 272 | + }, |
| 273 | + "output_type": "display_data" |
| 274 | + } |
| 275 | + ], |
| 276 | + "source": [ |
| 277 | + "t1_3050.join(t2_3050, col(\"t1_3050.topping_name\") < col(\"t2_3050.topping_name\")) \\\n", |
| 278 | + " .join(t3_3050, col(\"t2_3050.topping_name\") < col(\"t3_3050.topping_name\")) \\\n", |
| 279 | + " .select(\n", |
| 280 | + " concat_ws(\",\", \n", |
| 281 | + " t1_3050[\"topping_name\"], \n", |
| 282 | + " t2_3050[\"topping_name\"], \n", |
| 283 | + " t3_3050[\"topping_name\"]\n", |
| 284 | + " ).alias(\"pizza\"),\n", |
| 285 | + " round(\n", |
| 286 | + " t1_3050[\"cost\"] + t2_3050[\"cost\"] + t3_3050[\"cost\"], 2\n", |
| 287 | + " ).alias(\"total_cost\")\n", |
| 288 | + " ) \\\n", |
| 289 | + " .orderBy(col(\"total_cost\").desc(), col(\"pizza\").asc()).display()\n" |
| 290 | + ] |
131 | 291 | }
|
132 | 292 | ],
|
133 | 293 | "metadata": {
|
134 | 294 | "application/vnd.databricks.v1+notebook": {
|
135 |
| - "computePreferences": null, |
| 295 | + "computePreferences": { |
| 296 | + "hardware": { |
| 297 | + "accelerator": null, |
| 298 | + "gpuPoolId": null, |
| 299 | + "memory": null |
| 300 | + } |
| 301 | + }, |
136 | 302 | "dashboards": [],
|
137 | 303 | "environmentMetadata": {
|
138 | 304 | "base_environment": "",
|
139 |
| - "environment_version": "1" |
| 305 | + "environment_version": "2" |
140 | 306 | },
|
141 | 307 | "inputWidgetPreferences": null,
|
142 | 308 | "language": "python",
|
|
0 commit comments