@@ -699,7 +699,9 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
699699 const [ schema , name ] = table . split ( '.' ) ;
700700 const columns = await this . query < {
701701 COLUMN_NAME : string ,
702- DATA_TYPE : string
702+ DATA_TYPE : string ,
703+ NUMERIC_PRECISION : number | null ,
704+ NUMERIC_SCALE : number | null
703705 } [ ] > (
704706 `SELECT COLUMNS.COLUMN_NAME,
705707 CASE
@@ -708,7 +710,9 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
708710 COLUMNS.DATA_TYPE = 'NUMBER'
709711 THEN 'int'
710712 ELSE COLUMNS.DATA_TYPE
711- END as DATA_TYPE
713+ END as DATA_TYPE,
714+ COLUMNS.NUMERIC_PRECISION,
715+ COLUMNS.NUMERIC_SCALE
712716 FROM INFORMATION_SCHEMA.COLUMNS
713717 WHERE
714718 TABLE_NAME = ${ this . param ( 0 ) } AND
@@ -718,10 +722,24 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
718722 ) ;
719723 return columns . map ( c => ( {
720724 name : c . COLUMN_NAME ,
721- type : this . toGenericType ( c . DATA_TYPE ) ,
725+ type : this . formatColumnType ( c . DATA_TYPE , c . NUMERIC_PRECISION , c . NUMERIC_SCALE ) ,
722726 } ) ) ;
723727 }
724728
729+ /**
730+ * Formats column type with precision and scale for NUMBER/DECIMAL types.
731+ */
732+ private formatColumnType ( dataType : string , precision : number | null , scale : number | null ) : string {
733+ const genericType = this . toGenericType ( dataType ) ;
734+
735+ // For decimal types, include precision and scale if available
736+ if ( genericType === 'decimal' && precision !== null && scale !== null ) {
737+ return `decimal(${ precision } , ${ scale } )` ;
738+ }
739+
740+ return genericType ;
741+ }
742+
725743 /**
726744 * Returns export options clause.
727745 */
@@ -942,9 +960,16 @@ export class SnowflakeDriver extends BaseDriver implements DriverInterface {
942960 } ;
943961 if ( column . isNumber ( ) ) {
944962 // @ts -ignore
945- if ( column . getScale ( ) === 0 ) {
963+ const scale = column . getScale ( ) ;
964+ // @ts -ignore
965+ const precision = column . getPrecision ( ) ;
966+
967+ if ( scale === 0 ) {
946968 type . type = 'int' ;
947- } else if ( column . getScale ( ) && column . getScale ( ) <= 10 ) {
969+ } else if ( scale !== null && precision !== null ) {
970+ // Include precision and scale for decimal types
971+ type . type = `decimal(${ precision } , ${ scale } )` ;
972+ } else if ( scale && scale <= 10 ) {
948973 type . type = 'decimal' ;
949974 } else {
950975 type . type = this . toGenericType ( column . getType ( ) ) ;
0 commit comments