Skip to main content

Snowflake の Load History と Copy History の違い

data

Snowflake におけるデータロードの追跡は、データの健全性とパフォーマンスを維持するために非常に重要です。Load History と Copy History は、過去のデータロードに関する貴重な情報を提供してくれる機能です。これらの機能を理解することで、トラブルシューティング、監査、パフォーマンス分析などを効率的に行うことができます。

Snowflake で Load History を使っても Copy History を使ってもテーブルにロードされた過去のデータの履歴を取得できますが。

何が違うでしょうか。いつどっちを使った方が良いでしょうか。

Load History と Copy History の7違いさ

違いさ1: ビュー vs テーブル関数

Load History はビューです。
Copy History と言うテーブル関数ビューもあります。

Load History の使う方の例:

USE DATABASE db_1;

SELECT table_name, last_load_time
  FROM information_schema.load_history
  WHERE schema_name=current_schema() AND
  table_name='TABLE_1';

Copy History ビュー:

select file_name, table_name, last_load_time
from snowflake.account_usage.copy_history
order by last_load_time desc
limit 10;

Copy History テーブル関数:

select *
from table(
    information_schema.copy_history(
       TABLE_NAME=>'TABLE_1',
       START_TIME=> DATEADD(hours, -1, CURRENT_TIMESTAMP())
      )
    )
;

違いさ2: アクセス権限

Copy History テーブル関数は普通の関数です。
Copy History ビューは Account Usage ビューを使用します。
Load History ビュー Information Schema ビューを使用します。

と言うは:
Load History ビューを使うに Copy History テーブル関数使うよりもっと権限が必要です。
Copy History ビューを使うには Load History ビューを使うよりもっと高く権限が必要です。

違いさ 3: Snowpipe を使用してロードされたデータの履歴

Load History ビューは、Snowpipe を使用してロードされたデータの履歴を返しません。
Copy History テーブル関数もビューも Snowpipe を使用してロードされたデータの履歴を返します。

違いさ 4: 返される行の上限

Load History ビューは, 10,000 行の上限を返します。
Copy History テーブル関数もビューもこの上限がないです。

違いさ 5: 過去履歴の上限

Load History ビューと Copy History テーブル関数はテーブルにロードされた過去 14 日間以内のデータの履歴を取得できるようになります。
Copy History ビューは過去 365 日(1 年)の Snowflake データロード履歴をクエリできます。

違いさ 6: レイテンシー

Copy History ビューは多くの場合、ビューの遅延は最大 120 分(2 時間)です。状態によって最大 2 日になることもあります。

違いさ 7: クエリーの結果

Copy history テーブル関数を使う時に、必ずテーブル名を指定しないといけないです。
と言うのは、Copy history テーブル関数は一つのテーブルだけにロードされた過去のデータの履歴を取得できます。

例:

select *
from table(
    information_schema.copy_history(
      TABLE_NAME=>'TABLE_1',
      START_TIME=> DATEADD(hours, -1, CURRENT_TIMESTAMP())
      )
    )
;

Load History ビューと Copy history ビューの場合ではテーブル名を指定するのはオプショナルでは。
例: database_a データベースに対して実行された 10 個の最新の COPY INTO コマンドのレコードを取得します。

USE DATABASE database_a;

SELECT table_name, last_load_time
  FROM information_schema.load_history
  ORDER BY last_load_time DESC
  LIMIT 10;

Comments

Popular posts from this blog

脱初心者! Git ワークフローを理解して開発効率アップ

Git – チーム開発に必須のバージョン管理システムですが、その真価を発揮するにはワークフローの理解が欠かせません。 色々な人は Git の使い方を良く知っていますが、Git を仕事やワークフローに統合する方法を余り良く知らない人もいます。本記事では、Git をワークフローに組み込むことで、開発プロセスがどのように効率化され、チーム全体のパフォーマンスが向上するのかを解説します。Centralized Workflow から Forking Workflow まで、代表的な 9 つのワークフローの特徴を分かりやすく紹介します。それぞれのメリット・デメリット、そして最適なユースケースを理解することで、あなたのプロジェクトに最適なワークフローを選択し、開発をスムーズに進めましょう! Centralized Workflow Feature branching/GitHub Flow Trunk Based Flow Git Feature Flow Git Flow Enhanced Git Flow One Flow GitLab Flow Forking Workflow 分かりやすくするために、同じコンセプトを説明するに一つ以上の図を使った場合があります。 Centralized Workflow 説明: 集中化ワークフローではプロジェクトにおけるすべての変更の単一の入力箇所として中央リポジトリを使用します。デフォルトの開発用ブランチは main と呼ばれ、すべての変更がこのブランチにコミットされます。 集中化ワークフローでは main 以外のブランチは不要です。チームメンバー全員がひとつのブランチで作業し、変更を直接中央リポジトリにプッシュします。 メリット: SVN のような集中型バージョン管理システムから移行する小規模チームに最適。 デメリット: お互いのコードが邪魔になり (お互いの変更を上書きするように)、プロダクション環境にバグをい入れる可能性が高くて、複数のメンバいるチームでこのフローを使いにくい。 地図: graph TD; A[Central Repository] -->|Clone| B1[Developer A's Local Repo] A --...

From Generic to Genius: Fine-tuning LLMs for Superior Accuracy in Snowflake

TL;DR: Cortex Fine-tuning is a fully managed service that lets you fine-tune popular LLMs using your data, all within Snowflake. While large language models (LLMs) are revolutionizing various fields, their "out-of-the-box" capabilities might not always align perfectly with your specific needs. This is where the power of fine-tuning comes into play. As it will be explained in this article, this feature empowers you to take a base LLM and customize it to excel in your particular domain. Here's the brief summary of why you might want to leverage Snowflake's fine-tuning capabilities: Unlocking Domain Expertise : Pre-trained LLMs are trained on massive, general datasets. Fine-tuning allows you to build upon this foundation and train the LLM further using data specific to your field, such as legal documents, medical records, or financial data. This empowers the LLM to understand complex terminology and patterns unique to your domain, leading to more accurate a...

How Wendy’s Successfully Penetrated the Japanese Market After Long Struggles

Wendy’s had long struggled to penetrate the Japanese market. Initially the Daiei Group tried to bring Wendy’s to Japan but failed. The next owner of Wendy’s’ Japanese franchise, Zensho Holdings Co. also failed miserably. However, Japanese-American entrepreneur Ernest M. Higa seems to have managed to do the task. This article will discuss the challenges Wendy’s faced when entering the Japanese market, how Ernie Higa addressed those challenges, macro environmental factors that impacted the success of the brand in Japan, future threats the Japanese fast food market is facing , and potential solutions. The prior challenges that Wendy’s faced when they entered the Japanese market There is no one-size-fits-all formula in business, especially when Japan is involved in the conversation. According to Japanese-American entrepreneur Ernie Higa, even if a company has a good product and good pricing, penetrating the Japanese market is more difficult compared to the US’s market. Foreign e...