El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ MapReduce Service/ Component Operation Guide (LTS)/ Using Hive/ Enterprise-Class Enhancements of Hive/ Detecting Statements That Overwrite a Table with Its Own Data

Detecting Statements That Overwrite a Table with Its Own Data

Updated on 2024-12-13 GMT+08:00

Scenario

You can intercept SQL statements that read the data written by themselves in Hive. You can add the rule dynamic_0004 on the SQL Inspector page to intercept SQL statements that overwrite a table, partition, or directory with data from the same table, partition, or directory.

This topic is available for MRS 3.5.0 or later versions.

NOTE:

The following are some typical large Hive SQL statements you need to detect:

  • Non-partitioned table

    INSERT OVERWRITE TABLE tbl_a SELECT * FROM tbl_a;

  • Static partition table

    INSERT OVERWRITE TABLE tbl_b PARTITION (ds='20240101') SELECT * FROM tbl_b WHERE ds='20240101';

  • Dynamic partitioning

    INSERT OVERWRITE TABLE tbl_c PARTITION(pday) SELECT id,name,pday FROM tbl_c WHERE id > 100;

  • Writing data to an HDFS table

    INSERT OVERWRITE DIRECTORY 'hdfs://hacluster/user/hive/warehouse/tbl_d' SELECT * FROM tbl_d;

Procedure

  1. Log in to FusionInsight Manager as a user with management right.
  2. Choose Cluster > SQL Inspector, click Add Rule, enter the password of the user, and click OK. The Add Rule page is displayed.
  3. On the displayed page, set the following parameters and click OK:

    • Name: Enter a rule name, for example, test.
    • ID: Select dynamic_0004.
    • Tenant: Click Add and select the tenant name for which the inspection rule will be used, for example, default.
    • Services and Actions: Click Add. In the Add Service and Action dialog box, set the following parameters and click OK:
      • Service: Select Hive.
      • Enable the Hint or Intercept action based on service requirements.
    Figure 1 Creating a Hive SQL inspection rule

  4. Log in to the node where the Hive client is installed and switch to the client installation directory.

    cd /opt/client

    Configure environment variables.

    source bigdata_env

    Authenticate the user (skip this step if Kerberos authentication is disabled for the cluster).

    kinit Component service user who has the Hive operation permission

  5. Log in to the Hive client.

    beeline

  6. Create a table and insert data into the table.

    drop table tbl_a;

    create table tbl_a(id int, name string);

    insert into table tbl_a values(123,'sjk'),(234,'shen'),(111,'aaa');

  7. (Optional) Enable strict interception. For details, see Setting Strict Interception for Hive Dynamic Partitioned Tables. The nonstrict mode is used by default for dynamic partitioning.

    set hive-ext.dynamic.partition.intercept.mode=strict;

  8. Check whether the static_0001 rule has been applied.

    insert overwrite table tbl_a select * from tbl_a;

    If the configured action is Hint, the system reports an alarm when detecting a SQL statement that triggers the inspection rule. The SQL statement will continue to run, and the following information will be displayed:

    WARN  : DYNAMIC_0004 Self-read and self-overwrite operations are not allowed.

    If the configured action is Intercept, the SQL statement will be intercepted when the system detects a SQL statement that triggers the inspection rule. The following information is displayed:

    Error: Error while compiling statement: FAILED: RuleException DYNAMIC_0004 Self-read and self-overwrite operations are not allowed. (state=42000,code=40000)

Setting Strict Interception for Hive Dynamic Partitioned Tables

The system cannot obtain the partition information in the compilation phase of dynamic partitioning, and therefore cannot detect SQL statements that overwrite data with the same data. You can choose a non-strict or strict interception policy when SQL statements involve dynamic partitioning.

  • Non-strict interception allows the system to check whether the queried table is the one where the submitted SQL statement writes data to. The detection is completed during SQL compilation. So, non-strict interception is fast, but it also works for quires of data in different partitions.
  • Strict interception allows the system to check whether the queried partition is the one where the submitted SQL statement writes data to. The detection is completed during the MoveTask phase of a SQL task. Strict interception is more accurate, but it works only after most logics of the SQL task are executed, causing resource waste.

Non-strict interception is used by default for dynamic partitioning. To enable strict interception, set hive-ext.lakeformation.transform.role (in Table 1) to strict. You are advised to set this parameter for a single task, for example, for a SQL statement like set hive-ext.dynamic.partition.intercept.mode=strict;.

Table 1 Parameters

Parameter

Default Value

Description

hive-ext.dynamic.partition.intercept.mode

nonstrict

Interception mode for SQL statements that involve Hive dynamic partitioning. The options are as follows:

  • nonstrict: If the queried table is the one where a SQL statement inserts data to, the SQL statement is intercepted.
  • strict: If the queried partition is the one where a SQL statement inserts data to, the SQL statement is intercepted.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback