Hybrid Code Combining Imperative Loops with Declarative SQL

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional relational databases face limitations in implementing iterative and condition-based loop structures using Structured Query Language (SQL), which hinders the training of machine learning models that require iterative logic, and existing solutions either rely on non-standard SQL variants or incur high computational and memory overhead by moving data into client RAM.

Innovation Solution

A hybrid code approach that combines imperative programming language semantics with declarative SQL to generate iterative and conditional looping behavior within relational databases, allowing iterative logic to execute on the database without loading data into memory, while adhering to ANSI SQL syntax.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If declarative SQL is used for database operations, then high performance operations on large data sets are achieved, but iterative logic required for ML training cannot be implemented

Engineering Contradiction:
Improveperformance on large data setsVSAvoiditerative logic capability
Core Design Contradiction:
ProductivityVSAdaptability or versatility

Solution Approach 1:

The patent merges declarative SQL with imperative programming constructs by embedding SQL statements within Python loops and conditional statements. This combination allows the system to maintain the high performance of declarative SQL on large datasets while gaining the iterative logic capabilities of imperative programming, directly resolving the contradiction between performance and adaptability.

Inventive Principle:
Principle #5Merging (Combining)

Solution Approach 2:

The patent introduces an intermediary layer that translates iterative imperative logic into multiple declarative SQL statements. The Python code acts as a mediator that generates and executes sequences of SQL queries, enabling iterative behavior without requiring the database engine itself to support iterative constructs, thus preserving SQL performance while adding versatility.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Adaptability or versatility

If imperative code is used to support iterative programming semantics, then iterative logic is enabled, but memory limits are faced due to data loading requirements

Engineering Contradiction:
Improveiterative programming capabilityVSAvoidmemory capacity
Core Design Contradiction:
Adaptability or versatilityVSQuantity of substance

Solution Approach 1:

The patent extracts the data loading step from the iterative processing workflow. Instead of loading all data into memory before processing, the system keeps data in the database and only loads the necessary results of each SQL query into memory for the next iteration. This extraction of the loading operation resolves the contradiction by enabling iterative logic while minimizing memory usage.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent segments the data processing workflow into discrete SQL query operations that are executed iteratively. Each iteration processes a portion of the data through a SQL statement, and only the results of that specific operation are loaded into memory. This segmentation allows iterative processing to proceed with minimal memory requirements, as the database engine handles the heavy lifting of data management.

Inventive Principle:
Principle #1Segmentation

3Adaptability or versatility

If nonstandard or specialized SQL variants are used to implement iteration, then iterative control is achieved, but ANSI SQL syntax compliance is lost

Engineering Contradiction:
Improveiterative control capabilityVSAvoidSQL syntax standard compliance
Core Design Contradiction:
Adaptability or versatilityVSEase of manufacture

Solution Approach 1:

The patent uses Python as an intermediary layer that generates and executes standard ANSI SQL statements. The iterative control logic is implemented in Python, while the database operations themselves use compliant SQL syntax. This intermediary approach enables iterative control without requiring modifications to the SQL language standard, maintaining compatibility with existing database systems.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

Instead of trying to extend SQL with iterative constructs (which would violate ANSI compliance), the patent inverts the approach by using imperative Python to control and generate multiple SQL statements. The control flow is reversed: rather than SQL providing iteration, Python provides the iteration framework that orchestrates multiple SQL executions, thereby maintaining SQL standard compliance while achieving iterative functionality.

Inventive Principle:
Principle #13The other way round (Inversion)

Data Source

PatentUS20240086156A1Hybrid code combining imperative programming languages with declarative database operations to accomplish iterative logic
Publication Date: 2024.03.14 ATSCALE INC
  • US20240086156A1 patent drawing
  • US20240086156A1 patent drawing
  • US20240086156A1 patent drawing

AI summary

A hybrid code construct combines imperative and declarative semantics for leveraging complementary features for a relational database exchange optimized for declarative access driven by imperative direction for imposing iterative and conditional looping behavior. Databases responsive to a declarative command structure receive declarative code generated from an imperative code sequence. The imperative code is based on a language that allows conditional iteration for repetitive commands, which invoke the declarative command syntax within a controlled loop or iteration. Declarative syntax, while enjoying optimizations for high performance database access, does not lend itself well to iterative logic common for linear regression and training of ML models. The hybrid code allows efficient ML training while the dataset defining the model remains within the database and need not incur network transport for Al based usage.