Skip to main content

Creating and managing Mesh Tables with Brick Management

PurposeThis guide provides a detailed overview of creating Mesh Tables using Brick Management.
CreatedNovember 21,2023

Creating a Mesh Table

To create a Dynamic Table, navigate to Settings and select Brick Management v2. Start creating your Brick by defining the configuration using Python language. Depending on your use case, you will encounter various configuration options, including the incorporation of essential parameters such as API keys.

When creating the Python brick we will find two sections:

  • Configuration Options: Explore the different settings based on your requirements. For example, you can specify API keys for authentication.
  • Code: Incorporate Python code with a focus on structure and handling of data.

Essential functions for Brick Operation:

The Table Brick requires the implementation of the following methods:

  1. Init Method (__init__):

    • Description: Initializes an instance of the Table Brick class.
    • Parameters:
      • self: The instance of the class being created.
      • config: Configuration settings for the Table Brick.
    • Returns: None
  2. Scan Method:

    • Description: Sends basic statistics about the content within the table, enabling effective brick functionality.
    • Parameters:
      • self: The instance of the class.
    • Returns: None
  3. Query Method:

    • Description: Defines the translation process of SQL queries into the system, contributing to seamless integration.

    • Parameters:

      • self: The instance of the class.

      • query: SQL query to be processed.

    • Returns: Result of the SQL query execution.

Table Brick Example

class TableBrick:
def __init__(self, config):
self.config = config

def scan(self):
# Implement scan logic here
pass

def query(self, query):
# Implement query logic here
pass

Filters applicable to the Mesh Table

Filters are essential components for refining data retrieval from Dynamic Tables. They enable you to specify conditions that influence the selection of rows from the table. Below are various filters available for use in Dynamic Tables.

Equality =

Description: Retrieves rows where the specified column is equal to the given value.

Attributes:

  • column (str): The name of the column to filter.
  • value (Any): The value to compare for equality.
class FilterEq:
"""
Represents the Equality (=) filter in SQL.
"""
def __init__(self, column, value):
self.column = column
self.value = value

2. Inequality != or <>

Description: Retrieves rows where the specified column is not equal to the given value.

Attributes:

  • column (str): The name of the column to filter.
  • value (Any): The value to compare for inequality.
class FilterNeq:
"""
Represents the Inequality (!= or <>) filter in SQL.
"""
def __init__(self, column, value):
self.column = column
self.value = value

3. Negation ~ or !

Description: Retrieves rows where the specified condition is not true.

Attributes:

  • condition (FilterBase): The condition to negate.
class FilterNot:
"""
Represents the Negation (~ or !) filter in SQL.
"""
def __init__(self, condition):
self.condition = condition

4. Negation for ILIKE ~* or !~*

Description: Performs a case-insensitive pattern match (ILIKE) or a case-insensitive negated pattern match (!~*) on the specified column.

Attributes:

  • column (str): The name of the column to filter.
  • pattern (str): The pattern to match in a case-insensitive manner.
class FilterILike:
"""
Represents the ILIKE (~*) filter in SQL.
"""
def __init__(self, column, pattern):
self.column = column
self.pattern = pattern

Attributes:

  • column (str): The name of the column to filter.
  • pattern (str): The pattern to avoid in a case-insensitive manner.
class FilterNotILike:
"""
Represents the Negation for ILIKE (!~*) filter in SQL.
"""
def __init__(self, column, pattern):
self.column = column
self.pattern = pattern

5. Comparison Operators > , >=, <, <=

Description: Retrieves rows where the specified column satisfies the given comparison condition.

Attributes:

  • column (str): The name of the column to filter.
  • value (Any): The value to compare for greater than.
class FilterGt:
"""
Represents the Greater Than (>) filter in SQL.
"""
def __init__(self, column, value):
self.column = column
self.value = value

Attributes:

  • column (str): The name of the column to filter.
  • value (Any): The value to compare for greater than or equal to.
class FilterGte:
"""
Represents the Greater Than or Equal To (>=) filter in SQL.
"""
def __init__(self, column, value):
self.column = column
self.value = value

Attributes:

  • column (str): The name of the column to filter.
  • value (Any): The value to compare for less than.
class FilterLt:
"""
Represents the Less Than (<) filter in SQL.
"""
def __init__(self, column, value):
self.column = column
self.value = value

Attributes:

  • column (str): The name of the column to filter.
  • value (Any): The value to compare for less than or equal to.
class FilterLte:
"""
Represents the Less Than or Equal To (<=) filter in SQL.
"""
def __init__(self, column, value):
self.column = column
self.value = value

6. LIKE Operator

Description: Retrieves rows where the specified column matches the specified pattern.

Attributes:

  • column (str): The name of the column to filter.
  • pattern (str): The pattern to match.
class FilterLike:
"""
Represents the LIKE filter in SQL.
"""
def __init__(self, column, pattern):
self.column = column
self.pattern = pattern

7. ILIKE Operator

Description: Retrieves rows where the specified column matches the specified pattern in a case-insensitive manner.

Attributes:

  • column (Column): The column to filter.
  • pattern (str): The pattern to match.
class FilterILike(FilterBase):
"""
Represents the ILIKE filter in SQL.
"""
def __init__(self, column, pattern):
self.column = column
self.pattern = pattern

8. IN Operator

Description: Retrieves rows where the specified column matches any value in the provided list.

Attributes:

  • column (str): The name of the column to filter.
  • values (List[Any]): The list of values to match.
class FilterIn:
"""
Represents the IN filter in SQL.
"""
def __init__(self, column, values):
self.column = column
self.values = values

9. NOT Operator

Description: Retrieves rows where the specified condition is not true.

Attributes:

  • condition (FilterBase): The condition to negate.
class FilterNot:
"""
Represents the NOT filter in SQL.
"""
def __init__(self, condition):
self.condition = condition

10. Logical Operators OR, AND

Description: Retrieves rows based on the logical combination of conditions using the OR operator.

Attributes:

  • conditions (List[FilterBase]): The list of conditions to combine with OR.
class FilterOr:
"""
Represents the OR filter in SQL.
"""
def __init__(self, conditions):
self.conditions = conditions

Description: Retrieves rows based on the logical combination of conditions using the AND operator.

Attributes:

  • conditions (List[FilterBase]): The list of conditions to combine with AND.
class FilterAnd:
"""
Represents the AND filter in SQL.
"""
def __init__(self, conditions):
self.conditions = conditions

11. BETWEEN Operator

Description: Retrieves rows where the specified column's value is within the specified range.

Attributes:

  • column (str): The name of the column to filter.
  • low (Any): The lower bound of the range.
  • high (Any): The upper bound of the range.
class FilterBetween:
"""
Represents the BETWEEN filter in SQL.
"""
def __init__(self, column, low, high):
self.column = column
self.low = low
self.high = high

Implementing a Mesh Table

To use the created Brick in a Dynamic Table, follow these steps:

  1. Navigate to the Tables section within Settings.

  2. Select Table: Choose the type of Table you want to work with, in this case the "Dynamic Table".

  3. Select Brick: Select the Brick from which the information will be pulled.

  4. Specify Python Document: Indicate the Python document you intend to use for Dynamic Table implementation.

  5. Define Class Name: Specify the class name of the brick to employ for the implementation process.

  6. Define Schema: State how is the Table going to be structured.

    In the following section a Python script showing how to obtain a schema will be explained.

Schema script

For more information on the Schema script follow link below:

Learn more about Schema script

Brick example:

In this section you will find an example for a Brick you can use for creating your Dynamic Table. The main objective of this python code is to read CVS files using pandas

import pandas as pd

# Replace 'your_file.csv' with the actual path to your CSV file
file_path = 'your_file.csv'

# Load the CSV file into a pandas DataFrame
df = pd.read_csv(file_path)

# Display the DataFrame
print(df)

Some examples of CVS you could load are:

CSV File Examples

With the technical knowledge provided, you are now equipped to create your Python Bricks and easily integrate them into the Dynamic Table.