"""
Check actual product_line_vn values in StarRocks DB.
Verifies what accessory categories exist.
"""
import os
import sys

# Fix encoding for Windows console
os.environ["PYTHONIOENCODING"] = "utf-8"
sys.stdout.reconfigure(encoding="utf-8")

sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

from common.starrocks_connection import get_db_connection


def main():
    db = get_db_connection()
    results = db.execute_query(
        "SELECT DISTINCT product_line_vn, COUNT(*) as cnt "
        "FROM shared_source.magento_product_dimension_with_text_embedding "
        "GROUP BY product_line_vn ORDER BY cnt DESC"
    )
    print("=" * 55)
    print(f"{'product_line_vn':40s} | count")
    print("=" * 55)
    for r in results:
        val = str(r.get("product_line_vn") or "NULL")
        print(f"{val:40s} | {r['cnt']}")


if __name__ == "__main__":
    main()
