<jupyter_start><jupyter_text>Running CustomerDistribution, one of TPC-H queries[@evgskv](https://github.com/evgskv)  Retrieving TPC-H data<jupyter_code>!curl https://github.com/lovasoa/TPCH-sqlite/releases/download/v1.0/TPC-H.db -L > tpc.db
!ls -l<jupyter_output>total 1223508
drwxr-xr-x 1 root root       4096 Jul  1 13:42 sample_data
-rw-r--r-- 1 root root 1252864000 Jul  9 21:16 tpc.db<jupyter_text>Installing Logica<jupyter_code>!pip install logica
from logica import colab_logica<jupyter_output><empty_output><jupyter_text>Calculating distribution of customers by order count<jupyter_code>%%logica CustomerDistribution

@Engine("sqlite");
@AttachDatabase("db", "tpc.db");

OrdersByCustomer(c_custkey) += 1 :-
  db.customer(c_custkey:),
  db.orders(o_custkey:, o_comment:),
  o_custkey == c_custkey,
  !Like(o_comment, "%special%requesets%");
OrdersByCustomer(c_custkey) += 0 :-
  db.customer(c_custkey:);

CustomerDistribution(
  c_count: OrdersByCustomer(),
  custdist? += 1) distinct;<jupyter_output><empty_output><jupyter_text>Taking a look at what tables are available<jupyter_code>%%logica M

@AttachDatabase("db", "tpc.db");
@Engine("sqlite");
M(..r) :- db.sqlite_master(..r);
Q() += 1 :- db.customer();<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1502008032128514, 'fraction_numerical': 0.03132530120481928, 'mean_word_length': 6.461077844311378, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '642252', 'license': 'Apache-2.0', 'n_tokens_mistral': 535, 'n_tokens_neox': 494, 'n_words': 84, 'path': 'examples/more/Customer_Distribution_TPC_H_query.ipynb', 'repo_name': 'CyberFlameGO/logica', 'size': '1245'}