New Component: streamlit-merge-tables

Streamlit Merge Tables

streamlit-merge-tables is a Streamlit custom component that allows users to visually define merge (join) logic across multiple tables using an interactive UI.

The component does not perform the actual data merge. Instead, it returns a merge plan (dictionary) describing how tables should be joined, giving developers full control over execution.

Features

  • Visual table merge builder

  • Chain and pairwise merge modes

  • Multiple join types: INNER, LEFT, RIGHT, OUTER

  • Column-level join key selection

  • Built-in validation

  • Optional DAG visualization of merge flow

  • Framework-agnostic execution (pandas, SQL, backend services)

  • Github: GitHub - linhnt-hub/streamlit_merge_tables

Usage

Installation

pip install streamlit-merge-tables

Basic Usage

import streamlit as st
import pandas as pd
from streamlit_component import merge_tables

df_interfaces = pd.DataFrame({
    "ifname": ["ge-0/0/0", "ge-0/0/1"],
    "speed": [1000, 1000],
    "status": ["up", "down"],
})

df_traffic = pd.DataFrame({
    "ifname": ["ge-0/0/0"],
    "bps": [1234],
})

tables = [
    {
        "id": "interfaces",
        "name": "Interfaces",
        "columns": list(df_interfaces.columns),
    },
    {
        "id": "traffic",
        "name": "Traffic",
        "columns": list(df_traffic.columns),
    },
]

merge_plan = merge_tables(
    tables=tables,
    dag=True,
)

st.subheader("Merge plan")
st.json(merge_plan)

Tables Schema

The tables parameter defines table metadata only, not actual DataFrames. You can use python function for convert dataframe to tables schema like below:

tables = [
    {
        "id": "interfaces",
        "name": "Interfaces",
        "columns": ["ifname", "speed", "status"],
    }
]
#################################################################
import pandas as pd

def serialize_dataframe(df: pd.DataFrame) -> dict:
    return {
        "columns": list(df.columns),
        "dtypes": {c: str(t) for c, t in df.dtypes.items()},
        "data": df.to_dict(orient="records"),
    }

License

This project is licensed under the MIT License.

Give me feedback if you have any ideal, thanks

3 Likes