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
8
votes
2 answers

How to build custom bootstrap bundle using Rollup

According to Bootstrap 5 official documentation, we can import pre-compiled js files from bootstrap/js/dist and build a custom bundle using (Webpack, rollup,…
Mourad Karoudi
  • 348
  • 3
  • 13
8
votes
1 answer

How can typescript be setup in Storybook with Svelte?

I'm trying to use Storybook with a Svelte component library. Svelte is set up to use Rollup. I wonder if Storybook's use of Webpack could have anything to do with my issue? Storybook is working just fine as long as my svelte components are written…
8
votes
0 answers

Using react-admin with snowpack

I want to use react-admin in a project with snowpack but I encounter the following error ✖ snowpack failed to load node_modules/ra-core/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js 'default' is not exported by…
thammada.ts
  • 5,065
  • 2
  • 22
  • 33
8
votes
0 answers

Rollup: bundling/embedding wasm code from an external module

Using rollup, I'm trying to bundle a typescript library that imports and calls an npm module that contains a wasm file. Only the resulting bundle contains no trace of the wasm file contents. How can I force it to bundle the webassembly too ? Here's…
Nicolas Marshall
  • 4,186
  • 9
  • 36
  • 54
8
votes
2 answers

is it possible to run a rollup plugin without an input file (in a multi bundle instance)?

I have a situation where I am bundling multiple files via rollup cli an example of this is available in documentation. I export an array of bundles like so: export default [ { input: 'packages/A/index.js', output: { …
Otis Wright
  • 1,980
  • 8
  • 31
  • 53
8
votes
1 answer

Uncaught (in promise) TypeError: Illegal constructor at new SvelteElement (index.mjs:1381)

Uncaught promise when registering a custom element using the latest sapper, svelte, nodeJS, and rollup stack using the following statements. REPL example: https://svelte.dev/repl/489ee8acd10848b0bb1feb2535bd6cc5?version=3.16.5 created…
nclaudiuf
  • 91
  • 1
  • 5
8
votes
0 answers

How to create a npm library with JS config file and web target?

I've created an UI JS library, package.json is fine, I bundle it with webpack and it works great in npm (stays nicely in node_modules/library dir). However, I'd like to make some stuff configurable via config file. Let's say, my library has a Box…
Andrzej Dąbrowski
  • 1,159
  • 11
  • 14
7
votes
2 answers

How to do multiple bundles with vite?

Using vite js to bundle my library, I need to provide two versions at the same time: production usage development specific code and warnings with devtools integration. When I was using webpack, I had: module.exports = [ …
Incepter
  • 2,711
  • 15
  • 33
7
votes
1 answer

Typescript inferred type cannot be named without reference

My project's setup is tsdx (based on Rollup and Typescript). Working in my IDE (vscode) everything looks fine, and even running yarn tsc works without errors. When I'm running yarn build (which is tsdx build) I get the following error: (typescript)…
itaied
  • 119
  • 1
  • 1
  • 6
7
votes
1 answer

Prevent service-worker.js from being bundled with vite / rollup

I have a TypeScript-based Vuejs project compiled and bundled using Vite. I am trying to configure the build system to compile my custom service worker (src/service-worker.ts) and place the output in dist/service-worker.js. In particular, I don't…
Myk Willis
  • 12,306
  • 4
  • 45
  • 62
7
votes
1 answer

Building an Nx lib with Rollup does not bundle required dependencies

Question I'm using the default Rollup executor to build an Nx library that I will later run in a browser-like environment. The resulting bundle cannot contain imports or requires. Running nx run ssr-bundle:build should create a single bundle…
Mike Fleming
  • 2,593
  • 4
  • 14
  • 24
7
votes
2 answers

React Rollup: 'name' is not exported by node_modules/

I am trying to make a library/package from my component. Tech-stack is: React, Typescript... and a bunch of other dependencies. I am using Rollup and when I try to build the package I get the following error: [!] Error: 'DisplayHint' is not…
Mark James
  • 338
  • 4
  • 15
  • 43
7
votes
1 answer

Do the order of rollup plugins matter?

Playing around with rollup and Svelte it seems like changing the order of plugins inside of rollup.config.js makes no difference. plugins: [ svelte({ preprocess: sveltePreprocess(), compilerOptions: { // enable…
Will Taylor
  • 1,650
  • 9
  • 23
7
votes
1 answer

rollup watch include directory

I am trying with following rollup.config.js file import typescript from "rollup-plugin-typescript2"; import pkg from "./package.json"; import copy from 'rollup-plugin-copy' import clean from 'rollup-plugin-clean'; export default [ { input:…
Saurabh Nemade
  • 1,522
  • 2
  • 11
  • 20
7
votes
2 answers

CSS modules and rollup - generating separate CSS files ("themes") with same hashes

I'm using CSS Modules (Sass) with rollup on a component library project, which is working well. Each component ends up with a dist folder containing a single JS bundle file, and a corresponding CSS file with the scoped CSS classes so consumers of…
benjamin.keen
  • 1,936
  • 1
  • 20
  • 29