diff --git a/docs/_sources/index.rst.txt b/docs/_sources/index.rst.txt index 58dcf3d..98da015 100644 --- a/docs/_sources/index.rst.txt +++ b/docs/_sources/index.rst.txt @@ -32,6 +32,7 @@ It provides a consistent and convenient way to test the execution of your query usage/defining_table_mocks usage/your_sql_query_to_test usage/result_assertion + usage/default_values usage/examples .. toctree:: diff --git a/docs/_sources/usage/default_values.md.txt b/docs/_sources/usage/default_values.md.txt index d3688b5..a127cc2 100644 --- a/docs/_sources/usage/default_values.md.txt +++ b/docs/_sources/usage/default_values.md.txt @@ -8,7 +8,9 @@ Testing SQL queries can often involve repetitive setup for mock tables. In SQLMo ## Utilizing Default Values in MockTable Fields -Defining default values at the field level in your mock tables is straightforward. The default argument in the field definition allows you to set default values, which are particularly useful for ensuring that joins and other query functionalities operate correctly. +Defining default values at the field level in your mock tables is straightforward. +The default argument in the field definition allows you to set default values consistency across all test scenarios in one step. +They are particularly useful for ensuring that joins and other query functionalities operate correctly. Here's an example: @@ -20,7 +22,7 @@ class UserTable(BigQueryMockTable): # Create instances of the UserTable with various combinations of defaults and specified values users = UserTable.from_dicts([ - {}, # Uses default values --> {"user_id": 1, "user_name": "Mr. T"} + {}, # Left empty {} uses default values --> {"user_id": 1, "user_name": "Mr. T"} {"user_id": 2}, # Overrides user_id but uses default for user_name {"user_id": 3, "user_name": "Nala"} # No defaults used here ]) @@ -43,7 +45,10 @@ class MultipleSubscriptionUsersTable(BigQueryMockTable): user_id = col.Int(default=1) # Setting up different scenarios to demonstrate the use of defaults -users = UserTable.from_dicts([{"user_id": 1}, {"user_id": 2}]) +users = UserTable.from_dicts([ + {"user_id": 1}, + {"user_id": 2} +]) subscriptions = SubscriptionTable.from_dicts( [ {"subscription_id": 1, "user_id": 1}, diff --git a/docs/genindex.html b/docs/genindex.html index d8b6f45..0d614ec 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -51,6 +51,7 @@
  • Defining table mocks
  • Your SQL query to test
  • Result assertion
  • +
  • Default values
  • Examples
  • Database Specifics

    diff --git a/docs/index.html b/docs/index.html index cf3f7be..011b5af 100644 --- a/docs/index.html +++ b/docs/index.html @@ -54,6 +54,7 @@
  • Defining table mocks
  • Your SQL query to test
  • Result assertion
  • +
  • Default values
  • Examples
  • Database Specifics

    @@ -128,6 +129,12 @@

    Welcome to SQL Mock’s documentation!Result assertion +
  • Default values +
  • Examples
  • diff --git a/docs/objects.inv b/docs/objects.inv index 8593d54..db266c3 100644 Binary files a/docs/objects.inv and b/docs/objects.inv differ diff --git a/docs/py-modindex.html b/docs/py-modindex.html index 3165516..655eea2 100644 --- a/docs/py-modindex.html +++ b/docs/py-modindex.html @@ -54,6 +54,7 @@
  • Defining table mocks
  • Your SQL query to test
  • Result assertion
  • +
  • Default values
  • Examples
  • Database Specifics

    @@ -104,7 +105,7 @@

    Python Module Index

    - sql_mock + sql_mock diff --git a/docs/search.html b/docs/search.html index 904406d..78b3e23 100644 --- a/docs/search.html +++ b/docs/search.html @@ -54,6 +54,7 @@
  • Defining table mocks
  • Your SQL query to test
  • Result assertion
  • +
  • Default values
  • Examples
  • Database Specifics

    diff --git a/docs/searchindex.js b/docs/searchindex.js index d45ffb8..5f6aa45 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"docnames": ["faq", "getting_started/installation", "getting_started/quickstart", "index", "modules", "robots", "sql_mock", "sql_mock.bigquery", "sql_mock.clickhouse", "usage/bigquery/examples", "usage/bigquery/index", "usage/bigquery/settings", "usage/clickhouse/examples", "usage/clickhouse/index", "usage/clickhouse/settings", "usage/default_values", "usage/defining_table_mocks", "usage/examples", "usage/result_assertion", "usage/your_sql_query_to_test"], "filenames": ["faq.md", "getting_started/installation.md", "getting_started/quickstart.md", "index.rst", "modules.rst", "robots.txt", "sql_mock.rst", "sql_mock.bigquery.rst", "sql_mock.clickhouse.rst", "usage/bigquery/examples.md", "usage/bigquery/index.rst", "usage/bigquery/settings.md", "usage/clickhouse/examples.md", "usage/clickhouse/index.rst", "usage/clickhouse/settings.md", "usage/default_values.md", "usage/defining_table_mocks.md", "usage/examples.md", "usage/result_assertion.md", "usage/your_sql_query_to_test.md"], "titles": ["FAQ", "Installation", "Quickstart", "Welcome to SQL Mock\u2019s documentation!", "sql_mock", "<no title>", "sql_mock package", "sql_mock.bigquery package", "sql_mock.clickhouse package", "Example: Testing Subscription Counts in BigQuery", "BigQuery", "Settings", "Example: Testing Subscription Counts in ClickHouse", "Clickhouse", "Settings", "Default values", "Defining table mocks", "Examples", "Result assertion", "Your SQL query to test"], "terms": {"we": [0, 1, 2, 6, 15, 16, 18, 19], "ar": [0, 1, 6, 15, 16, 18, 19], "plan": 0, "add": [0, 1, 6], "more": [0, 2, 16, 18], "howev": 0, "you": [0, 1, 2, 6, 11, 14, 15, 16, 17, 18, 19], "can": [0, 1, 2, 6, 15, 16, 17, 18, 19], "still": 0, "There": [0, 16, 18, 19], "onli": [0, 6, 15, 16, 18, 19], "2": [0, 2, 3, 9, 12, 15, 16, 18], "thing": [0, 16], "need": [0, 1, 3, 6, 11, 14, 15, 16, 19], "first": 0, "inherit": [0, 6, 9, 12, 16], "from": [0, 1, 2, 6, 7, 8, 9, 12, 16, 18, 19], "sql_mock": [0, 1, 2, 9, 12, 16, 18], "table_mock": [0, 2, 9, 12, 16, 18], "basemockt": [0, 6, 7, 8, 16], "That": 0, "implement": [0, 15], "_get_result": 0, "method": [0, 1, 2, 15, 16, 18, 19], "which": [0, 6, 15], "make": [0, 1], "sure": [0, 1], "fetch": 0, "result": [0, 2, 3, 6, 9, 12, 16], "queri": [0, 2, 3, 6, 9, 12, 15, 16, 18], "e": [0, 2, 6, 16, 19], "g": [0, 2, 6, 16, 19], "produc": 0, "self": 0, "_generate_queri": 0, "return": [0, 6], "list": [0, 6], "dictionari": [0, 2, 6, 7, 8, 19], "look": 0, "one": [0, 6, 15], "exist": 0, "client": 0, "librari": [0, 1, 3], "see": 0, "how": [0, 2, 10, 13, 15, 16, 18, 19], "thi": [0, 1, 2, 3, 6, 7, 8, 10, 13, 16, 18, 19], "could": 0, "work": [0, 2, 15], "bigquerymockt": [0, 2, 6, 7, 9, 15, 16, 18], "might": 0, "set": [0, 3, 6, 10, 13], "well": [0, 16], "case": [0, 18, 19], "some": [0, 2, 16, 17, 19], "connect": [0, 11, 14], "avail": [0, 2], "within": [0, 6], "In": [0, 1, 2, 11, 14, 15, 18, 19], "order": [0, 6, 11, 14], "them": [0, 6, 16, 19], "column": [0, 2, 6], "column_mock": [0, 2, 9, 12, 16, 18], "base": [0, 2, 6, 7, 8], "For": [0, 15], "most": 0, "specifi": [0, 2, 15, 16, 19], "dtype": [0, 6, 7, 8], "pars": 0, "input": [0, 2, 3, 6, 15, 16, 18, 19], "A": [0, 6, 18], "good": 0, "practis": 0, "all": [0, 1, 2, 6, 16], "import": [0, 1, 2, 9, 12, 16, 18], "myfancedatabasecolumnmock": 0, "logic": [0, 15, 18], "overwrit": [0, 6, 16], "default": [0, 2, 6, 7, 8, 9, 12, 16, 18, 19], "behavior": 0, "so": 0, "here": [0, 15], "pass": [0, 3, 15, 16], "int": [0, 2, 6, 7, 8, 9, 12, 15, 16, 18, 19], "integ": [0, 7, 8], "string": [0, 2, 6, 7, 8, 9, 12, 15, 16, 18, 19], "definit": [0, 15, 16], "folk": 0, "commun": 0, "just": 0, "feel": 0, "free": 0, "pr": 0, "repositori": 0, "start": [0, 2], "implementd": 0, "basic": [0, 15], "happen": [0, 6], "don": [0, 2, 15], "t": [0, 2, 9, 12, 15, 18], "find": [0, 17], "luckili": 0, "easili": [0, 16], "those": [0, 14, 16, 18, 19], "tool": 0, "provid": [0, 2, 3, 6, 14, 15, 16], "The": [0, 1, 3, 6, 15, 16, 19], "bigquerycolumnmock": [0, 6, 7], "write": 0, "usual": [0, 16], "correct": [0, 15], "would": [0, 6], "later": 0, "cast": [0, 2], "col": [0, 2, 9, 12, 15, 16, 18, 19], "express": [0, 2], "replac": [0, 2, 6, 7, 8], "bigqueri": [0, 1, 3, 6, 11, 16, 18], "myfancymissingcoltyp": 0, "fancymissingcoltyp": 0, "addit": [0, 15], "forget": 0, "pypi": 1, "us": [1, 2, 3, 6, 9, 10, 11, 12, 13, 14, 16, 18], "pip": 1, "upgrad": 1, "sql": [1, 2, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16, 18], "mock": [1, 2, 5, 6, 9, 10, 11, 12, 13, 14, 18, 19], "clickhous": [1, 2, 3, 6, 14], "If": [1, 6], "modifi": 1, "sourc": 1, "code": [1, 15], "depend": 1, "poetri": 1, "extra": [1, 7, 8], "conftest": 1, "py": [1, 16, 19], "file": [1, 6, 11, 16, 19], "root": 1, "your": [1, 2, 3, 9, 12, 14, 15, 16, 18], "project": 1, "follow": [1, 14, 18, 19], "line": 1, "register_assert_rewrit": 1, "allow": [1, 3, 15, 16], "get": [1, 2], "rich": 1, "comparison": [1, 6], "when": [1, 6, 14, 16, 18, 19], "assert_equ": [1, 2, 6, 9, 12, 18], "tabl": [1, 2, 6, 9, 12, 15, 18, 19], "instanc": [1, 2, 6, 14, 15, 16, 18, 19], "also": [1, 16, 18, 19], "icdiff": 1, "better": 1, "visibl": 1, "diff": 1, "fail": 1, "test": [1, 3, 6, 10, 11, 13, 14, 15, 16, 18], "befor": 2, "dive": 2, "specif": [2, 10, 13, 15, 19], "databas": [2, 6, 16], "scenario": [2, 3, 15], "let": [2, 11, 15, 18, 19], "": [2, 6, 15, 18, 19], "simplifi": [2, 3, 15], "exampl": [2, 3, 10, 13, 15, 18, 19], "behind": 2, "scene": 2, "have": [2, 11, 14, 16, 18], "an": [2, 15], "origin": [2, 6, 9, 12], "path": [2, 6, 7, 8, 15, 16, 19], "query_for_result_t": [2, 16, 19], "select": [2, 6, 9, 12, 16, 18, 19], "id": [2, 16, 19], "data": [2, 3, 6, 9, 12, 15, 16, 18, 19], "table1": [2, 16], "defin": [2, 3, 6, 7, 8, 9, 12, 15, 18, 19], "built": [2, 18], "type": [2, 3, 6], "includ": [2, 18], "date": [2, 6, 7, 8, 9, 12, 18], "each": 2, "ha": 2, "own": 2, "subclass": 2, "class": [2, 3, 6, 7, 8, 9, 12, 15, 16, 18, 19], "fit": 2, "along": 2, "valu": [2, 6], "our": [2, 18], "clickhousetablemock": [2, 6, 8, 12], "table_meta": [2, 3, 6, 9, 12, 16, 18], "table_ref": [2, 6, 9, 12, 15, 16, 18, 19], "1": [2, 3, 6, 9, 12, 15, 16, 18], "name": [2, 6, 7, 8, 16], "peter": [2, 16], "result_t": [2, 16, 19], "query_path": [2, 6, 15, 16, 18, 19], "resultt": [2, 16, 19], "creat": [2, 3, 6, 9, 12, 15, 16], "repres": [2, 6], "row": [2, 6], "kei": [2, 6], "correspond": 2, "user_data": 2, "both": 2, "martin": 2, "3": [2, 15], "input_table_mock": 2, "from_dict": [2, 6, 9, 12, 15, 18], "from_mock": [2, 3, 6, 9, 12, 15, 16, 18], "object": [2, 6], "gener": [2, 6], "re": [2, 9, 12, 15, 16, 18, 19], "input_data": [2, 6, 9, 12, 15, 16, 18, 19], "refer": [2, 6], "common": 2, "cte": [2, 6, 18], "fill": 2, "dummi": 2, "It": [2, 3, 6], "roughli": 2, "compar": [2, 6], "someth": 2, "like": [2, 6, 16], "WITH": [2, 18], "data__table1": 2, "AS": [2, 9, 12, 18, 19], "union": [2, 6], "final": [2, 6, 18], "expect": [2, 6, 9, 12], "primari": 3, "purpos": 3, "i": [3, 6, 16, 19], "model": [3, 6, 7, 8, 9, 12, 16, 18, 19], "user": [3, 5, 6, 8, 9, 12, 14, 15, 18, 19], "variou": [3, 15], "consist": 3, "conveni": 3, "wai": [3, 15, 16, 18], "execut": 3, "without": 3, "process": [3, 6, 15], "massiv": 3, "amount": 3, "instal": 3, "recommend": [3, 16], "setup": [3, 15], "pytest": 3, "quickstart": 3, "faq": 3, "my": 3, "system": 3, "support": 3, "yet": 3, "want": [3, 6, 14, 16, 18, 19], "what": 3, "should": [3, 6, 7, 8], "do": [3, 18], "mocktabl": [3, 6, 16], "columnmock": [3, 6, 7, 8], "contribut": 3, "am": 3, "miss": 3, "field": [3, 6, 7, 8], "option": 3, "decor": [3, 6, 15, 16], "call": 3, "jinja": [3, 6], "templat": [3, 6], "assert": [3, 6, 9, 12], "subscript": [3, 10, 13, 15, 18], "count": [3, 10, 13, 18], "index": 3, "modul": 3, "search": 3, "page": 3, "agent": 5, "sitemap": 5, "http": 5, "deeplcom": 5, "github": 5, "io": 5, "xml": 5, "decim": [6, 7, 8], "float": [6, 7, 8], "bigqueryset": [6, 7], "google_application_credenti": [6, 7, 11], "model_config": [6, 7, 8], "model_field": [6, 7, 8], "boolean": [6, 8], "clickhousecolumnmock": [6, 8], "datetim": [6, 8, 9, 12, 18], "datetime64": [6, 8], "clickhouseset": [6, 8], "host": [6, 8, 14], "password": [6, 8, 14], "port": [6, 8, 14], "none": [6, 7, 8], "nullabl": [6, 7, 8], "fals": [6, 7, 8], "str": [6, 7, 8], "indic": 6, "whether": 6, "null": 6, "cast_field": 6, "column_nam": 6, "to_sql": 6, "noinput": 6, "validationerror": 6, "dict": [6, 7, 8], "attribut": 6, "col1": 6, "_sql_mock_data": 6, "store": 6, "automatci": 6, "instanti": 6, "sqlmockdata": 6, "_sql_mock_meta": 6, "metadata": [6, 7, 8], "mocktablemeta": 6, "as_sql_input": 6, "combin": [6, 15], "assert_cte_equ": [6, 18], "cte_nam": 6, "ignore_missing_kei": 6, "bool": [6, 7, 8], "ignore_ord": 6, "true": [6, 7, 8], "equal": 6, "paramet": 6, "against": 6, "present": 6, "argument": [6, 15, 16, 19], "ignor": 6, "classmethod": 6, "query_template_kwarg": [6, 19], "run": [6, 11, 14, 18], "static": 6, "hold": 6, "pair": 6, "render": [6, 19], "cl": 6, "basemodel": 6, "dure": 6, "avoid": 6, "collis": 6, "srting": 6, "format": 6, "classvar": [6, 7, 8], "configdict": [6, 7, 8], "configur": [6, 7, 8], "conform": [6, 7, 8], "pydant": [6, 7, 8], "config": [6, 7, 8], "fieldinfo": [6, 7, 8], "annot": [6, 7, 8], "requir": [6, 7, 8, 15], "about": [6, 7, 8], "map": [6, 7, 8, 18], "__fields__": [6, 7, 8], "v1": [6, 7, 8], "rendered_queri": 6, "last_queri": 6, "get_keys_from_list_of_dict": 6, "replace_original_table_refer": 6, "mock_tabl": 6, "orign": 6, "point": [6, 11], "select_from_ct": 6, "statement": 6, "select_ct": 6, "note": [6, 19], "validate_input_mock": 6, "precis": [7, 8], "scale": [7, 8], "_case_sensit": [7, 8], "_env_prefix": [7, 8], "_env_fil": [7, 8], "dotenvtyp": [7, 8], "posixpath": [7, 8], "_env_file_encod": [7, 8], "_env_nested_delimit": [7, 8], "_secrets_dir": [7, 8], "baseset": [7, 8], "settingsconfigdict": [7, 8], "arbitrary_types_allow": [6, 7, 8], "case_sensit": [7, 8], "env_fil": [7, 8], "env_file_encod": [7, 8], "env_nested_delimit": [7, 8], "env_prefix": [7, 8], "forbid": [7, 8], "protected_namespac": [7, 8], "model_": [7, 8], "settings_": [7, 8], "secrets_dir": [7, 8], "validate_default": [7, 8], "arg": [7, 8], "kwarg": [7, 8], "sql_mock_clickhouse_": 8, "usert": [9, 12, 15, 18], "user_id": [9, 12, 15, 18, 19], "user_nam": [9, 12, 15, 18], "mr": [9, 12, 15, 18], "subscriptiont": [9, 12, 15, 18], "subscription_id": [9, 12, 15, 18], "period_start_d": [9, 12, 18], "2023": [9, 12, 18, 19], "9": [9, 12, 18], "5": [9, 12, 18], "period_end_d": [9, 12, 18], "subscriptioncountt": [9, 12], "subscription_count": [9, 12, 18], "left": [9, 12, 18], "join": [9, 12, 15, 18], "group": [9, 12, 18], "BY": [9, 12, 18], "simul": [9, 12], "section": [10, 13, 16], "document": [10, 13], "ensur": [11, 15], "environ": [11, 14], "variabl": [11, 14, 19], "correctli": [11, 15], "servic": 11, "account": 11, "while": 11, "sql_mock_clickhouse_host": 14, "sql_mock_clickhouse_us": 14, "sql_mock_clickhouse_password": 14, "sql_mock_clickhouse_port": 14, "enabl": 14, "upstream": 16, "central": 16, "where": [16, 18, 19], "reus": [16, 19], "across": 16, "goign": 16, "mention": 16, "referenc": 16, "product": 16, "pattern": 16, "schema": 16, "current": 16, "u": 16, "onc": [16, 19], "whatev": [16, 19], "wa": [16, 19], "read": 16, "detail": 16, "handl": 16, "found": 16, "folder": 17, "check": 18, "output": 18, "given": [18, 19], "normal": 18, "full": 18, "lot": 18, "time": 18, "complic": 18, "thei": 18, "bunch": 18, "separ": 18, "step": 18, "unit": 18, "abl": 18, "singl": 18, "To": 18, "assum": [18, 19], "subscriptions_per_us": 18, "sub": 18, "ON": 18, "users_with_multiple_sub": 18, "test_queri": [15, 18], "multiplesubscriptionuserst": [15, 18], "now": 18, "differ": [15, 18], "def": 18, "test_model": 18, "subscriptions_per_user__expect": 18, "users_with_multiple_subs__expect": 18, "end_result__expect": 18, "end": 18, "multipl": [15, 19], "walk": 19, "through": 19, "cover": 19, "bigquerytablemock": 19, "itself": 19, "advantag": 19, "after": 19, "mani": 19, "overwrid": 19, "sometim": 19, "dbt": 19, "necessari": 19, "context": 19, "created_at": 19, "creation_d": 19, "your_input_mock_inst": 19, "09": 19, "05": 19, "automat": 19, "_sql_dialect": 6, "dialect": 6, "leverag": 6, "sqlglot": 6, "sql_dialect": 6, "sql_mock_data": 6, "default_input": [6, 15, 16], "serv": 6, "other": [6, 15], "often": 15, "involv": 15, "repetit": 15, "sqlmock": 15, "effect": 15, "streamlin": 15, "By": 15, "reason": 15, "significantli": 15, "reduc": 15, "boilerpl": 15, "especi": 15, "deal": 15, "complex": 15, "explor": 15, "effici": 15, "level": [15, 16], "straightforward": 15, "particularli": 15, "function": 15, "oper": 15, "overrid": 15, "nala": 15, "No": 15, "accept": 15, "consid": 15, "up": 15, "demonstr": 15, "happi": 15, "valid": 15, "syntax": 15, "minim": 15, "subset": 15, "certain": 15, "help": 15, "focu": 15, "numer": 15, "between": 15, "frequent": 15, "new": 15, "prevent": 15, "extens": 15, "refactor": 15, "ani": 6, "skipvalid": 6}, "objects": {"": [[6, 0, 0, "-", "sql_mock"]], "sql_mock": [[7, 0, 0, "-", "bigquery"], [8, 0, 0, "-", "clickhouse"], [6, 0, 0, "-", "column_mocks"], [6, 0, 0, "-", "constants"], [6, 0, 0, "-", "exceptions"], [6, 0, 0, "-", "table_mocks"]], "sql_mock.bigquery": [[7, 0, 0, "-", "column_mocks"], [7, 0, 0, "-", "settings"], [7, 0, 0, "-", "table_mocks"]], "sql_mock.bigquery.column_mocks": [[7, 1, 1, "", "BigQueryColumnMock"], [7, 1, 1, "", "Date"], [7, 1, 1, "", "Decimal"], [7, 1, 1, "", "Float"], [7, 1, 1, "", "Int"], [7, 1, 1, "", "String"]], "sql_mock.bigquery.column_mocks.Date": [[7, 2, 1, "", "dtype"]], "sql_mock.bigquery.column_mocks.Float": [[7, 2, 1, "", "dtype"]], "sql_mock.bigquery.column_mocks.Int": [[7, 2, 1, "", "dtype"]], "sql_mock.bigquery.column_mocks.String": [[7, 2, 1, "", "dtype"]], "sql_mock.bigquery.settings": [[7, 1, 1, "", "BigQuerySettings"]], "sql_mock.bigquery.settings.BigQuerySettings": [[7, 2, 1, "", "google_application_credentials"], [7, 2, 1, "", "model_config"], [7, 2, 1, "", "model_fields"]], "sql_mock.bigquery.table_mocks": [[7, 1, 1, "", "BigQueryMockTable"]], "sql_mock.clickhouse": [[8, 0, 0, "-", "column_mocks"], [8, 0, 0, "-", "settings"], [8, 0, 0, "-", "table_mocks"]], "sql_mock.clickhouse.column_mocks": [[8, 1, 1, "", "Boolean"], [8, 1, 1, "", "ClickhouseColumnMock"], [8, 1, 1, "", "Date"], [8, 1, 1, "", "Datetime"], [8, 1, 1, "", "Datetime64"], [8, 1, 1, "", "Decimal"], [8, 1, 1, "", "Float"], [8, 1, 1, "", "Int"], [8, 1, 1, "", "String"]], "sql_mock.clickhouse.column_mocks.Boolean": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Date": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Datetime": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Datetime64": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Float": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Int": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.String": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.settings": [[8, 1, 1, "", "ClickHouseSettings"]], "sql_mock.clickhouse.settings.ClickHouseSettings": [[8, 2, 1, "", "host"], [8, 2, 1, "", "model_config"], [8, 2, 1, "", "model_fields"], [8, 2, 1, "", "password"], [8, 2, 1, "", "port"], [8, 2, 1, "", "user"]], "sql_mock.clickhouse.table_mocks": [[8, 1, 1, "", "ClickHouseTableMock"]], "sql_mock.column_mocks": [[6, 1, 1, "", "ColumnMock"]], "sql_mock.column_mocks.ColumnMock": [[6, 3, 1, "", "cast_field"], [6, 2, 1, "id0", "default"], [6, 2, 1, "id1", "dtype"], [6, 2, 1, "id2", "nullable"], [6, 3, 1, "", "to_sql"]], "sql_mock.constants": [[6, 1, 1, "", "NoInput"]], "sql_mock.exceptions": [[6, 4, 1, "", "ValidationError"]], "sql_mock.table_mocks": [[6, 1, 1, "", "BaseMockTable"], [6, 1, 1, "", "MockTableMeta"], [6, 1, 1, "", "SQLMockData"], [6, 5, 1, "", "get_keys_from_list_of_dicts"], [6, 5, 1, "", "replace_original_table_references"], [6, 5, 1, "", "select_from_cte"], [6, 5, 1, "", "table_meta"], [6, 5, 1, "", "validate_input_mocks"]], "sql_mock.table_mocks.BaseMockTable": [[6, 2, 1, "", "_sql_dialect"], [6, 2, 1, "", "_sql_mock_data"], [6, 2, 1, "", "_sql_mock_meta"], [6, 3, 1, "", "as_sql_input"], [6, 3, 1, "", "assert_cte_equal"], [6, 3, 1, "", "assert_equal"], [6, 3, 1, "", "from_dicts"], [6, 3, 1, "", "from_mocks"]], "sql_mock.table_mocks.MockTableMeta": [[6, 2, 1, "", "model_config"], [6, 2, 1, "", "model_fields"], [6, 2, 1, "id3", "query"], [6, 2, 1, "id4", "table_ref"]], "sql_mock.table_mocks.SQLMockData": [[6, 2, 1, "", "columns"], [6, 2, 1, "", "data"], [6, 2, 1, "", "default_inputs"], [6, 2, 1, "", "input_data"], [6, 2, 1, "", "last_query"], [6, 2, 1, "", "model_config"], [6, 2, 1, "", "model_fields"], [6, 2, 1, "", "rendered_query"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:attribute", "3": "py:method", "4": "py:exception", "5": "py:function"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "attribute", "Python attribute"], "3": ["py", "method", "Python method"], "4": ["py", "exception", "Python exception"], "5": ["py", "function", "Python function"]}, "titleterms": {"faq": 0, "my": 0, "databas": [0, 3], "system": 0, "i": [0, 15], "support": 0, "yet": 0, "want": 0, "us": [0, 15, 19], "sql": [0, 3, 19], "mock": [0, 3, 15, 16], "what": 0, "should": 0, "do": 0, "creat": 0, "your": [0, 19], "mocktabl": [0, 15], "class": 0, "columnmock": 0, "contribut": 0, "setup": [0, 1], "am": 0, "miss": 0, "specif": [0, 3], "type": 0, "model": 0, "field": [0, 15], "instal": 1, "recommend": [1, 19], "pytest": 1, "quickstart": 2, "welcom": 3, "": 3, "document": 3, "get": 3, "start": 3, "basic": 3, "usag": 3, "api": 3, "refer": 3, "indic": 3, "tabl": [3, 16], "sql_mock": [4, 6, 7, 8], "packag": [6, 7, 8], "subpackag": 6, "submodul": [6, 7, 8], "column_mock": [6, 7, 8], "modul": [6, 7, 8], "constant": 6, "except": 6, "table_mock": [6, 7, 8], "content": [6, 7, 8], "bigqueri": [7, 9, 10], "set": [7, 8, 11, 14, 15], "clickhous": [8, 12, 13], "exampl": [9, 12, 17], "test": [9, 12, 19], "subscript": [9, 12], "count": [9, 12], "defin": 16, "result": 18, "assert": 18, "queri": 19, "wai": 19, "provid": 19, "option": 19, "1": 19, "table_meta": [15, 19], "decor": 19, "2": 19, "pass": 19, "from_mock": 19, "call": 19, "jinja": 19, "templat": 19, "default": 15, "valu": 15, "util": 15, "when": 15, "thi": 15}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 60}, "alltitles": {"FAQ": [[0, "faq"]], "My database system is not supported yet but I want to use SQL Mock. What should I do?": [[0, "my-database-system-is-not-supported-yet-but-i-want-to-use-sql-mock-what-should-i-do"]], "Create your MockTable class": [[0, "create-your-mocktable-class"]], "Create your ColumnMocks": [[0, "create-your-columnmocks"]], "Contribute your database setup": [[0, "contribute-your-database-setup"]], "I am missing a specific ColumnMock type for my model fields": [[0, "i-am-missing-a-specific-columnmock-type-for-my-model-fields"]], "Installation": [[1, "installation"]], "Recommended Setup for Pytest": [[1, "recommended-setup-for-pytest"]], "Quickstart": [[2, "quickstart"]], "Welcome to SQL Mock\u2019s documentation!": [[3, "welcome-to-sql-mock-s-documentation"]], "Getting Started": [[3, null]], "Basic Usage": [[3, null]], "Database Specifics": [[3, null]], "API Reference": [[3, null]], "Indices and tables": [[3, "indices-and-tables"]], "sql_mock": [[4, "sql-mock"]], "Example: Testing Subscription Counts in BigQuery": [[9, "example-testing-subscription-counts-in-bigquery"]], "BigQuery": [[10, "bigquery"]], "Settings": [[11, "settings"], [14, "settings"]], "Example: Testing Subscription Counts in ClickHouse": [[12, "example-testing-subscription-counts-in-clickhouse"]], "Clickhouse": [[13, "clickhouse"]], "Examples": [[17, "examples"]], "Result assertion": [[18, "result-assertion"]], "Your SQL query to test": [[19, "your-sql-query-to-test"]], "Ways to provide your SQL query to be tested": [[19, "ways-to-provide-your-sql-query-to-be-tested"]], "Option 1 (recommended): Use the table_meta decorator": [[19, "option-1-recommended-use-the-table-meta-decorator"]], "Option 2: Pass the query in the .from_mocks call": [[19, "option-2-pass-the-query-in-the-from-mocks-call"]], "Queries with Jinja templates": [[19, "queries-with-jinja-templates"]], "sql_mock package": [[6, "sql-mock-package"]], "Subpackages": [[6, "subpackages"]], "Submodules": [[6, "submodules"], [7, "submodules"], [8, "submodules"]], "sql_mock.column_mocks module": [[6, "module-sql_mock.column_mocks"]], "sql_mock.constants module": [[6, "module-sql_mock.constants"]], "sql_mock.exceptions module": [[6, "module-sql_mock.exceptions"]], "sql_mock.table_mocks module": [[6, "module-sql_mock.table_mocks"]], "Module contents": [[6, "module-sql_mock"], [7, "module-sql_mock.bigquery"], [8, "module-sql_mock.clickhouse"]], "sql_mock.bigquery package": [[7, "sql-mock-bigquery-package"]], "sql_mock.bigquery.column_mocks module": [[7, "module-sql_mock.bigquery.column_mocks"]], "sql_mock.bigquery.settings module": [[7, "module-sql_mock.bigquery.settings"]], "sql_mock.bigquery.table_mocks module": [[7, "module-sql_mock.bigquery.table_mocks"]], "sql_mock.clickhouse package": [[8, "sql-mock-clickhouse-package"]], "sql_mock.clickhouse.column_mocks module": [[8, "module-sql_mock.clickhouse.column_mocks"]], "sql_mock.clickhouse.settings module": [[8, "module-sql_mock.clickhouse.settings"]], "sql_mock.clickhouse.table_mocks module": [[8, "module-sql_mock.clickhouse.table_mocks"]], "Default values": [[15, "default-values"]], "Utilizing Default Values in MockTable Fields": [[15, "utilizing-default-values-in-mocktable-fields"]], "Setting Mock Defaults with table_meta": [[15, "setting-mock-defaults-with-table-meta"]], "When is this useful?": [[15, "when-is-this-useful"]], "Defining table mocks": [[16, "defining-table-mocks"]]}, "indexentries": {"module": [[3, "module-sql_mock"], [6, "module-sql_mock"], [6, "module-sql_mock.column_mocks"], [6, "module-sql_mock.constants"], [6, "module-sql_mock.exceptions"], [6, "module-sql_mock.table_mocks"], [7, "module-sql_mock.bigquery"], [7, "module-sql_mock.bigquery.column_mocks"], [7, "module-sql_mock.bigquery.settings"], [7, "module-sql_mock.bigquery.table_mocks"], [8, "module-sql_mock.clickhouse"], [8, "module-sql_mock.clickhouse.column_mocks"], [8, "module-sql_mock.clickhouse.settings"], [8, "module-sql_mock.clickhouse.table_mocks"]], "sql_mock": [[3, "module-sql_mock"], [6, "module-sql_mock"]], "basemocktable (class in sql_mock.table_mocks)": [[6, "sql_mock.table_mocks.BaseMockTable"]], "columnmock (class in sql_mock.column_mocks)": [[6, "sql_mock.column_mocks.ColumnMock"]], "mocktablemeta (class in sql_mock.table_mocks)": [[6, "sql_mock.table_mocks.MockTableMeta"]], "noinput (class in sql_mock.constants)": [[6, "sql_mock.constants.NoInput"]], "sqlmockdata (class in sql_mock.table_mocks)": [[6, "sql_mock.table_mocks.SQLMockData"]], "validationerror": [[6, "sql_mock.exceptions.ValidationError"]], "_sql_dialect (sql_mock.table_mocks.basemocktable attribute)": [[6, "sql_mock.table_mocks.BaseMockTable._sql_dialect"]], "_sql_mock_data (sql_mock.table_mocks.basemocktable attribute)": [[6, "sql_mock.table_mocks.BaseMockTable._sql_mock_data"]], "_sql_mock_meta (sql_mock.table_mocks.basemocktable attribute)": [[6, "sql_mock.table_mocks.BaseMockTable._sql_mock_meta"]], "as_sql_input() (sql_mock.table_mocks.basemocktable method)": [[6, "sql_mock.table_mocks.BaseMockTable.as_sql_input"]], "assert_cte_equal() (sql_mock.table_mocks.basemocktable method)": [[6, "sql_mock.table_mocks.BaseMockTable.assert_cte_equal"]], "assert_equal() (sql_mock.table_mocks.basemocktable method)": [[6, "sql_mock.table_mocks.BaseMockTable.assert_equal"]], "cast_field() (sql_mock.column_mocks.columnmock method)": [[6, "sql_mock.column_mocks.ColumnMock.cast_field"]], "columns (sql_mock.table_mocks.sqlmockdata attribute)": [[6, "sql_mock.table_mocks.SQLMockData.columns"]], "data (sql_mock.table_mocks.sqlmockdata attribute)": [[6, "sql_mock.table_mocks.SQLMockData.data"]], "default (sql_mock.column_mocks.columnmock attribute)": [[6, "id0"], [6, "sql_mock.column_mocks.ColumnMock.default"]], "default_inputs (sql_mock.table_mocks.sqlmockdata attribute)": [[6, "sql_mock.table_mocks.SQLMockData.default_inputs"]], "dtype (sql_mock.column_mocks.columnmock attribute)": [[6, "id1"], [6, "sql_mock.column_mocks.ColumnMock.dtype"]], "from_dicts() (sql_mock.table_mocks.basemocktable class method)": [[6, "sql_mock.table_mocks.BaseMockTable.from_dicts"]], "from_mocks() (sql_mock.table_mocks.basemocktable class method)": [[6, "sql_mock.table_mocks.BaseMockTable.from_mocks"]], "get_keys_from_list_of_dicts() (in module sql_mock.table_mocks)": [[6, "sql_mock.table_mocks.get_keys_from_list_of_dicts"]], "input_data (sql_mock.table_mocks.sqlmockdata attribute)": [[6, "sql_mock.table_mocks.SQLMockData.input_data"]], "last_query (sql_mock.table_mocks.sqlmockdata attribute)": [[6, "sql_mock.table_mocks.SQLMockData.last_query"]], "model_config (sql_mock.table_mocks.mocktablemeta attribute)": [[6, "sql_mock.table_mocks.MockTableMeta.model_config"]], "model_config (sql_mock.table_mocks.sqlmockdata attribute)": [[6, "sql_mock.table_mocks.SQLMockData.model_config"]], "model_fields (sql_mock.table_mocks.mocktablemeta attribute)": [[6, "sql_mock.table_mocks.MockTableMeta.model_fields"]], "model_fields (sql_mock.table_mocks.sqlmockdata attribute)": [[6, "sql_mock.table_mocks.SQLMockData.model_fields"]], "nullable (sql_mock.column_mocks.columnmock attribute)": [[6, "id2"], [6, "sql_mock.column_mocks.ColumnMock.nullable"]], "query (sql_mock.table_mocks.mocktablemeta attribute)": [[6, "id3"], [6, "sql_mock.table_mocks.MockTableMeta.query"]], "rendered_query (sql_mock.table_mocks.sqlmockdata attribute)": [[6, "sql_mock.table_mocks.SQLMockData.rendered_query"]], "replace_original_table_references() (in module sql_mock.table_mocks)": [[6, "sql_mock.table_mocks.replace_original_table_references"]], "select_from_cte() (in module sql_mock.table_mocks)": [[6, "sql_mock.table_mocks.select_from_cte"]], "sql_mock.column_mocks": [[6, "module-sql_mock.column_mocks"]], "sql_mock.constants": [[6, "module-sql_mock.constants"]], "sql_mock.exceptions": [[6, "module-sql_mock.exceptions"]], "sql_mock.table_mocks": [[6, "module-sql_mock.table_mocks"]], "table_meta() (in module sql_mock.table_mocks)": [[6, "sql_mock.table_mocks.table_meta"]], "table_ref (sql_mock.table_mocks.mocktablemeta attribute)": [[6, "id4"], [6, "sql_mock.table_mocks.MockTableMeta.table_ref"]], "to_sql() (sql_mock.column_mocks.columnmock method)": [[6, "sql_mock.column_mocks.ColumnMock.to_sql"]], "validate_input_mocks() (in module sql_mock.table_mocks)": [[6, "sql_mock.table_mocks.validate_input_mocks"]], "bigquerycolumnmock (class in sql_mock.bigquery.column_mocks)": [[7, "sql_mock.bigquery.column_mocks.BigQueryColumnMock"]], "bigquerymocktable (class in sql_mock.bigquery.table_mocks)": [[7, "sql_mock.bigquery.table_mocks.BigQueryMockTable"]], "bigquerysettings (class in sql_mock.bigquery.settings)": [[7, "sql_mock.bigquery.settings.BigQuerySettings"]], "date (class in sql_mock.bigquery.column_mocks)": [[7, "sql_mock.bigquery.column_mocks.Date"]], "decimal (class in sql_mock.bigquery.column_mocks)": [[7, "sql_mock.bigquery.column_mocks.Decimal"]], "float (class in sql_mock.bigquery.column_mocks)": [[7, "sql_mock.bigquery.column_mocks.Float"]], "int (class in sql_mock.bigquery.column_mocks)": [[7, "sql_mock.bigquery.column_mocks.Int"]], "string (class in sql_mock.bigquery.column_mocks)": [[7, "sql_mock.bigquery.column_mocks.String"]], "dtype (sql_mock.bigquery.column_mocks.date attribute)": [[7, "sql_mock.bigquery.column_mocks.Date.dtype"]], "dtype (sql_mock.bigquery.column_mocks.float attribute)": [[7, "sql_mock.bigquery.column_mocks.Float.dtype"]], "dtype (sql_mock.bigquery.column_mocks.int attribute)": [[7, "sql_mock.bigquery.column_mocks.Int.dtype"]], "dtype (sql_mock.bigquery.column_mocks.string attribute)": [[7, "sql_mock.bigquery.column_mocks.String.dtype"]], "google_application_credentials (sql_mock.bigquery.settings.bigquerysettings attribute)": [[7, "sql_mock.bigquery.settings.BigQuerySettings.google_application_credentials"]], "model_config (sql_mock.bigquery.settings.bigquerysettings attribute)": [[7, "sql_mock.bigquery.settings.BigQuerySettings.model_config"]], "model_fields (sql_mock.bigquery.settings.bigquerysettings attribute)": [[7, "sql_mock.bigquery.settings.BigQuerySettings.model_fields"]], "sql_mock.bigquery": [[7, "module-sql_mock.bigquery"]], "sql_mock.bigquery.column_mocks": [[7, "module-sql_mock.bigquery.column_mocks"]], "sql_mock.bigquery.settings": [[7, "module-sql_mock.bigquery.settings"]], "sql_mock.bigquery.table_mocks": [[7, "module-sql_mock.bigquery.table_mocks"]], "boolean (class in sql_mock.clickhouse.column_mocks)": [[8, "sql_mock.clickhouse.column_mocks.Boolean"]], "clickhousesettings (class in sql_mock.clickhouse.settings)": [[8, "sql_mock.clickhouse.settings.ClickHouseSettings"]], "clickhousetablemock (class in sql_mock.clickhouse.table_mocks)": [[8, "sql_mock.clickhouse.table_mocks.ClickHouseTableMock"]], "clickhousecolumnmock (class in sql_mock.clickhouse.column_mocks)": [[8, "sql_mock.clickhouse.column_mocks.ClickhouseColumnMock"]], "date (class in sql_mock.clickhouse.column_mocks)": [[8, "sql_mock.clickhouse.column_mocks.Date"]], "datetime (class in sql_mock.clickhouse.column_mocks)": [[8, "sql_mock.clickhouse.column_mocks.Datetime"]], "datetime64 (class in sql_mock.clickhouse.column_mocks)": [[8, "sql_mock.clickhouse.column_mocks.Datetime64"]], "decimal (class in sql_mock.clickhouse.column_mocks)": [[8, "sql_mock.clickhouse.column_mocks.Decimal"]], "float (class in sql_mock.clickhouse.column_mocks)": [[8, "sql_mock.clickhouse.column_mocks.Float"]], "int (class in sql_mock.clickhouse.column_mocks)": [[8, "sql_mock.clickhouse.column_mocks.Int"]], "string (class in sql_mock.clickhouse.column_mocks)": [[8, "sql_mock.clickhouse.column_mocks.String"]], "dtype (sql_mock.clickhouse.column_mocks.boolean attribute)": [[8, "sql_mock.clickhouse.column_mocks.Boolean.dtype"]], "dtype (sql_mock.clickhouse.column_mocks.date attribute)": [[8, "sql_mock.clickhouse.column_mocks.Date.dtype"]], "dtype (sql_mock.clickhouse.column_mocks.datetime attribute)": [[8, "sql_mock.clickhouse.column_mocks.Datetime.dtype"]], "dtype (sql_mock.clickhouse.column_mocks.datetime64 attribute)": [[8, "sql_mock.clickhouse.column_mocks.Datetime64.dtype"]], "dtype (sql_mock.clickhouse.column_mocks.float attribute)": [[8, "sql_mock.clickhouse.column_mocks.Float.dtype"]], "dtype (sql_mock.clickhouse.column_mocks.int attribute)": [[8, "sql_mock.clickhouse.column_mocks.Int.dtype"]], "dtype (sql_mock.clickhouse.column_mocks.string attribute)": [[8, "sql_mock.clickhouse.column_mocks.String.dtype"]], "host (sql_mock.clickhouse.settings.clickhousesettings attribute)": [[8, "sql_mock.clickhouse.settings.ClickHouseSettings.host"]], "model_config (sql_mock.clickhouse.settings.clickhousesettings attribute)": [[8, "sql_mock.clickhouse.settings.ClickHouseSettings.model_config"]], "model_fields (sql_mock.clickhouse.settings.clickhousesettings attribute)": [[8, "sql_mock.clickhouse.settings.ClickHouseSettings.model_fields"]], "password (sql_mock.clickhouse.settings.clickhousesettings attribute)": [[8, "sql_mock.clickhouse.settings.ClickHouseSettings.password"]], "port (sql_mock.clickhouse.settings.clickhousesettings attribute)": [[8, "sql_mock.clickhouse.settings.ClickHouseSettings.port"]], "sql_mock.clickhouse": [[8, "module-sql_mock.clickhouse"]], "sql_mock.clickhouse.column_mocks": [[8, "module-sql_mock.clickhouse.column_mocks"]], "sql_mock.clickhouse.settings": [[8, "module-sql_mock.clickhouse.settings"]], "sql_mock.clickhouse.table_mocks": [[8, "module-sql_mock.clickhouse.table_mocks"]], "user (sql_mock.clickhouse.settings.clickhousesettings attribute)": [[8, "sql_mock.clickhouse.settings.ClickHouseSettings.user"]]}}) \ No newline at end of file +Search.setIndex({"docnames": ["faq", "getting_started/installation", "getting_started/quickstart", "index", "modules", "robots", "sql_mock", "sql_mock.bigquery", "sql_mock.clickhouse", "usage/bigquery/examples", "usage/bigquery/index", "usage/bigquery/settings", "usage/clickhouse/examples", "usage/clickhouse/index", "usage/clickhouse/settings", "usage/default_values", "usage/defining_table_mocks", "usage/examples", "usage/result_assertion", "usage/your_sql_query_to_test"], "filenames": ["faq.md", "getting_started/installation.md", "getting_started/quickstart.md", "index.rst", "modules.rst", "robots.txt", "sql_mock.rst", "sql_mock.bigquery.rst", "sql_mock.clickhouse.rst", "usage/bigquery/examples.md", "usage/bigquery/index.rst", "usage/bigquery/settings.md", "usage/clickhouse/examples.md", "usage/clickhouse/index.rst", "usage/clickhouse/settings.md", "usage/default_values.md", "usage/defining_table_mocks.md", "usage/examples.md", "usage/result_assertion.md", "usage/your_sql_query_to_test.md"], "titles": ["FAQ", "Installation", "Quickstart", "Welcome to SQL Mock\u2019s documentation!", "sql_mock", "<no title>", "sql_mock package", "sql_mock.bigquery package", "sql_mock.clickhouse package", "Example: Testing Subscription Counts in BigQuery", "BigQuery", "Settings", "Example: Testing Subscription Counts in ClickHouse", "Clickhouse", "Settings", "Default values", "Defining table mocks", "Examples", "Result assertion", "Your SQL query to test"], "terms": {"we": [0, 1, 2, 6, 15, 16, 18, 19], "ar": [0, 1, 6, 15, 16, 18, 19], "plan": 0, "add": [0, 1, 6], "more": [0, 2, 16, 18], "howev": 0, "you": [0, 1, 2, 6, 11, 14, 15, 16, 17, 18, 19], "can": [0, 1, 2, 6, 15, 16, 17, 18, 19], "still": 0, "There": [0, 16, 18, 19], "onli": [0, 6, 15, 16, 18, 19], "2": [0, 2, 3, 9, 12, 15, 16, 18], "thing": [0, 16], "need": [0, 1, 3, 6, 11, 14, 15, 16, 19], "first": 0, "inherit": [0, 6, 9, 12, 16], "from": [0, 1, 2, 6, 7, 8, 9, 12, 16, 18, 19], "sql_mock": [0, 1, 2, 9, 12, 16, 18], "table_mock": [0, 2, 9, 12, 16, 18], "basemockt": [0, 6, 7, 8, 16], "That": 0, "implement": [0, 15], "_get_result": 0, "method": [0, 1, 2, 15, 16, 18, 19], "which": [0, 6], "make": [0, 1], "sure": [0, 1], "fetch": 0, "result": [0, 2, 3, 6, 9, 12, 16], "queri": [0, 2, 3, 6, 9, 12, 15, 16, 18], "e": [0, 2, 6, 16, 19], "g": [0, 2, 6, 16, 19], "produc": 0, "self": 0, "_generate_queri": 0, "return": [0, 6], "list": [0, 6], "dictionari": [0, 2, 6, 7, 8, 19], "look": 0, "one": [0, 6, 15], "exist": 0, "client": 0, "librari": [0, 1, 3], "see": 0, "how": [0, 2, 10, 13, 15, 16, 18, 19], "thi": [0, 1, 2, 3, 6, 7, 8, 10, 13, 16, 18, 19], "could": 0, "work": [0, 2, 15], "bigquerymockt": [0, 2, 6, 7, 9, 15, 16, 18], "might": 0, "set": [0, 3, 6, 10, 13], "well": [0, 16], "case": [0, 18, 19], "some": [0, 2, 16, 17, 19], "connect": [0, 11, 14], "avail": [0, 2], "within": [0, 6], "In": [0, 1, 2, 11, 14, 15, 18, 19], "order": [0, 6, 11, 14], "them": [0, 6, 16, 19], "column": [0, 2, 6], "column_mock": [0, 2, 9, 12, 16, 18], "base": [0, 2, 6, 7, 8], "For": [0, 15], "most": 0, "specifi": [0, 2, 15, 16, 19], "dtype": [0, 6, 7, 8], "pars": 0, "input": [0, 2, 3, 6, 15, 16, 18, 19], "A": [0, 6, 18], "good": 0, "practis": 0, "all": [0, 1, 2, 6, 15, 16], "import": [0, 1, 2, 9, 12, 16, 18], "myfancedatabasecolumnmock": 0, "logic": [0, 15, 18], "overwrit": [0, 6, 16], "default": [0, 2, 3, 6, 7, 8, 9, 12, 16, 18, 19], "behavior": 0, "so": 0, "here": [0, 15], "pass": [0, 3, 15, 16], "int": [0, 2, 6, 7, 8, 9, 12, 15, 16, 18, 19], "integ": [0, 7, 8], "string": [0, 2, 6, 7, 8, 9, 12, 15, 16, 18, 19], "definit": [0, 15, 16], "folk": 0, "commun": 0, "just": 0, "feel": 0, "free": 0, "pr": 0, "repositori": 0, "start": [0, 2], "implementd": 0, "basic": [0, 15], "happen": [0, 6], "don": [0, 2, 15], "t": [0, 2, 9, 12, 15, 18], "find": [0, 17], "luckili": 0, "easili": [0, 16], "those": [0, 14, 16, 18, 19], "tool": 0, "provid": [0, 2, 3, 6, 14, 15, 16], "The": [0, 1, 3, 6, 15, 16, 19], "bigquerycolumnmock": [0, 6, 7], "write": 0, "usual": [0, 16], "correct": [0, 15], "would": [0, 6], "later": 0, "cast": [0, 2], "col": [0, 2, 9, 12, 15, 16, 18, 19], "express": [0, 2], "replac": [0, 2, 6, 7, 8], "bigqueri": [0, 1, 3, 6, 11, 16, 18], "myfancymissingcoltyp": 0, "fancymissingcoltyp": 0, "addit": [0, 15], "forget": 0, "pypi": 1, "us": [1, 2, 3, 6, 9, 10, 11, 12, 13, 14, 16, 18], "pip": 1, "upgrad": 1, "sql": [1, 2, 5, 6, 9, 10, 11, 12, 13, 14, 15, 16, 18], "mock": [1, 2, 5, 6, 9, 10, 11, 12, 13, 14, 18, 19], "clickhous": [1, 2, 3, 6, 14], "If": [1, 6], "modifi": 1, "sourc": 1, "code": [1, 15], "depend": 1, "poetri": 1, "extra": [1, 7, 8], "conftest": 1, "py": [1, 16, 19], "file": [1, 6, 11, 16, 19], "root": 1, "your": [1, 2, 3, 9, 12, 14, 15, 16, 18], "project": 1, "follow": [1, 14, 18, 19], "line": 1, "register_assert_rewrit": 1, "allow": [1, 3, 15, 16], "get": [1, 2], "rich": 1, "comparison": [1, 6], "when": [1, 3, 6, 14, 16, 18, 19], "assert_equ": [1, 2, 6, 9, 12, 18], "tabl": [1, 2, 6, 9, 12, 15, 18, 19], "instanc": [1, 2, 6, 14, 15, 16, 18, 19], "also": [1, 16, 18, 19], "icdiff": 1, "better": 1, "visibl": 1, "diff": 1, "fail": 1, "test": [1, 3, 6, 10, 11, 13, 14, 15, 16, 18], "befor": 2, "dive": 2, "specif": [2, 10, 13, 15, 19], "databas": [2, 6, 16], "scenario": [2, 3, 15], "let": [2, 11, 15, 18, 19], "": [2, 6, 15, 18, 19], "simplifi": [2, 3, 15], "exampl": [2, 3, 10, 13, 15, 18, 19], "behind": 2, "scene": 2, "have": [2, 11, 14, 16, 18], "an": [2, 15], "origin": [2, 6, 9, 12], "path": [2, 6, 7, 8, 15, 16, 19], "query_for_result_t": [2, 16, 19], "select": [2, 6, 9, 12, 16, 18, 19], "id": [2, 16, 19], "data": [2, 3, 6, 9, 12, 15, 16, 18, 19], "table1": [2, 16], "defin": [2, 3, 6, 7, 8, 9, 12, 15, 18, 19], "built": [2, 18], "type": [2, 3, 6], "includ": [2, 18], "date": [2, 6, 7, 8, 9, 12, 18], "each": 2, "ha": 2, "own": 2, "subclass": 2, "class": [2, 3, 6, 7, 8, 9, 12, 15, 16, 18, 19], "fit": 2, "along": 2, "valu": [2, 3, 6], "our": [2, 18], "clickhousetablemock": [2, 6, 8, 12], "table_meta": [2, 3, 6, 9, 12, 16, 18], "table_ref": [2, 6, 9, 12, 15, 16, 18, 19], "1": [2, 3, 6, 9, 12, 15, 16, 18], "name": [2, 6, 7, 8, 16], "peter": [2, 16], "result_t": [2, 16, 19], "query_path": [2, 6, 15, 16, 18, 19], "resultt": [2, 16, 19], "creat": [2, 3, 6, 9, 12, 15, 16], "repres": [2, 6], "row": [2, 6], "kei": [2, 6], "correspond": 2, "user_data": 2, "both": 2, "martin": 2, "3": [2, 15], "input_table_mock": 2, "from_dict": [2, 6, 9, 12, 15, 18], "from_mock": [2, 3, 6, 9, 12, 15, 16, 18], "object": [2, 6], "gener": [2, 6], "re": [2, 9, 12, 15, 16, 18, 19], "input_data": [2, 6, 9, 12, 15, 16, 18, 19], "refer": [2, 6], "common": 2, "cte": [2, 6, 18], "fill": 2, "dummi": 2, "It": [2, 3, 6], "roughli": 2, "compar": [2, 6], "someth": 2, "like": [2, 6, 16], "WITH": [2, 18], "data__table1": 2, "AS": [2, 9, 12, 18, 19], "union": [2, 6], "final": [2, 6, 18], "expect": [2, 6, 9, 12], "primari": 3, "purpos": 3, "i": [3, 6, 16, 19], "model": [3, 6, 7, 8, 9, 12, 16, 18, 19], "user": [3, 5, 6, 8, 9, 12, 14, 15, 18, 19], "variou": [3, 15], "consist": [3, 15], "conveni": 3, "wai": [3, 15, 16, 18], "execut": 3, "without": 3, "process": [3, 6, 15], "massiv": 3, "amount": 3, "instal": 3, "recommend": [3, 16], "setup": [3, 15], "pytest": 3, "quickstart": 3, "faq": 3, "my": 3, "system": 3, "support": 3, "yet": 3, "want": [3, 6, 14, 16, 18, 19], "what": 3, "should": [3, 6, 7, 8], "do": [3, 18], "mocktabl": [3, 6, 16], "columnmock": [3, 6, 7, 8], "contribut": 3, "am": 3, "miss": 3, "field": [3, 6, 7, 8], "option": 3, "decor": [3, 6, 15, 16], "call": 3, "jinja": [3, 6], "templat": [3, 6], "assert": [3, 6, 9, 12], "subscript": [3, 10, 13, 15, 18], "count": [3, 10, 13, 18], "index": 3, "modul": 3, "search": 3, "page": 3, "agent": 5, "sitemap": 5, "http": 5, "deeplcom": 5, "github": 5, "io": 5, "xml": 5, "decim": [6, 7, 8], "float": [6, 7, 8], "bigqueryset": [6, 7], "google_application_credenti": [6, 7, 11], "model_config": [6, 7, 8], "model_field": [6, 7, 8], "boolean": [6, 8], "clickhousecolumnmock": [6, 8], "datetim": [6, 8, 9, 12, 18], "datetime64": [6, 8], "clickhouseset": [6, 8], "host": [6, 8, 14], "password": [6, 8, 14], "port": [6, 8, 14], "none": [6, 7, 8], "nullabl": [6, 7, 8], "fals": [6, 7, 8], "str": [6, 7, 8], "indic": 6, "whether": 6, "null": 6, "cast_field": 6, "column_nam": 6, "to_sql": 6, "noinput": 6, "validationerror": 6, "dict": [6, 7, 8], "attribut": 6, "col1": 6, "_sql_mock_data": 6, "store": 6, "automatci": 6, "instanti": 6, "sqlmockdata": 6, "_sql_mock_meta": 6, "metadata": [6, 7, 8], "mocktablemeta": 6, "as_sql_input": 6, "combin": [6, 15], "assert_cte_equ": [6, 18], "cte_nam": 6, "ignore_missing_kei": 6, "bool": [6, 7, 8], "ignore_ord": 6, "true": [6, 7, 8], "equal": 6, "paramet": 6, "against": 6, "present": 6, "argument": [6, 15, 16, 19], "ignor": 6, "classmethod": 6, "query_template_kwarg": [6, 19], "run": [6, 11, 14, 18], "static": 6, "hold": 6, "pair": 6, "render": [6, 19], "cl": 6, "basemodel": 6, "dure": 6, "avoid": 6, "collis": 6, "srting": 6, "format": 6, "classvar": [6, 7, 8], "configdict": [6, 7, 8], "configur": [6, 7, 8], "conform": [6, 7, 8], "pydant": [6, 7, 8], "config": [6, 7, 8], "fieldinfo": [6, 7, 8], "annot": [6, 7, 8], "requir": [6, 7, 8, 15], "about": [6, 7, 8], "map": [6, 7, 8, 18], "__fields__": [6, 7, 8], "v1": [6, 7, 8], "rendered_queri": 6, "last_queri": 6, "get_keys_from_list_of_dict": 6, "replace_original_table_refer": 6, "mock_tabl": 6, "orign": 6, "point": [6, 11], "select_from_ct": 6, "statement": 6, "select_ct": 6, "note": [6, 19], "validate_input_mock": 6, "precis": [7, 8], "scale": [7, 8], "_case_sensit": [7, 8], "_env_prefix": [7, 8], "_env_fil": [7, 8], "dotenvtyp": [7, 8], "posixpath": [7, 8], "_env_file_encod": [7, 8], "_env_nested_delimit": [7, 8], "_secrets_dir": [7, 8], "baseset": [7, 8], "settingsconfigdict": [7, 8], "arbitrary_types_allow": [6, 7, 8], "case_sensit": [7, 8], "env_fil": [7, 8], "env_file_encod": [7, 8], "env_nested_delimit": [7, 8], "env_prefix": [7, 8], "forbid": [7, 8], "protected_namespac": [7, 8], "model_": [7, 8], "settings_": [7, 8], "secrets_dir": [7, 8], "validate_default": [7, 8], "arg": [7, 8], "kwarg": [7, 8], "sql_mock_clickhouse_": 8, "usert": [9, 12, 15, 18], "user_id": [9, 12, 15, 18, 19], "user_nam": [9, 12, 15, 18], "mr": [9, 12, 15, 18], "subscriptiont": [9, 12, 15, 18], "subscription_id": [9, 12, 15, 18], "period_start_d": [9, 12, 18], "2023": [9, 12, 18, 19], "9": [9, 12, 18], "5": [9, 12, 18], "period_end_d": [9, 12, 18], "subscriptioncountt": [9, 12], "subscription_count": [9, 12, 18], "left": [9, 12, 15, 18], "join": [9, 12, 15, 18], "group": [9, 12, 18], "BY": [9, 12, 18], "simul": [9, 12], "section": [10, 13, 16], "document": [10, 13], "ensur": [11, 15], "environ": [11, 14], "variabl": [11, 14, 19], "correctli": [11, 15], "servic": 11, "account": 11, "while": 11, "sql_mock_clickhouse_host": 14, "sql_mock_clickhouse_us": 14, "sql_mock_clickhouse_password": 14, "sql_mock_clickhouse_port": 14, "enabl": 14, "upstream": 16, "central": 16, "where": [16, 18, 19], "reus": [16, 19], "across": [15, 16], "goign": 16, "mention": 16, "referenc": 16, "product": 16, "pattern": 16, "schema": 16, "current": 16, "u": 16, "onc": [16, 19], "whatev": [16, 19], "wa": [16, 19], "read": 16, "detail": 16, "handl": 16, "found": 16, "folder": 17, "check": 18, "output": 18, "given": [18, 19], "normal": 18, "full": 18, "lot": 18, "time": 18, "complic": 18, "thei": [15, 18], "bunch": 18, "separ": 18, "step": [15, 18], "unit": 18, "abl": 18, "singl": 18, "To": 18, "assum": [18, 19], "subscriptions_per_us": 18, "sub": 18, "ON": 18, "users_with_multiple_sub": 18, "test_queri": [15, 18], "multiplesubscriptionuserst": [15, 18], "now": 18, "differ": [15, 18], "def": 18, "test_model": 18, "subscriptions_per_user__expect": 18, "users_with_multiple_subs__expect": 18, "end_result__expect": 18, "end": 18, "multipl": [15, 19], "walk": 19, "through": 19, "cover": 19, "bigquerytablemock": 19, "itself": 19, "advantag": 19, "after": 19, "mani": 19, "overwrid": 19, "sometim": 19, "dbt": 19, "necessari": 19, "context": 19, "created_at": 19, "creation_d": 19, "your_input_mock_inst": 19, "09": 19, "05": 19, "automat": 19, "_sql_dialect": 6, "dialect": 6, "leverag": 6, "sqlglot": 6, "sql_dialect": 6, "sql_mock_data": 6, "default_input": [6, 15, 16], "serv": 6, "other": [6, 15], "often": 15, "involv": 15, "repetit": 15, "sqlmock": 15, "effect": 15, "streamlin": 15, "By": 15, "reason": 15, "significantli": 15, "reduc": 15, "boilerpl": 15, "especi": 15, "deal": 15, "complex": 15, "explor": 15, "effici": 15, "level": [15, 16], "straightforward": 15, "particularli": 15, "function": 15, "oper": 15, "overrid": 15, "nala": 15, "No": 15, "accept": 15, "consid": 15, "up": 15, "demonstr": 15, "happi": 15, "valid": 15, "syntax": 15, "minim": 15, "subset": 15, "certain": 15, "help": 15, "focu": 15, "numer": 15, "between": 15, "frequent": 15, "new": 15, "prevent": 15, "extens": 15, "refactor": 15, "ani": 6, "skipvalid": 6, "empti": 15, "util": 3}, "objects": {"": [[3, 0, 0, "-", "sql_mock"]], "sql_mock": [[7, 0, 0, "-", "bigquery"], [8, 0, 0, "-", "clickhouse"], [6, 0, 0, "-", "column_mocks"], [6, 0, 0, "-", "constants"], [6, 0, 0, "-", "exceptions"], [6, 0, 0, "-", "table_mocks"]], "sql_mock.bigquery": [[7, 0, 0, "-", "column_mocks"], [7, 0, 0, "-", "settings"], [7, 0, 0, "-", "table_mocks"]], "sql_mock.bigquery.column_mocks": [[7, 1, 1, "", "BigQueryColumnMock"], [7, 1, 1, "", "Date"], [7, 1, 1, "", "Decimal"], [7, 1, 1, "", "Float"], [7, 1, 1, "", "Int"], [7, 1, 1, "", "String"]], "sql_mock.bigquery.column_mocks.Date": [[7, 2, 1, "", "dtype"]], "sql_mock.bigquery.column_mocks.Float": [[7, 2, 1, "", "dtype"]], "sql_mock.bigquery.column_mocks.Int": [[7, 2, 1, "", "dtype"]], "sql_mock.bigquery.column_mocks.String": [[7, 2, 1, "", "dtype"]], "sql_mock.bigquery.settings": [[7, 1, 1, "", "BigQuerySettings"]], "sql_mock.bigquery.settings.BigQuerySettings": [[7, 2, 1, "", "google_application_credentials"], [7, 2, 1, "", "model_config"], [7, 2, 1, "", "model_fields"]], "sql_mock.bigquery.table_mocks": [[7, 1, 1, "", "BigQueryMockTable"]], "sql_mock.clickhouse": [[8, 0, 0, "-", "column_mocks"], [8, 0, 0, "-", "settings"], [8, 0, 0, "-", "table_mocks"]], "sql_mock.clickhouse.column_mocks": [[8, 1, 1, "", "Boolean"], [8, 1, 1, "", "ClickhouseColumnMock"], [8, 1, 1, "", "Date"], [8, 1, 1, "", "Datetime"], [8, 1, 1, "", "Datetime64"], [8, 1, 1, "", "Decimal"], [8, 1, 1, "", "Float"], [8, 1, 1, "", "Int"], [8, 1, 1, "", "String"]], "sql_mock.clickhouse.column_mocks.Boolean": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Date": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Datetime": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Datetime64": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Float": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.Int": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.column_mocks.String": [[8, 2, 1, "", "dtype"]], "sql_mock.clickhouse.settings": [[8, 1, 1, "", "ClickHouseSettings"]], "sql_mock.clickhouse.settings.ClickHouseSettings": [[8, 2, 1, "", "host"], [8, 2, 1, "", "model_config"], [8, 2, 1, "", "model_fields"], [8, 2, 1, "", "password"], [8, 2, 1, "", "port"], [8, 2, 1, "", "user"]], "sql_mock.clickhouse.table_mocks": [[8, 1, 1, "", "ClickHouseTableMock"]], "sql_mock.column_mocks": [[6, 1, 1, "", "ColumnMock"]], "sql_mock.column_mocks.ColumnMock": [[6, 3, 1, "", "cast_field"], [6, 2, 1, "id0", "default"], [6, 2, 1, "id1", "dtype"], [6, 2, 1, "id2", "nullable"], [6, 3, 1, "", "to_sql"]], "sql_mock.constants": [[6, 1, 1, "", "NoInput"]], "sql_mock.exceptions": [[6, 4, 1, "", "ValidationError"]], "sql_mock.table_mocks": [[6, 1, 1, "", "BaseMockTable"], [6, 1, 1, "", "MockTableMeta"], [6, 1, 1, "", "SQLMockData"], [6, 5, 1, "", "get_keys_from_list_of_dicts"], [6, 5, 1, "", "replace_original_table_references"], [6, 5, 1, "", "select_from_cte"], [6, 5, 1, "", "table_meta"], [6, 5, 1, "", "validate_input_mocks"]], "sql_mock.table_mocks.BaseMockTable": [[6, 2, 1, "", "_sql_dialect"], [6, 2, 1, "", "_sql_mock_data"], [6, 2, 1, "", "_sql_mock_meta"], [6, 3, 1, "", "as_sql_input"], [6, 3, 1, "", "assert_cte_equal"], [6, 3, 1, "", "assert_equal"], [6, 3, 1, "", "from_dicts"], [6, 3, 1, "", "from_mocks"]], "sql_mock.table_mocks.MockTableMeta": [[6, 2, 1, "", "model_config"], [6, 2, 1, "", "model_fields"], [6, 2, 1, "id3", "query"], [6, 2, 1, "id4", "table_ref"]], "sql_mock.table_mocks.SQLMockData": [[6, 2, 1, "", "columns"], [6, 2, 1, "", "data"], [6, 2, 1, "", "default_inputs"], [6, 2, 1, "", "input_data"], [6, 2, 1, "", "last_query"], [6, 2, 1, "", "model_config"], [6, 2, 1, "", "model_fields"], [6, 2, 1, "", "rendered_query"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:attribute", "3": "py:method", "4": "py:exception", "5": "py:function"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "attribute", "Python attribute"], "3": ["py", "method", "Python method"], "4": ["py", "exception", "Python exception"], "5": ["py", "function", "Python function"]}, "titleterms": {"faq": 0, "my": 0, "databas": [0, 3], "system": 0, "i": [0, 15], "support": 0, "yet": 0, "want": 0, "us": [0, 15, 19], "sql": [0, 3, 19], "mock": [0, 3, 15, 16], "what": 0, "should": 0, "do": 0, "creat": 0, "your": [0, 19], "mocktabl": [0, 15], "class": 0, "columnmock": 0, "contribut": 0, "setup": [0, 1], "am": 0, "miss": 0, "specif": [0, 3], "type": 0, "model": 0, "field": [0, 15], "instal": 1, "recommend": [1, 19], "pytest": 1, "quickstart": 2, "welcom": 3, "": 3, "document": 3, "get": 3, "start": 3, "basic": 3, "usag": 3, "api": 3, "refer": 3, "indic": 3, "tabl": [3, 16], "sql_mock": [4, 6, 7, 8], "packag": [6, 7, 8], "subpackag": 6, "submodul": [6, 7, 8], "column_mock": [6, 7, 8], "modul": [6, 7, 8], "constant": 6, "except": 6, "table_mock": [6, 7, 8], "content": [6, 7, 8], "bigqueri": [7, 9, 10], "set": [7, 8, 11, 14, 15], "clickhous": [8, 12, 13], "exampl": [9, 12, 17], "test": [9, 12, 19], "subscript": [9, 12], "count": [9, 12], "defin": 16, "result": 18, "assert": 18, "queri": 19, "wai": 19, "provid": 19, "option": 19, "1": 19, "table_meta": [15, 19], "decor": 19, "2": 19, "pass": 19, "from_mock": 19, "call": 19, "jinja": 19, "templat": 19, "default": 15, "valu": 15, "util": 15, "when": 15, "thi": 15}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 60}, "alltitles": {"FAQ": [[0, "faq"]], "My database system is not supported yet but I want to use SQL Mock. What should I do?": [[0, "my-database-system-is-not-supported-yet-but-i-want-to-use-sql-mock-what-should-i-do"]], "Create your MockTable class": [[0, "create-your-mocktable-class"]], "Create your ColumnMocks": [[0, "create-your-columnmocks"]], "Contribute your database setup": [[0, "contribute-your-database-setup"]], "I am missing a specific ColumnMock type for my model fields": [[0, "i-am-missing-a-specific-columnmock-type-for-my-model-fields"]], "Installation": [[1, "installation"]], "Recommended Setup for Pytest": [[1, "recommended-setup-for-pytest"]], "Quickstart": [[2, "quickstart"]], "sql_mock": [[4, "sql-mock"]], "Example: Testing Subscription Counts in BigQuery": [[9, "example-testing-subscription-counts-in-bigquery"]], "BigQuery": [[10, "bigquery"]], "Settings": [[11, "settings"], [14, "settings"]], "Example: Testing Subscription Counts in ClickHouse": [[12, "example-testing-subscription-counts-in-clickhouse"]], "Clickhouse": [[13, "clickhouse"]], "Examples": [[17, "examples"]], "Result assertion": [[18, "result-assertion"]], "Your SQL query to test": [[19, "your-sql-query-to-test"]], "Ways to provide your SQL query to be tested": [[19, "ways-to-provide-your-sql-query-to-be-tested"]], "Option 1 (recommended): Use the table_meta decorator": [[19, "option-1-recommended-use-the-table-meta-decorator"]], "Option 2: Pass the query in the .from_mocks call": [[19, "option-2-pass-the-query-in-the-from-mocks-call"]], "Queries with Jinja templates": [[19, "queries-with-jinja-templates"]], "Defining table mocks": [[16, "defining-table-mocks"]], "sql_mock package": [[6, "sql-mock-package"]], "Subpackages": [[6, "subpackages"]], "Submodules": [[6, "submodules"], [7, "submodules"], [8, "submodules"]], "sql_mock.column_mocks module": [[6, "module-sql_mock.column_mocks"]], "sql_mock.constants module": [[6, "module-sql_mock.constants"]], "sql_mock.exceptions module": [[6, "module-sql_mock.exceptions"]], "sql_mock.table_mocks module": [[6, "module-sql_mock.table_mocks"]], "Module contents": [[6, "module-sql_mock"], [7, "module-sql_mock.bigquery"], [8, "module-sql_mock.clickhouse"]], "sql_mock.bigquery package": [[7, "sql-mock-bigquery-package"]], "sql_mock.bigquery.column_mocks module": [[7, "module-sql_mock.bigquery.column_mocks"]], "sql_mock.bigquery.settings module": [[7, "module-sql_mock.bigquery.settings"]], "sql_mock.bigquery.table_mocks module": [[7, "module-sql_mock.bigquery.table_mocks"]], "sql_mock.clickhouse package": [[8, "sql-mock-clickhouse-package"]], "sql_mock.clickhouse.column_mocks module": [[8, "module-sql_mock.clickhouse.column_mocks"]], "sql_mock.clickhouse.settings module": [[8, "module-sql_mock.clickhouse.settings"]], "sql_mock.clickhouse.table_mocks module": [[8, "module-sql_mock.clickhouse.table_mocks"]], "Default values": [[15, "default-values"]], "Utilizing Default Values in MockTable Fields": [[15, "utilizing-default-values-in-mocktable-fields"]], "Setting Mock Defaults with table_meta": [[15, "setting-mock-defaults-with-table-meta"]], "When is this useful?": [[15, "when-is-this-useful"]], "Welcome to SQL Mock\u2019s documentation!": [[3, "welcome-to-sql-mock-s-documentation"]], "Getting Started": [[3, null]], "Basic Usage": [[3, null]], "Database Specifics": [[3, null]], "API Reference": [[3, null]], "Indices and tables": [[3, "indices-and-tables"]]}, "indexentries": {"module": [[3, "module-sql_mock"]], "sql_mock": [[3, "module-sql_mock"]]}}) \ No newline at end of file diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 43e66e8..a6b6963 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -1,2 +1,2 @@ -https://deeplcom.github.io/sql-mock/en/index.htmlhttps://deeplcom.github.io/sql-mock/en/modules.htmlhttps://deeplcom.github.io/sql-mock/en/sql_mock.htmlhttps://deeplcom.github.io/sql-mock/en/sql_mock.bigquery.htmlhttps://deeplcom.github.io/sql-mock/en/sql_mock.clickhouse.htmlhttps://deeplcom.github.io/sql-mock/en/usage/default_values.htmlhttps://deeplcom.github.io/sql-mock/en/usage/defining_table_mocks.htmlhttps://deeplcom.github.io/sql-mock/en/genindex.htmlhttps://deeplcom.github.io/sql-mock/en/py-modindex.htmlhttps://deeplcom.github.io/sql-mock/en/search.html \ No newline at end of file +https://deeplcom.github.io/sql-mock/en/index.htmlhttps://deeplcom.github.io/sql-mock/en/genindex.htmlhttps://deeplcom.github.io/sql-mock/en/py-modindex.htmlhttps://deeplcom.github.io/sql-mock/en/search.html \ No newline at end of file diff --git a/docs/usage/default_values.html b/docs/usage/default_values.html index 33c16bf..1cd5d64 100644 --- a/docs/usage/default_values.html +++ b/docs/usage/default_values.html @@ -95,7 +95,9 @@

    Default values

    Utilizing Default Values in MockTable Fields

    -

    Defining default values at the field level in your mock tables is straightforward. The default argument in the field definition allows you to set default values, which are particularly useful for ensuring that joins and other query functionalities operate correctly.

    +

    Defining default values at the field level in your mock tables is straightforward. +The default argument in the field definition allows you to set default values consistency across all test scenarios in one step. +They are particularly useful for ensuring that joins and other query functionalities operate correctly.

    Here’s an example:

    @table_meta(table_ref="data.users")
     class UserTable(BigQueryMockTable):
    @@ -104,7 +106,7 @@ 

    Utilizing Default Values in MockTable Fields# Create instances of the UserTable with various combinations of defaults and specified values users = UserTable.from_dicts([ - {}, # Uses default values --> {"user_id": 1, "user_name": "Mr. T"} + {}, # Left empty {} uses default values --> {"user_id": 1, "user_name": "Mr. T"} {"user_id": 2}, # Overrides user_id but uses default for user_name {"user_id": 3, "user_name": "Nala"} # No defaults used here ]) @@ -124,7 +126,10 @@

    Setting Mock Defaults with table_metauser_id = col.Int(default=1) # Setting up different scenarios to demonstrate the use of defaults -users = UserTable.from_dicts([{"user_id": 1}, {"user_id": 2}]) +users = UserTable.from_dicts([ + {"user_id": 1}, + {"user_id": 2} +]) subscriptions = SubscriptionTable.from_dicts( [ {"subscription_id": 1, "user_id": 1}, diff --git a/docsource/index.rst b/docsource/index.rst index 58dcf3d..98da015 100644 --- a/docsource/index.rst +++ b/docsource/index.rst @@ -32,6 +32,7 @@ It provides a consistent and convenient way to test the execution of your query usage/defining_table_mocks usage/your_sql_query_to_test usage/result_assertion + usage/default_values usage/examples .. toctree:: diff --git a/docsource/usage/default_values.md b/docsource/usage/default_values.md index d3688b5..a127cc2 100644 --- a/docsource/usage/default_values.md +++ b/docsource/usage/default_values.md @@ -8,7 +8,9 @@ Testing SQL queries can often involve repetitive setup for mock tables. In SQLMo ## Utilizing Default Values in MockTable Fields -Defining default values at the field level in your mock tables is straightforward. The default argument in the field definition allows you to set default values, which are particularly useful for ensuring that joins and other query functionalities operate correctly. +Defining default values at the field level in your mock tables is straightforward. +The default argument in the field definition allows you to set default values consistency across all test scenarios in one step. +They are particularly useful for ensuring that joins and other query functionalities operate correctly. Here's an example: @@ -20,7 +22,7 @@ class UserTable(BigQueryMockTable): # Create instances of the UserTable with various combinations of defaults and specified values users = UserTable.from_dicts([ - {}, # Uses default values --> {"user_id": 1, "user_name": "Mr. T"} + {}, # Left empty {} uses default values --> {"user_id": 1, "user_name": "Mr. T"} {"user_id": 2}, # Overrides user_id but uses default for user_name {"user_id": 3, "user_name": "Nala"} # No defaults used here ]) @@ -43,7 +45,10 @@ class MultipleSubscriptionUsersTable(BigQueryMockTable): user_id = col.Int(default=1) # Setting up different scenarios to demonstrate the use of defaults -users = UserTable.from_dicts([{"user_id": 1}, {"user_id": 2}]) +users = UserTable.from_dicts([ + {"user_id": 1}, + {"user_id": 2} +]) subscriptions = SubscriptionTable.from_dicts( [ {"subscription_id": 1, "user_id": 1}, diff --git a/examples/bigquery/test_example.py b/examples/bigquery/test_example.py index dc06bcb..dfe3b00 100644 --- a/examples/bigquery/test_example.py +++ b/examples/bigquery/test_example.py @@ -62,7 +62,12 @@ def test_with_defaults_for_subscriptions_table(): In this test case we don't provide a mock for subscriptions because we use the class default Subscriptions([]) which translates to an empty table. """ - users = UserTable.from_dicts([{"user_id": 1}, {"user_id": 2}]) + users = UserTable.from_dicts( + [ + {"user_id": 1}, + {"user_id": 2}, + ] + ) subscriptions_per_user__expected = [ {"user_id": 1, "subscription_count": 0}, diff --git a/examples/clickhouse/test_example.py b/examples/clickhouse/test_example.py index cc75ecf..bdfec0a 100644 --- a/examples/clickhouse/test_example.py +++ b/examples/clickhouse/test_example.py @@ -62,7 +62,12 @@ def test_with_defaults_for_subscriptions_table(): In this test case we don't provide a mock for subscriptions because we use the class default Subscriptions([]) which translates to an empty table. """ - users = UserTable.from_dicts([{"user_id": 1}, {"user_id": 2}]) + users = UserTable.from_dicts( + [ + {"user_id": 1}, + {"user_id": 2}, + ] + ) subscriptions_per_user__expected = [ {"user_id": 1, "subscription_count": 0},