External Schemas, File, and Table Formats

Redshift परिचय

Jason Myers

Principal Architect

External schemas

डेटाबेस कॉम्पोनेंट्स डेटाबेस कॉम्पोनेंट्स

  • जब मेटाडेटा कैटलॉग और स्टोरेज क्लस्टर का भाग नहीं होते, तो उन्हें external माना जाता है

Redshift Spectrum

Redshift Spectrum के साथ External Schemas

  • Redshift इंजन है
  • डिफॉल्ट रूप से AWS Glue Data Catalog और AWS S3 स्टोरेज का उपयोग करता है
Redshift परिचय

S3 डेटा फाइल फॉर्मेट्स

फाइल फॉर्मेट कॉलमनर पैरेलल रीड सपोर्ट
Parquet Yes Yes
ORC Yes Yes
TextFile No No
OpenCSV No Yes
JSON No No
Redshift परिचय

CSV External Table बनाएँ

CREATE TABLE spectrumdb.IDAHO_SITE_ID
(
    'pk_siteid' INTEGER PRIMARY KEY,
    -- Cutting the rest of columns for space
)

-- CSV rows are comma delimited ROW FORMAT DELIMITED
-- CSV fields are terminated by a comma FIELDS TERMINATED BY ','
-- CSVs are a type of text file STORED AS TEXTFILE
-- This is where the data is in AWS S3 LOCATION 's3://spectrum-id/idaho_sites/'
-- This file has headers that we want to skip TABLE PROPERTIES ('skip.header.line.count'='1');
Redshift परिचय

Spectrum टेबल्स पर क्वेरी करना

  • आंतरिक टेबल्स की तरह ही क्वेरी चलता है
  • EXPLAIN अलग दिखेगा
  • DISTKEY या SORTKEYs की चिंता नहीं
  • प्सूडो-कॉलम्स
    • $path - पंक्ति के लिए फाइल स्टोरेज पाथ दिखाता है
    • $size - पंक्ति के लिए फाइल साइज़ दिखाता है
Redshift परिचय

प्सूडो-कॉलम्स का उपयोग

SELECT "$path", 
       "$size",
       pk_siteid
  FROM spectrumdb.idaho_site_id;
$path                           | $size | pk_siteid
================================|=======|==========
's3://spectrum-id/idaho_sites/' | 1616  | 1 
's3://spectrum-id/idaho_sites/' | 1616  | 2 
's3://spectrum-id/idaho_sites/' | 1616  | 3 
Redshift परिचय

टेबल फॉर्मेट्स

  • कॉमन फॉर्मेट्स:

    • Hive
    • Iceberg
    • Hudi
    • Deltalake
  • केवल पढ़ने योग्य

  • कुछ, जैसे Hive, को AWS Glue से अलग external कैटलॉग चाहिए
Redshift परिचय

External schemas देखना

  • SVV_ALL_SCHEMAS - internal या external
SELECT schema_name, 
       schema_type
  FROM SVV_ALL_SCHEMAS
 ORDER BY SCHEMA_NAME;
schema_name           | schema_type
======================|=============
public_intro_redshift | internal
spectrumdb            | external
Redshift परिचय

External tables देखना

  • SVV_ALL_TABLES - TABLE या EXTERNAL TABLE
SELECT table_name, 
       table_type
  FROM SVV_ALL_TABLES
 WHERE schema_name = 'public_intro_redshift';
table_name                | table_type
==========================|================
coffee_county_weather     | TABLE
idaho_monitoring_location | TABLE
idaho_samples             | TABLE
ecommerce_sales           | EXTERNAL_TABLE
Redshift परिचय

अभ्यास करते हैं!

Redshift परिचय

Preparing Video For Download...