Skip to content

Commit

Permalink
Merge branch 'current' into mult-unique-keys
Browse files Browse the repository at this point in the history
  • Loading branch information
runleonarun authored Nov 14, 2024
2 parents dd91b05 + 53df291 commit 0762612
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 18 deletions.
3 changes: 2 additions & 1 deletion website/docs/docs/dbt-versions/versionless-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ The legacy dbt Semantic Layer was deprecated in the second half of 2023. We reco
<Expandable alt_header="What are other known issues when upgrading from older dbt Core versions?" >

If you are upgrading from a very old unsupported version of dbt Core, you may run into one of these edge cases after the upgrade to a newer version:
- [v1.1] Customers on BigQuery should be aware that dbt Cloud sets a default [per-model timeout](/docs/core/connect-data-platform/bigquery-setup#job_execution_timeout_seconds) of 5 minutes. You may override this config in your connection details. Older versions of dbt (including v1.0) did not appropriately respect this timeout configuration.
- [v1.3] Customers with non-dbt `.py` files defined within their project directories, such as `models/`. Since v1.3, dbt expects these files be valid [Python models](/docs/build/python-models). The customer needs to move these files out of their `models/` directory, or ignore them via `.dbtignore`
- [v1.5] Customers who have `--m` in their job definitions, instead of `-m` or `--models`. This autocompletion (`--m[odels]` for `--models`) has never been officially documented or supported. It was an implicit behavior of argparse (CLI library used in dbt-core v1.0-1.4) that is not supported by `click` (the CLI library used in dbt-core since v1.5+).
- [v1.5] Empty invalid `tests` config start raising a validation error](https://docs.getdbt.com/docs/dbt-versions/core-upgrade/upgrading-to-v1.5). Replace empty `tests` config with `tests: []` or remove it altogether.
- [v1.6] Performance optimization to `load_result` means you cannot call it on the same query result multiple times (https://github.com/dbt-labs/dbt-core/pull/7371)
- [v1.6] Performance optimization to `load_result` means you cannot call it on the same query result multiple times. Instead, save it to a local variable once, and reuse that variable (context: [dbt-core#7371](https://github.com/dbt-labs/dbt-core/pull/7371)

You should [contact dbt Cloud support](https://docs.getdbt.com/docs/dbt-support#dbt-cloud-support) to request an extension, during which you will need to make those updates.

Expand Down
8 changes: 4 additions & 4 deletions website/docs/faqs/Accounts/change-users-license.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ id: change-user-license

To change the license type for a user from `developer` to `read-only` or `IT` in dbt Cloud, you must be an account owner or have admin privileges. You might make this change to free up a billable seat but retain the user’s access to view the information in the dbt Cloud account.

1. From dbt Cloud, click the gear icon at the top right and select **Account Settings**.
1. From dbt Cloud, click on your account name in the left side menu and, select **Account settings**.

<Lightbox src="/img/docs/dbt-cloud/Navigate To Account Settings.png" title="Navigate to account settings" />
<Lightbox src="/img/docs/dbt-cloud/Navigate-to-account-settings.png" title="Navigate to account settings" />

2. In **Account Settings**, select **Users** under **Teams**.
3. Select the user you want to remove, and click **Edit** in the bottom of their profile.
3. Select the user you want to remove and click **Edit** in the bottom of their profile.
4. For the **License** option, choose **Read-only** or **IT** (from **Developer**), and click **Save**.

<Lightbox src="/img/docs/dbt-cloud/change_user_to_read_only_20221023.gif" title="Change users license type" />
<Lightbox src="/img/docs/dbt-cloud/change_user_to_read_only_20221023.gif" title="Change user's license type" />
52 changes: 39 additions & 13 deletions website/docs/reference/commands/deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,47 @@ Update your versions in packages.yml, then run dbt deps

## Predictable package installs

Starting in dbt Core v1.7, dbt generates a `package-lock.yml` file in the root of your project. This contains the complete set of resolved packages based on the `packages` configuration in `dependencies.yml` or `packages.yml`. Each subsequent invocation of `dbt deps` will install from the _locked_ set of packages specified in this file. Storing the complete set of required packages (with pinned versions) in version-controlled code ensures predictable installs in production and consistency across all developers and environments.
Starting in dbt v1.7, dbt generates a `package-lock.yml` file in the root of your project. This file ensures consistent and predictable package installs by storing the exact versions (including commit SHAs) of all resolved packages specified in your `packages.yml` or `dependencies.yml`. This consistency is crucial for maintaining stability in development and production environments, preventing unexpected issues from new releases with potential bugs.

The `package-lock.yml` file should be committed in Git initially, and then updated and committed only when you want to change versions or uninstall a package (for example `dbt deps --upgrade` or `dbt deps --lock`).
When you run `dbt deps`, dbt installs packages based on the locked versions in `package-lock.yml`. To update these locked versions, you must explicitly run `dbt deps --upgrade` and commit the updated `package-lock.yml` file. Storing this file in version control guarantees consistency across all environments and for all developers.

The `package-lock.yml` file includes a `sha1_hash` of the `packages` config. This enables dbt to detect if the `packages` config has been updated, and to rerun dependency resolution. To only check for changes to the `packages` config and update the lock file accordingly without installing those packages, provide the `--lock` flag (that is, `dbt deps --lock`).
### Managing `package-lock.yml`

### Forcing upgrades
The `package-lock.yml` file should be committed to Git initially and updated only when you intend to change versions or uninstall a package. For example, run `dbt deps --upgrade` to get updated package versions or `dbt deps --lock` to update the lock file based on changes to the packages config without installing the packages.

It's possible to force package resolution to rerun, even if the `packages` config hasn't changed, by running `dbt deps --upgrade`. This enables you to get the latest commits from the `main` branch of an internally maintained `git` package while accepting the risk of unpredictable builds.
To bypass using `package-lock.yml` entirely, you can add it to your project's `.gitignore`. However, this approach sacrifices the predictability of builds. If you choose this route, we strongly recommend adding version pins for third-party packages in your `packages` config.

An alternative to running `dbt deps --upgrade` in production is to "ignore" the lock file by adding `package-lock.yml` to your project's `.gitignore` file.
### Detecting changes in `packages` config

If you pursue either approach, dbt Labs strongly recommends adding version pins for third-party packages within your `packages` config.
The `package-lock.yml` file includes a `sha1_hash` of your packages config. If you update `packages.yml`, dbt will detect the change and rerun dependency resolution during the next `dbt deps` command. To update the lock file without installing the new packages, use the `--lock` flag:

## Add specific packages
```shell
dbt deps --lock
```

### Forcing package updates

To update all packages, even if `packages.yml` hasn’t changed, use the `--upgrade` flag:

```shell

dbt deps --upgrade

```

This is particularly useful for fetching the latest commits from the `main` branch of an internally maintained Git package.

:::warning
Forcing package upgrades may introduce build inconsistencies unless carefully managed.
:::

### Adding specific packages

The `dbt deps` command can add or update an existing package configuration &mdash; no need to remember the exact syntax for package configurations.
The `dbt deps` command can add or update package configurations directly, saving you from remembering exact syntax.

For Hub packages (default), which are the easiest to install:
#### Hub packages (default)

Hub packages are the default package types and the easiest to install.

```shell
dbt deps --add-package dbt-labs/[email protected]
Expand All @@ -87,11 +109,15 @@ dbt deps --add-package dbt-labs/[email protected]
dbt deps --add-package dbt-labs/snowplow@">=0.7.0,<0.8.0"
```

For other package types, use the `--source` flag:
#### Non-Hub packages

Use the `--source` flag to specify the type of package to be installed:

```shell
# add package from git

# Git package
dbt deps --add-package https://github.com/fivetran/[email protected] --source git

# add package from local
# Local package
dbt deps --add-package /opt/dbt/redshift --source local
```
12 changes: 12 additions & 0 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"gray-matter": "^4.0.3",
"hast-util-is-element": "^1.1.0",
"js-yaml": "^4.1.0",
"markdown-to-jsx": "^7.5.0",
"mobx": "^6.3.9",
"node-polyfill-webpack-plugin": "^1.1.4",
"papaparse": "^5.3.2",
Expand Down
114 changes: 114 additions & 0 deletions website/src/components/sortableTable/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import React, { useState, useMemo } from 'react';
import Markdown from 'markdown-to-jsx';

const stripMarkdown = (text) => {
let strippedText = text.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1');
strippedText = strippedText.replace(/[_*`~]/g, '');
return strippedText;
};

const parseMarkdownTable = (markdown) => {
const rows = markdown.trim().split('\n');
const headers = rows[0].split('|').map((header) => header.trim()).filter(Boolean);

const alignmentsRow = rows[1].split('|').map((align) => align.trim()).filter(Boolean);
const columnAlignments = alignmentsRow.map((alignment) => {
if (alignment.startsWith(':') && alignment.endsWith(':')) {
return 'center';
} else if (alignment.startsWith(':')) {
return 'left';
} else if (alignment.endsWith(':')) {
return 'right';
} else {
return 'left';
}
});

const data = rows.slice(2).map(row => row.split('|').map(cell => cell.trim()).filter(Boolean));

return { headers, data, columnAlignments };
};

const SortableTable = ({ children }) => {
const { headers, data: initialData, columnAlignments } = useMemo(
() => parseMarkdownTable(children),
[children]
);

const [data, setData] = useState(initialData);
const [sortConfig, setSortConfig] = useState({ key: '', direction: 'asc' });

const sortTable = (keyIndex) => {
const newDirection = (sortConfig.key === keyIndex && sortConfig.direction === 'asc') ? 'desc' : 'asc';
setSortConfig({ key: keyIndex, direction: newDirection });

const sortedData = [...data].sort((a, b) => {
const aVal = stripMarkdown(a[keyIndex]);
const bVal = stripMarkdown(b[keyIndex]);
if (aVal < bVal) return newDirection === 'asc' ? -1 : 1;
if (aVal > bVal) return newDirection === 'asc' ? 1 : -1;
return 0;
});

setData(sortedData);
};

return (
<table>
<thead>
<tr>
{headers.map((header, index) => (
<th
key={index}
onClick={() => sortTable(index)}
style={{
cursor: 'pointer',
position: 'relative',
textAlign: columnAlignments[index],
padding: '10px'
}}
>
<div style={{
display: 'flex',
alignItems: 'center',
justifyContent: columnAlignments[index] === 'center' ? 'center' : columnAlignments[index]
}}>
<span style={{ marginRight: '5px' }}>{header}</span>
<span style={{
opacity: sortConfig.key === index && sortConfig.direction === 'asc' ? 1 : (sortConfig.key === index ? 0.5 : 0.5)
}}>
</span>
<span style={{
marginLeft: '5px',
opacity: sortConfig.key === index && sortConfig.direction === 'desc' ? 1 : (sortConfig.key === index ? 0.5 : 0.5)
}}>
</span>
</div>
</th>
))}
</tr>
</thead>
<tbody>
{data.map((row, rowIndex) => (
<tr key={rowIndex}>
{row.map((cell, cellIndex) => (
<td
key={cellIndex}
style={{
textAlign: columnAlignments[cellIndex],
padding: '8px'
}}
>
<Markdown>{cell || '\u00A0'}</Markdown>
</td>
))}
</tr>
))}
</tbody>
</table>
);
};

export default SortableTable;
2 changes: 2 additions & 0 deletions website/src/theme/MDXComponents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Mermaid from '@theme/Mermaid';
/* dbt Customizations:
* Imports the following components below for export
*/
import SortableTable from '@site/src/components/sortableTable';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem'
import Changelog from '@site/src/components/changelog';
Expand Down Expand Up @@ -95,5 +96,6 @@ const MDXComponents = {
DetailsToggle: DetailsToggle,
Expandable: Expandable,
ConfettiTrigger: ConfettiTrigger,
SortableTable: SortableTable,
};
export default MDXComponents;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions website/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"cleanUrls": true,
"trailingSlash": false,
"redirects": [
{
"source": "/faqs/API/rotate-token",
"destination": "/docs/dbt-cloud-apis/service-tokens#service-token-update",
"permanent": true
},
{
"source": "/styles",
"destination": "https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/adding-page-components.md",
Expand Down

0 comments on commit 0762612

Please sign in to comment.