Questions tagged [rollup]

The ROLLUP operator is useful in generating reports that contain subtotals and totals. The ROLLUP operator generates a result set that is similar to the result sets generated by the CUBE operator

The ROLLUP operator is useful in generating reports that contain subtotals and totals. The ROLLUP operator generates a result set that is similar to the result sets generated by the CUBE operator. For more information, see Summarizing Data Using CUBE.

Following are the specific differences between CUBE and ROLLUP:

  • CUBE generates a result set that shows aggregates for all combinations of values in the selected columns.
  • ROLLUP generates a result set that shows aggregates for a hierarchy of values in the selected columns.

For example, a simple table Inventory contains the following:

Item                 Color                Quantity                   
-------------------- -------------------- -------------------------- 
Table                Blue                 124                        
Table                Red                  223                        
Chair                Blue                 101                        
Chair                Red                  210 

The next query

SELECT CASE WHEN (GROUPING(Item) = 1) THEN 'ALL'
            ELSE ISNULL(Item, 'UNKNOWN')
       END AS Item,
       CASE WHEN (GROUPING(Color) = 1) THEN 'ALL'
            ELSE ISNULL(Color, 'UNKNOWN')
       END AS Color,
       SUM(Quantity) AS QtySum
FROM Inventory
GROUP BY Item, Color WITH ROLLUP 

generates the following subtotal report:

Item                 Color                QtySum                     
-------------------- -------------------- -------------------------- 
Chair                Blue                 101.00                     
Chair                Red                  210.00                     
Chair                ALL                  311.00                     
Table                Blue                 124.00                     
Table                Red                  223.00                     
Table                ALL                  347.00                     
ALL                  ALL                  658.00   

If the ROLLUP keyword in the query is changed to CUBE, the CUBE result set is the same, except these two additional rows are returned at the end:

ALL                  Blue                 225.00                     
ALL                  Red                  433.00  

The CUBE operation generated rows for possible combinations of values from both Item and Color. For example, not only does CUBE report all possible combinations of Color values combined with the Item value Chair (Red, Blue, and Red + Blue), it also reports all possible combinations of Item values combined with the Color value Red (Chair, Table, and Chair + Table).

For each value in the columns on the right in the GROUP BY clause, the ROLLUP operation does not report all possible combinations of values from the column, or columns, on the left. For example, ROLLUP does not report all the possible combinations of Item values for each Color value.

The result set of a ROLLUP operation has functionality similar to that returned by a COMPUTE BY. However, ROLLUP has the following advantages:

  • ROLLUP returns a single result set while COMPUTE BY returns multiple result sets that increase the complexity of application code.
  • ROLLUP can be used in a server cursor while COMPUTE BY cannot.
  • The query optimizer can sometimes generate more efficient execution plans for ROLLUP than it can for COMPUTE BY.
1420 questions
22
votes
2 answers

Rollup + React not compiling JSX

I'm trying to use Rollup + React but I'm encounting an error when rollup encounters JSX. Unexpected token... export default () =>

M... I have a repo that triggers the error. All documentation/examples I've found using Rollup + React don't use…

Brad Woods
  • 1,507
  • 2
  • 12
  • 30
20
votes
4 answers

vite without hash in filename

I'm trying to compile a webcomponent based on the monaco editor (in a lit element context). Having tried a lot of options I now have got the result down to two files rmx-monaco.abc123.js style.css My top priority is to get rid of the hash…
Simon H
  • 20,332
  • 14
  • 71
  • 128
19
votes
3 answers

How to get rollup to include a dependency from another package in a lerna monorepo in its transpilation (TypeScript)?

I created a minimal example to show the question I have: Github repo. I have a lerna monorepo with two npm packages in the packages folder, the packages are called: utils: exports a function: export const add = (a:number, b: number) => a +…
evianpring
  • 3,316
  • 1
  • 25
  • 54
18
votes
2 answers

Svelte (rollup) - Error: Unexpected token (Note that you need @rollup/plugin-json to import JSON files)

I am doing nothing to trigger this error. The app works fine one second, and doesn't the next. Why is this happening? It is not due to the missing @rollup/plugin-json plugin because it worked previously without…
Ivan
  • 1,967
  • 4
  • 34
  • 60
18
votes
2 answers

How do you import a Svelte component in a Typescript file?

Is it possible to import a Svelte component in a Typescript file and have Rollup successfully compile it? The following code works as a Javascript file, but errors when converted to Typescript, because the TS compiler doesn’t know how to handle a…
swithinbank
  • 1,127
  • 1
  • 6
  • 15
18
votes
6 answers

Overall summary with multiple GROUP BY

Lets say I have a table called census with the following information: COUNTRY PROVINCE CITY POPULATION ============================================== USA California Sacramento 1234 USA California SanFran 4321 USA…
Mr. Llama
  • 20,202
  • 2
  • 62
  • 115
17
votes
2 answers

vite cannot handle xxx.html files

I had a Vite project for Vue2, It include a static html file. like following import template from 'editor.html'; export default { template: template } When I ran yarn dev, Terminal…
noahlam
  • 171
  • 1
  • 4
17
votes
3 answers

Alias names to with rollup in SQL queries?

I am using with rollup in my sql query. I am not getting alias name for rollup. My SQL is SELECT [Column1], sum([Column2]) FROM Tablea GROUP BY [Column2] WITH ROLLUP Which returns s 8 t 8 j 8 null 24 How can I…
vision
  • 415
  • 2
  • 4
  • 12
14
votes
2 answers

Separating Material UI in Vite (Rollup) as a manual chunk to reduce chunk size

Is anyone using Vite to bundle their MUI app? I was surprised at how big my vendor chunk (1.1MB) was from Vite/Rollup. I've come up with the below config which separates MUI packages into it's own chunk: import { defineConfig } from "vite"; import…
Ben Stickley
  • 1,551
  • 1
  • 16
  • 22
14
votes
1 answer

How to setup rollup for css modules in TypeScript

I managed to import css modules in my Typescript React Class using this plugin from npm. tsconfig.json { "compilerOptions": { "target": "ESNext", "outDir": "build", "jsx": "react", "noImplicitAny": false, "removeComments":…
KawaLo
  • 1,783
  • 3
  • 16
  • 34
14
votes
2 answers

Why is my React component library not tree-shakable?

I have a React component library that I’m bundling with rollup. Then I’m consuming that library in an app setup with create-react-app which uses Webpack under the hood. I expect Webpack to tree-shake the component library. After building the app…
borisdiakur
  • 10,387
  • 7
  • 68
  • 100
14
votes
2 answers

Creating a tree shakable library with rollup

I am trying to create a component library wie rollup and Vue that can be tree shakable when others import it. My setup goes as follows: Relevant excerpt from package.json { "name": "red-components-with-rollup", "version": "1.0.0", …
Lukas
  • 9,752
  • 15
  • 76
  • 120
13
votes
0 answers

Rollup.js is not bundling my React Component Library fonts

Everything works just fine when I view my React component library with Storybook. When I publish the library to the NPM registry, I install it into a dummy React app and everything works as expected except for the font. Below is my rollup.config.js…
Ton
  • 131
  • 6
13
votes
2 answers

How to set multiple output when build lib with vite

When I try to build a lib in vue3, I want to set multiple output file. Code like this: rollupOptions { output: [ { file: 'bundle.js', format: 'cjs' }, { file: 'bundle.min.js', format: 'iife', name:…
wubian
  • 131
  • 1
  • 1
  • 3
13
votes
5 answers

Rollup is not generating typescript sourcemap

I am using rollup with svelte + typescript + scss. My problem is that I am not able to generate source maps. Following is my rollup config file: import svelte from 'rollup-plugin-svelte' import resolve from '@rollup/plugin-node-resolve' import…
dasfdsa
  • 7,102
  • 8
  • 51
  • 93
1
2
3
94 95